当前位置: 首页>>代码示例>>Python>>正文


Python config.ConfigStore类代码示例

本文整理汇总了Python中datastore.config.ConfigStore的典型用法代码示例。如果您正苦于以下问题:Python ConfigStore类的具体用法?Python ConfigStore怎么用?Python ConfigStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ConfigStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_datastore

    def init_datastore(self):
        try:
            self.datastore = datastore.get_datastore()
        except datastore.DatastoreException as err:
            self.logger.error('Cannot initialize datastore: %s', str(err))
            sys.exit(1)

        self.configstore = ConfigStore(self.datastore)
开发者ID:650elx,项目名称:middleware,代码行数:8,代码来源:main.py

示例2: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_default_datastore()
        cs = ConfigStore(ds)

        lldp = orm['services.LLDP'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='lldp')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.lldp.enable', svc.srv_enable)

        cs.set('service.lldp.save_description', lldp.lldp_intdesc)
        cs.set('service.lldp.country_code', lldp.lldp_country or None)
        cs.set('service.lldp.location', lldp.lldp_location or None)
开发者ID:williambr,项目名称:middleware,代码行数:19,代码来源:9012_lldp_to_mongodb.py

示例3: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        iscsi = orm['services.iSCSITargetGlobalConfiguration'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='iscsi')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.iscsi.enable', svc.srv_enable)

        cs.set('service.iscsi.base_name', iscsi.iscsi_basename)
        cs.set('service.iscsi.isns_servers', iscsi.iscsi_isns_servers)
        cs.set('service.iscsi.pool_space_threshold', iscsi.iscsi_pool_avail_threshold)

        # iSCSI Portals
        iscsi_portals = orm['services.iSCSITargetPortal'].objects.all()
        for p in iscsi_portals:
            ds.insert('iscsi.portals', {
                'id': 'pg{0}'.format(p.id),
                'tag': p.iscsi_target_portal_tag,
                'description': p.iscsi_target_portal_comment,
                'discovery_auth_group': 'ag{0}'.format(p.iscsi_target_portal_discoveryauthgroup),
                'listen': [{'address': i.iscsi_target_portalip_ip, 'port': i.iscsi_target_portalip_port} for i in p.ips.all()]
            })

        # iSCSI Targets
        iscsi_targets = orm['services.iSCSITarget'].objects.all()
        for t in iscsi_targets:
            ds.insert('iscsi.targets', {
                'id': t.iscsi_target_name,
                'portal_group': 'default',  # XXX: Needs to pass proper portal group
                'auth_group': 'no-authentication',  # XXX: Needs to pass proper auth group
                'description': t.iscsi_target_alias,
                'extents': []
            })
开发者ID:freenas,项目名称:middleware,代码行数:41,代码来源:9013_iscsi_to_mongodb.py

示例4: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_default_datastore()
        cs = ConfigStore(ds)

        rsyncd = orm['services.Rsyncd'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='rsync')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.rsyncd.enable', svc.srv_enable)

        cs.set('service.rsyncd.port', rsyncd.rsyncd_port)
        cs.set('service.rsyncd.auxiliary', rsyncd.rsyncd_auxiliary)

        for rmod in orm['services.RsyncMod'].objects.all():
            if rmod.rsyncmod_path == 'ro':
                mode = 'READONLY'
            elif rmod.rsyncmod_path == 'wo':
                mode = 'WRITEONLY'
            else:
                mode = 'READWRITE'
            ds.insert('rsyncd-module', {
                'name': rmod.rsyncmod_name,
                'description': rmod.rsyncmod_comment or None,
                'path': rmod.rsyncmod_path,
                'mode': mode,
                'max_connections': rmod.rsyncmod_maxconn or None,
                'user': rmod.rsyncmod_user,
                'group': rmod.rsyncmod_group,
                'hosts_allow': rmod.rsyncmod_hostsallow or None,
                'hosts_deny': rmod.rsyncmod_hostsdeny or None,
                'auxiliary': rmod.rsyncmod_auxiliary or None,
            })
开发者ID:williambr,项目名称:middleware,代码行数:38,代码来源:9005_rsyncd_to_mongodb.py

示例5: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        ddns = orm['services.DynamicDNS'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='dynamicdns')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.dyndns.enable', svc.srv_enable)

        if ddns.ddns_provider:
            cs.set('service.dyndns.provider', ddns.ddns_provider)
        if ddns.ddns_ipserver:
            cs.set('service.dyndns.ipserver', ddns.ddns_ipserver)
        if ddns.ddns_domain:
            cs.set('service.dyndns.domains', ddns.ddns_domain.split(','))
        cs.set('service.dyndns.username', ddns.ddns_username)
        try:
            pwd = notifier().pwenc_decrypt(ddns.ddns_password)
        except:
            pwd = ''
        cs.set('service.dyndns.password', pwd)
        if ddns.ddns_updateperiod:
            cs.set('service.dyndns.update_period', ddns.ddns_updateperiod)
        if ddns.ddns_fupdateperiod:
            cs.set('service.dyndns.force_update_period', ddns.ddns_fupdateperiod)
        if ddns.ddns_options:
            cs.set('service.dyndns.auxiliary', ddns.ddns_options)
开发者ID:freenas,项目名称:middleware,代码行数:34,代码来源:9002_dyndns_to_mongodb.py

示例6: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_default_datastore()
        cs = ConfigStore(ds)

        tftp = orm['services.TFTP'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='tftp')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.tftp.enable', svc.srv_enable)

        cs.set('service.tftp.path', tftp.tftp_directory or None)
        cs.set('service.tftp.allow_new_files', tftp.tftp_newfiles)
        cs.set('service.tftp.port', tftp.tftp_port)
        cs.set('service.tftp.username', tftp.tftp_username)
        cs.set('service.tftp.umask', tftp.tftp_umask)
        cs.set('service.tftp.auxiliary', tftp.tftp_options or None)
开发者ID:williambr,项目名称:middleware,代码行数:22,代码来源:9009_tftp_to_mongodb.py

示例7: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        ssh = orm['services.SSH'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='ssh')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.sshd.enable', svc.srv_enable)

        cs.set('service.sshd.port', ssh.ssh_tcpport)
        cs.set('service.sshd.permit_root_login', ssh.ssh_rootlogin)
        cs.set('service.sshd.allow_password_auth', ssh.ssh_passwordauth)
        cs.set('service.sshd.allow_port_forwarding', ssh.ssh_tcpfwd)
        cs.set('service.sshd.compression', ssh.ssh_compression)
        cs.set('service.sshd.sftp_log_level', ssh.ssh_sftp_log_level)
        cs.set('service.sshd.sftp_log_facility', ssh.ssh_sftp_log_facility)
        cs.set('service.sshd.auxiliary', ssh.ssh_options or None)
        cs.set('service.sshd.keys.host.private', ssh.ssh_host_key)
        cs.set('service.sshd.keys.host.public', ssh.ssh_host_key_pub)
        cs.set('service.sshd.keys.dsa.private', ssh.ssh_host_dsa_key or None)
        cs.set('service.sshd.keys.dsa.public', ssh.ssh_host_dsa_key_pub or None)
        if ssh.ssh_host_dsa_key_cert_pub:
            cs.set('service.sshd.keys.dsa.certificate', ssh.ssh_host_dsa_key_cert_pub)
        cs.set('service.sshd.keys.ecdsa.private', ssh.ssh_host_ecdsa_key or None)
        cs.set('service.sshd.keys.ecdsa.public', ssh.ssh_host_ecdsa_key_pub or None)
        if ssh.ssh_host_ecdsa_key_cert_pub:
            cs.set('service.sshd.keys.ecdsa.certificate', ssh.ssh_host_ecdsa_key_cert_pub)
        cs.set('service.sshd.keys.ed25519.private', ssh.ssh_host_ed25519_key or None)
        cs.set('service.sshd.keys.ed25519.public', ssh.ssh_host_ed25519_key_pub or None)
        if ssh.ssh_host_ed25519_key_cert_pub:
            cs.set('service.sshd.keys.ed25519.certificate', ssh.ssh_host_ed25519_key_cert_pub)
        cs.set('service.sshd.keys.rsa.private', ssh.ssh_host_rsa_key or None)
        cs.set('service.sshd.keys.rsa.public', ssh.ssh_host_rsa_key_pub or None)
        if ssh.ssh_host_rsa_key_cert_pub:
            cs.set('service.sshd.keys.rsa.certificate', ssh.ssh_host_rsa_key_cert_pub)
开发者ID:650elx,项目名称:middleware,代码行数:42,代码来源:9008_ssh_to_mongodb.py

示例8: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        nfs = orm['services.NFS'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='nfs')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.nfs.enable', svc.srv_enable)

        cs.set('service.nfs.servers', nfs.nfs_srv_servers)
        cs.set('service.nfs.udp', nfs.nfs_srv_udp)
        cs.set('service.nfs.nonroot', nfs.nfs_srv_allow_nonroot)
        cs.set('service.nfs.v4', nfs.nfs_srv_v4)
        cs.set('service.nfs.v4_kerberos', nfs.nfs_srv_v4_krb)
        if nfs.nfs_srv_bindip:
            cs.set('service.nfs.bind_addresses', nfs.nfs_srv_bindip.split(','))
        if nfs.nfs_srv_mountd_port:
            cs.set('service.nfs.mountd_port', nfs.nfs_srv_mountd_port)
        if nfs.nfs_srv_rpcstatd_port:
            cs.set('service.nfs.rpcstatd_port', nfs.nfs_srv_rpcstatd_port)
        if nfs.nfs_srv_rpclockd_port:
            cs.set('service.nfs.rpclockd_port', nfs.nfs_srv_rpclockd_port)
开发者ID:freenas,项目名称:middleware,代码行数:29,代码来源:9004_nfs_to_mongodb.py

示例9: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if "FREENAS_INSTALL" in os.environ:
            return

        ds = get_default_datastore()
        cs = ConfigStore(ds)

        nfs = orm["services.NFS"].objects.all()[0]
        svc = orm["services.services"].objects.filter(srv_service="nfs")
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set("service.nfs.enable", svc.srv_enable)

        cs.set("service.nfs.servers", nfs.nfs_srv_servers)
        cs.set("service.nfs.udp", nfs.nfs_srv_udp)
        cs.set("service.nfs.nonroot", nfs.nfs_srv_allow_nonroot)
        cs.set("service.nfs.v4", nfs.nfs_srv_v4)
        cs.set("service.nfs.v4_kerberos", nfs.nfs_srv_v4_krb)
        if nfs.nfs_srv_bindip:
            cs.set("service.nfs.bind_addresses", nfs.nfs_srv_bindip.split(","))
        if nfs.nfs_srv_mountd_port:
            cs.set("service.nfs.mountd_port", nfs.nfs_srv_mountd_port)
        if nfs.nfs_srv_rpcstatd_port:
            cs.set("service.nfs.rpcstatd_port", nfs.nfs_srv_rpcstatd_port)
        if nfs.nfs_srv_rpclockd_port:
            cs.set("service.nfs.rpclockd_port", nfs.nfs_srv_rpclockd_port)
开发者ID:williambr,项目名称:middleware,代码行数:29,代码来源:9004_nfs_to_mongodb.py

示例10: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        email = orm['system.Email'].objects.order_by('-id')[0]

        cs.set('mail.from', email.em_fromemail)
        cs.set('mail.server', email.em_outgoingserver)
        cs.set('mail.port', email.em_port)

        encryption = 'PLAIN'
        if email.em_security in ('ssl', 'tls'):
            encryption = email.em_security.upper()

        cs.set('mail.encryption', encryption)
        cs.set('mail.auth', email.em_smtp)
        cs.set('mail.user', email.em_user)
        cs.set('mail.pass', email.em_pass)
开发者ID:freenas,项目名称:middleware,代码行数:23,代码来源:9002_email_to_mongodb.py

示例11: Main

class Main(object):
    def __init__(self):
        self.logger = logging.getLogger('dscached')
        self.config = None
        self.datastore = None
        self.configstore = None
        self.rpc = RpcContext()
        self.rpc.streaming_enabled = True
        self.rpc.streaming_burst = 16
        self.client = None
        self.server = None
        self.plugin_dirs = []
        self.plugins = {}
        self.directories = []
        self.users_cache = TTLCacheStore()
        self.groups_cache = TTLCacheStore()
        self.hosts_cache = TTLCacheStore()
        self.cache_ttl = 7200
        self.search_order = []
        self.cache_enumerations = True
        self.cache_lookups = True
        self.rpc.register_service_instance('dscached.account', AccountService(self))
        self.rpc.register_service_instance('dscached.group', GroupService(self))
        self.rpc.register_service_instance('dscached.host', HostService(self))
        self.rpc.register_service_instance('dscached.management', ManagementService(self))
        self.rpc.register_service_instance('dscached.debug', DebugService())

    def get_enabled_directories(self):
        return list(filter(None, (self.get_directory_by_name(n) for n in self.get_search_order())))

    def get_search_order(self):
        return ['local', 'system'] + self.search_order

    def get_directory_by_domain(self, domain_name):
        return first_or_default(lambda d: d.domain_name == domain_name, self.directories)

    def get_directory_by_name(self, name):
        return first_or_default(lambda d: d.name == name, self.directories)

    def get_directory_for_id(self, uid=None, gid=None):
        if uid is not None:
            if uid == 0:
                # Special case for root user
                return first_or_default(lambda d: d.plugin_type == 'local', self.directories)

            return first_or_default(
                lambda d: d.max_uid and d.max_uid >= uid >= d.min_uid,
                self.directories
            )

        if gid is not None:
            if gid == 0:
                # Special case for wheel group
                return first_or_default(lambda d: d.plugin_type == 'local', self.directories)

            return first_or_default(
                lambda d: d.max_gid and d.max_gid >= gid >= d.min_gid,
                self.directories
            )

    def init_datastore(self):
        try:
            self.datastore = datastore.get_datastore()
        except datastore.DatastoreException as err:
            self.logger.error('Cannot initialize datastore: %s', str(err))
            sys.exit(1)

        self.configstore = ConfigStore(self.datastore)

    def init_dispatcher(self):
        def on_error(reason, **kwargs):
            if reason in (ClientError.CONNECTION_CLOSED, ClientError.LOGOUT):
                self.logger.warning('Connection to dispatcher lost')
                self.connect()

        self.client = Client()
        self.client.on_error(on_error)
        self.connect()

    def init_server(self, address):
        self.server = Server(self)
        self.server.rpc = self.rpc
        self.server.start(address)
        thread = Thread(target=self.server.serve_forever)
        thread.name = 'ServerThread'
        thread.daemon = True
        thread.start()

    def parse_config(self, filename):
        try:
            with open(filename, 'r') as f:
                self.config = json.load(f)
        except IOError as err:
            self.logger.error('Cannot read config file: %s', err.message)
            sys.exit(1)
        except ValueError:
            self.logger.error('Config file has unreadable format (not valid JSON)')
            sys.exit(1)

        self.plugin_dirs = self.config['dscached']['plugin-dirs']
#.........这里部分代码省略.........
开发者ID:650elx,项目名称:middleware,代码行数:101,代码来源:main.py

示例12: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if "FREENAS_INSTALL" in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        ftp = orm["services.FTP"].objects.all()[0]
        svc = orm["services.services"].objects.filter(srv_service="ftp")
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set("service.ftp.enable", svc.srv_enable)

        tls_options = []
        if ftp.ftp_tls_opt_allow_client_renegotiations:
            tls_options.append("ALLOW_CLIENT_RENEGOTIATIONS")
        if ftp.ftp_tls_opt_allow_dot_login:
            tls_options.append("ALLOW_DOT_LOGIN")
        if ftp.ftp_tls_opt_allow_per_user:
            tls_options.append("ALLOW_PER_USER")
        if ftp.ftp_tls_opt_common_name_required:
            tls_options.append("COMMON_NAME_REQUIRED")
        if ftp.ftp_tls_opt_enable_diags:
            tls_options.append("ENABLE_DIAGNOSTICS")
        if ftp.ftp_tls_opt_export_cert_data:
            tls_options.append("EXPORT_CERTIFICATE_DATA")
        if ftp.ftp_tls_opt_no_cert_request:
            tls_options.append("NO_CERTIFICATE_REQUEST")
        if ftp.ftp_tls_opt_no_empty_fragments:
            tls_options.append("NO_EMPTY_FRAGMENTS")
        if ftp.ftp_tls_opt_no_session_reuse_required:
            tls_options.append("NO_SESSION_REUSE_REQUIRED")
        if ftp.ftp_tls_opt_stdenvvars:
            tls_options.append("STANDARD_ENV_VARS")
        if ftp.ftp_tls_opt_dns_name_required:
            tls_options.append("DNS_NAME_REQUIRED")
        if ftp.ftp_tls_opt_ip_address_required:
            tls_options.append("IP_ADDRESS_REQUIRED")

        cs.set("service.ftp.port", ftp.ftp_port)
        cs.set("service.ftp.max_clients", ftp.ftp_clients)
        if ftp.ftp_ipconnections:
            cs.set("service.ftp.ip_connections", ftp.ftp_ipconnections)
        cs.set("service.ftp.login_attempt", ftp.ftp_loginattempt)
        cs.set("service.ftp.timeout", ftp.ftp_timeout)
        cs.set("service.ftp.root_login", ftp.ftp_rootlogin)
        cs.set("service.ftp.only_anonymous", ftp.ftp_onlyanonymous)
        if ftp.ftp_anonpath:
            cs.set("service.ftp.anonymous_path", ftp.ftp_anonpath)
        cs.set("service.ftp.only_local", ftp.ftp_onlylocal)
        cs.set("service.ftp.display_login", ftp.ftp_banner)
        cs.set("service.ftp.filemask", ftp.ftp_filemask)
        cs.set("service.ftp.dirmask", ftp.ftp_dirmask)
        cs.set("service.ftp.fxp", ftp.ftp_fxp)
        cs.set("service.ftp.resume", ftp.ftp_resume)
        cs.set("service.ftp.chroot", ftp.ftp_defaultroot)
        cs.set("service.ftp.ident", ftp.ftp_ident)
        cs.set("service.ftp.reverse_dns", ftp.ftp_reversedns)
        cs.set("service.ftp.masquerade_address", ftp.ftp_masqaddress)
        if ftp.ftp_passiveportsmin:
            cs.set("service.ftp.passive_ports_min", ftp.ftp_passiveportsmin)
        if ftp.ftp_passiveportsmax:
            cs.set("service.ftp.passive_ports_max", ftp.ftp_passiveportsmax)
        if ftp.ftp_localuserbw:
            cs.set("service.ftp.local_up_bandwidth", ftp.ftp_localuserbw)
        if ftp.ftp_localuserdlbw:
            cs.set("service.ftp.local_down_bandwidth", ftp.ftp_localuserdlbw)
        if ftp.ftp_anonuserbw:
            cs.set("service.ftp.anon_up_bandwidth", ftp.ftp_anonuserbw)
        if ftp.ftp_anonuserdlbw:
            cs.set("service.ftp.anon_down_bandwidth", ftp.ftp_anonuserdlbw)
        cs.set("service.ftp.tls", ftp.ftp_tls)
        if tls_options:
            cs.set("service.ftp.tls_options", tls_options)
        cs.set("service.ftp.auxiliary", ftp.ftp_options)
开发者ID:freenas,项目名称:middleware,代码行数:78,代码来源:9003_ftp_to_mongodb.py

示例13: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        afp = orm['services.AFP'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='afp')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.afp.enable', svc.srv_enable)

        cs.set('service.afp.guest_enable', afp.afp_srv_guest)
        if afp.afp_srv_guest_user:
            cs.set('service.afp.guest_user', afp.afp_srv_guest_user)
        if afp.afp_srv_bindip:
            cs.set('service.afp.bind_addresses', afp.afp_srv_bindip)
        cs.set('service.afp.connections_limit', afp.afp_srv_connections_limit)
        cs.set('service.afp.homedir_enable"', afp.afp_srv_homedir_enable)
        if afp.afp_srv_homedir:
            cs.set('service.afp.homedir_path', afp.afp_srv_homedir)
        if afp.afp_srv_homename:
            cs.set('service.afp.homedir_name', afp.afp_srv_homename)
        if afp.afp_srv_dbpath:
            cs.set('service.afp.dbpath', afp.afp_srv_dbpath)
        if afp.afp_srv_global_aux:
            cs.set('service.afp.auxiliary', afp.afp_srv_global_aux)
开发者ID:650elx,项目名称:middleware,代码行数:31,代码来源:9000_afp_to_mongodb.py

示例14: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        def migrate_cert(certs):
            id_uuid_map = {}
            signedby = []

            for obj in certs:

                if obj.cert_type == 0x1:
                    _type = 'CA_EXISTING'
                elif obj.cert_type == 0x2:
                    _type = 'CA_INTERNAL'
                elif obj.cert_type == 0x4:
                    _type = 'CA_INTERMEDIATE'
                elif obj.cert_type == 0x8:
                    _type = 'CERT_EXISTING'
                elif obj.cert_type == 0x10:
                    _type = 'CERT_INTERNAL'
                else:
                    _type = 'CERT_CSR'

                cert = {
                    'type': _type,
                    'name': obj.cert_name,
                    'certificate': obj.cert_certificate,
                    'privatekey': obj.cert_privatekey,
                    'csr': obj.cert_CSR,
                    'key_length': obj.cert_key_length,
                    'digest_algorithm': obj.cert_digest_algorithm,
                    'lifetime': obj.cert_lifetime,
                    'country': obj.cert_country,
                    'state': obj.cert_state,
                    'city': obj.cert_city,
                    'organization': obj.cert_organization,
                    'email': obj.cert_email,
                    'common': obj.cert_common,
                    'serial': obj.cert_serial,
                }

                pkey = ds.insert('crypto.certificates', cert)
                id_uuid_map[obj.id] = pkey

                if obj.cert_signedby is not None:
                    signedby.append(obj.id)

            return id_uuid_map, signedby

        def migrate_signedby(model, id_uuid_map, signedby, ca_map):
            for id in signedby:
                cobj = model.objects.get(id=id)
                pkey = id_uuid_map.get(id)
                if pkey is None:
                    continue
                cert = ds.get_by_id('crypto.certificates', pkey)
                if cobj.cert_signedby is None:
                    continue

                signedby = ca_map.get(cobj.cert_signedby.id)
                if signedby is None:
                    continue
                cert['signedby'] = signedby
                ds.update('crypto.certificates', pkey, cert)

        id_uuid_map, signedby = migrate_cert(orm['system.CertificateAuthority'].objects.order_by('cert_signedby'))
        migrate_signedby(orm['system.CertificateAuthority'], id_uuid_map, signedby, id_uuid_map)

        cert_id_uuid_map, cert_signedby = migrate_cert(orm['system.Certificate'].objects.order_by('cert_signedby'))
        migrate_signedby(orm['system.Certificate'], cert_id_uuid_map, cert_signedby, id_uuid_map)

        settings = orm['system.Settings'].objects.order_by('-id')[0]
        if settings.stg_guicertificate:
            uuid = cert_id_uuid_map.get(settings.stg_guicertificate.id)
            if uuid:
                cs.set('service.nginx.https.certificate', uuid)

        ds.collection_record_migration('crypto.certificates', 'freenas9_migration')
开发者ID:freenas,项目名称:middleware,代码行数:83,代码来源:9001_certificates_to_mongodb.py

示例15: forwards

    def forwards(self, orm):

        # Skip for install time, we only care for upgrades here
        if 'FREENAS_INSTALL' in os.environ:
            return

        ds = get_datastore()
        cs = ConfigStore(ds)

        smartd = orm['services.SMART'].objects.all()[0]
        svc = orm['services.services'].objects.filter(srv_service='smartd')
        svc = svc[0] if svc.exists() else None

        if svc:
            cs.set('service.smartd.enable', svc.srv_enable)

        cs.set('service.smartd.interval', smartd.smart_interval)
        cs.set('service.smartd.power_mode', smartd.smart_powermode.upper())
        cs.set('service.smartd.temp_difference', smartd.smart_difference or None)
        cs.set('service.smartd.temp_informational', smartd.smart_informational or None)
        cs.set('service.smartd.temp_critical', smartd.smart_critical or None)
开发者ID:650elx,项目名称:middleware,代码行数:21,代码来源:9006_smartd_to_mongodb.py


注:本文中的datastore.config.ConfigStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。