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


Python ConfigNode.__getstate__方法代码示例

本文整理汇总了Python中datastore.config.ConfigNode.__getstate__方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigNode.__getstate__方法的具体用法?Python ConfigNode.__getstate__怎么用?Python ConfigNode.__getstate__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datastore.config.ConfigNode的用法示例。


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

示例1: run

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]
    def run(self, smb):
        try:
            action = 'NONE'
            node = ConfigNode('service.smb', self.configstore)
            if smb.get('filemask'):
                smb['filemask'] = get_integer(smb['filemask'])
            if smb.get('dirmask'):
                smb['dirmask'] = get_integer(smb['dirmask'])
            node.update(smb)
            configure_params(node.__getstate__(), self.dispatcher.call_sync('service.smb.ad_enabled'))

            try:
                rpc = smbconf.SambaMessagingContext()
                rpc.reload_config()
            except OSError:
                action = 'RESTART'

            # XXX: Is restart to change netbios name/workgroup *really* needed?
            if 'netbiosname' in smb or 'workgroup' in smb:
                action = 'RESTART'

            self.dispatcher.dispatch_event('service.smb.changed', {
                'operation': 'updated',
                'ids': None,
            })
        except RpcException as e:
            raise TaskException(
                errno.ENXIO, 'Cannot reconfigure SMB: {0}'.format(str(e))
            )

        return action
开发者ID:650elx,项目名称:middleware,代码行数:33,代码来源:SMBPlugin.py

示例2: run

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]
    def run(self, smb):
        node = ConfigNode('service.smb', self.configstore).__getstate__()
        netbiosname = smb.get('netbiosname')
        if netbiosname is not None:
            for n in netbiosname:
                if not validate_netbios_name(n):
                    raise TaskException(errno.EINVAL, 'Invalid name {0}'.format(n))
        else:
            netbiosname = node['netbiosname']

        workgroup = smb.get('workgroup')
        if workgroup is not None:
            if not validate_netbios_name(workgroup):
                raise TaskException(errno.EINVAL, 'Invalid name')
        else:
            workgroup = node['workgroup']

        if workgroup.lower() in [i.lower() for i in netbiosname]:
            raise TaskException(errno.EINVAL, 'NetBIOS and Workgroup must be unique')

        if smb.get('guest_user'):
            if not self.dispatcher.call_sync('user.query', [('username', '=', smb['guest_user'])], {'single': True}):
                raise TaskException(errno.EINVAL, 'User: {0} does not exist'.format(smb['guest_user']))

        try:
            action = 'NONE'
            node = ConfigNode('service.smb', self.configstore)
            if smb.get('filemask'):
                smb['filemask'] = get_integer(smb['filemask'])

            if smb.get('dirmask'):
                smb['dirmask'] = get_integer(smb['dirmask'])

            node.update(smb)
            configure_params(node.__getstate__(), self.dispatcher.call_sync('service.smb.ad_enabled'))

            try:
                rpc = smbconf.SambaMessagingContext()
                rpc.reload_config()
            except OSError:
                action = 'RESTART'

            # XXX: Is restart to change netbios name/workgroup *really* needed?
            if 'netbiosname' in smb or 'workgroup' in smb:
                action = 'RESTART'

            self.dispatcher.dispatch_event('service.smb.changed', {
                'operation': 'updated',
                'ids': None,
            })
        except RpcException as e:
            raise TaskException(
                errno.ENXIO, 'Cannot reconfigure SMB: {0}'.format(str(e))
            )

        return action
开发者ID:erinix,项目名称:middleware,代码行数:58,代码来源:SMBPlugin.py

示例3: run

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]
    def run(self, smb):
        node = ConfigNode("service.smb", self.configstore).__getstate__()
        netbiosname = smb.get("netbiosname")
        if netbiosname is not None:
            for n in netbiosname:
                if not validate_netbios_name(n):
                    raise TaskException(errno.EINVAL, "Invalid name {0}".format(n))
        else:
            netbiosname = node["netbiosname"]

        workgroup = smb.get("workgroup")
        if workgroup is not None:
            if not validate_netbios_name(workgroup):
                raise TaskException(errno.EINVAL, "Invalid name")
        else:
            workgroup = node["workgroup"]

        if workgroup.lower() in [i.lower() for i in netbiosname]:
            raise TaskException(errno.EINVAL, "NetBIOS and Workgroup must be unique")

        try:
            action = "NONE"
            node = ConfigNode("service.smb", self.configstore)
            if smb.get("filemask"):
                smb["filemask"] = get_integer(smb["filemask"])

            if smb.get("dirmask"):
                smb["dirmask"] = get_integer(smb["dirmask"])

            node.update(smb)
            configure_params(node.__getstate__(), self.dispatcher.call_sync("service.smb.ad_enabled"))

            try:
                rpc = smbconf.SambaMessagingContext()
                rpc.reload_config()
            except OSError:
                action = "RESTART"

            # XXX: Is restart to change netbios name/workgroup *really* needed?
            if "netbiosname" in smb or "workgroup" in smb:
                action = "RESTART"

            self.dispatcher.dispatch_event("service.smb.changed", {"operation": "updated", "ids": None})
        except RpcException as e:
            raise TaskException(errno.ENXIO, "Cannot reconfigure SMB: {0}".format(str(e)))

        return action
开发者ID:freenas,项目名称:middleware,代码行数:49,代码来源:SMBPlugin.py

示例4: run

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]
    def run(self, cifs):
        try:
            action = 'NONE'
            node = ConfigNode('service.cifs', self.configstore)
            node.update(cifs)
            configure_params(node.__getstate__())

            # XXX: Is restart to change netbios name/workgroup *really* needed?
            if 'netbiosname' in cifs or 'workgroup' in cifs:
                action = 'RESTART'

            self.dispatcher.dispatch_event('service.cifs.changed', {
                'operation': 'updated',
                'ids': None,
            })
        except RpcException as e:
            raise TaskException(
                errno.ENXIO, 'Cannot reconfigure CIFS: {0}'.format(str(e))
            )

        return action
开发者ID:williambr,项目名称:middleware,代码行数:23,代码来源:CIFSPlugin.py

示例5: _init

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]
def _init(dispatcher, plugin):

    def set_cifs_sid():
        cifs = dispatcher.call_sync('service.cifs.get_config')
        if not cifs['sid']:
            try:
                sid = system('/usr/local/bin/net', 'getlocalsid')[0]
                if ':' in sid:
                    sid = sid.split(':', 1)[1].strip(' ').strip('\n')
                    if sid:
                        dispatcher.configstore.set('service.cifs.sid', sid)
                        cifs['sid'] = sid
            except SubprocessException:
                logger.error('Failed to get local sid', exc_info=True)
        try:
            if cifs['sid']:
                system('/usr/local/bin/net', 'setlocalsid', cifs['sid'])
        except SubprocessException as err:
            logger.error('Failed to set local sid: {0}'.format(err.output))

    # Register schemas
    PROTOCOLS = [
        'CORE',
        'COREPLUS',
        'LANMAN1',
        'LANMAN2',
        'NT1',
        'SMB2',
        'SMB2_02',
        'SMB2_10',
        'SMB2_22',
        'SMB2_24',
        'SMB3',
        'SMB3_00',
    ]

    plugin.register_schema_definition('service-cifs', {
        'type': 'object',
        'properties': {
            'netbiosname': {
                'type': 'array',
                'items': {'type': 'string'}
            },
            'workgroup': {'type': 'string'},
            'description': {'type': 'string'},
            'dos_charset': {'type': 'string'},
            'unix_charset': {'type': 'string'},
            'log_level': {
                'type': 'string',
                'enum': list(LogLevel.__members__.keys())
            },
            'syslog': {'type': 'boolean'},
            'local_master': {'type': 'boolean'},
            'domain_logons': {'type': 'boolean'},
            'time_server': {'type': 'boolean'},
            'guest_user': {'type': 'string'},
            'filemask': {'type': ['string', 'null']},
            'dirmask': {'type': ['string', 'null']},
            'empty_password': {'type': 'boolean'},
            'unixext': {'type': 'boolean'},
            'zeroconf': {'type': 'boolean'},
            'hostlookup': {'type': 'boolean'},
            'min_protocol': {'type': ['string', 'null'], 'enum': [None] + PROTOCOLS},
            'max_protocol': {'type': 'string', 'enum': PROTOCOLS},
            'execute_always': {'type': 'boolean'},
            'obey_pam_restrictions': {'type': 'boolean'},
            'bind_addresses': {
                'type': ['array', 'null'],
                'items': {'type': 'string'},
            },
            'auxiliary': {'type': ['string', 'null']},
            'sid': {'type': ['string', 'null']},
        },
        'additionalProperties': False,
    })

    # Register providers
    plugin.register_provider("service.cifs", CIFSProvider)

    # Register tasks
    plugin.register_task_handler("service.cifs.configure", CIFSConfigureTask)

    set_cifs_sid()
    node = ConfigNode('service.cifs', dispatcher.configstore)
    configure_params(node.__getstate__())
开发者ID:williambr,项目名称:middleware,代码行数:87,代码来源:CIFSPlugin.py

示例6: _init

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]

#.........这里部分代码省略.........
        'NT1',
        'SMB2',
        'SMB2_02',
        'SMB2_10',
        'SMB2_22',
        'SMB2_24',
        'SMB3',
        'SMB3_00',
    ]

    plugin.register_schema_definition('ServiceSmb', {
        'type': 'object',
        'properties': {
            'type': {'enum': ['ServiceSmb']},
            'enable': {'type': 'boolean'},
            'netbiosname': {
                'type': 'array',
                'items': {'type': 'string'}
            },
            'workgroup': {'type': 'string'},
            'description': {'type': 'string'},
            'dos_charset': {'$ref': 'ServiceSmbDoscharset'},
            'unix_charset': {'$ref': 'ServiceSmbUnixcharset'},
            'log_level': {'$ref': 'ServiceSmbLoglevel'},
            'local_master': {'type': 'boolean'},
            'domain_logons': {'type': 'boolean'},
            'time_server': {'type': 'boolean'},
            'guest_user': {'type': 'string'},
            'filemask': {
                'oneOf': [
                    {'$ref': 'UnixPermissions'},
                    {'type': 'null'}
                ]
            },
            'dirmask': {
                'oneOf': [
                    {'$ref': 'UnixPermissions'},
                    {'type': 'null'}
                ]
            },
            'empty_password': {'type': 'boolean'},
            'unixext': {'type': 'boolean'},
            'zeroconf': {'type': 'boolean'},
            'hostlookup': {'type': 'boolean'},
            'min_protocol': {'$ref': 'ServiceSmbMinprotocol'},
            'max_protocol': {'$ref': 'ServiceSmbMaxprotocol'},
            'execute_always': {'type': 'boolean'},
            'obey_pam_restrictions': {'type': 'boolean'},
            'bind_addresses': {
                'type': ['array', 'null'],
                'items': {'type': 'string'},
            },
            'auxiliary': {'type': ['string', 'null']},
            'sid': {'type': ['string', 'null']},
        },
        'additionalProperties': False,
    })

    plugin.register_schema_definition('ServiceSmbDoscharset', {
        'type': 'string',
        'enum': [
            'CP437', 'CP850', 'CP852', 'CP866', 'CP932', 'CP949',
            'CP950', 'CP1029', 'CP1251', 'ASCII'
        ]
    })

    plugin.register_schema_definition('ServiceSmbUnixcharset', {
        'type': 'string',
        'enum': ['UTF-8', 'iso-8859-1', 'iso-8859-15', 'gb2312', 'EUC-JP', 'ASCII']
    })

    plugin.register_schema_definition('ServiceSmbLoglevel', {
        'type': 'string',
        'enum': list(LogLevel.__members__.keys())
    })

    plugin.register_schema_definition('ServiceSmbMinprotocol', {
        'type': 'string',
        'enum': PROTOCOLS
    })

    plugin.register_schema_definition('ServiceSmbMaxprotocol', {
        'type': 'string',
        'enum': PROTOCOLS
    })

    # Register providers
    plugin.register_provider("service.smb", SMBProvider)

    # Register tasks
    plugin.register_task_handler("service.smb.update", SMBConfigureTask)

    # Register debug hooks
    plugin.register_debug_hook(collect_debug)

    set_smb_sid()
    os.unlink('/var/db/samba4/registry.tdb')

    node = ConfigNode('service.smb', dispatcher.configstore)
    configure_params(node.__getstate__(), dispatcher.call_sync('service.smb.ad_enabled'))
开发者ID:erinix,项目名称:middleware,代码行数:104,代码来源:SMBPlugin.py

示例7: _init

# 需要导入模块: from datastore.config import ConfigNode [as 别名]
# 或者: from datastore.config.ConfigNode import __getstate__ [as 别名]

#.........这里部分代码省略.........
                    if sid:
                        dispatcher.configstore.set("service.smb.sid", sid)
                        smb["sid"] = sid
            except SubprocessException:
                logger.error("Failed to get local sid", exc_info=True)
        try:
            if smb["sid"]:
                system("/usr/local/bin/net", "setlocalsid", smb["sid"])
        except SubprocessException as err:
            logger.error("Failed to set local sid: {0}".format(err.output))

    # Register schemas
    PROTOCOLS = [
        "CORE",
        "COREPLUS",
        "LANMAN1",
        "LANMAN2",
        "NT1",
        "SMB2",
        "SMB2_02",
        "SMB2_10",
        "SMB2_22",
        "SMB2_24",
        "SMB3",
        "SMB3_00",
    ]

    plugin.register_schema_definition(
        "service-smb",
        {
            "type": "object",
            "properties": {
                "type": {"enum": ["service-smb"]},
                "enable": {"type": "boolean"},
                "netbiosname": {"type": "array", "items": {"type": "string"}},
                "workgroup": {"type": "string"},
                "description": {"type": "string"},
                "dos_charset": {"$ref": "service-smb-doscharset"},
                "unix_charset": {"$ref": "service-smb-unixcharset"},
                "log_level": {"$ref": "service-smb-loglevel"},
                "syslog": {"type": "boolean"},
                "local_master": {"type": "boolean"},
                "domain_logons": {"type": "boolean"},
                "time_server": {"type": "boolean"},
                "guest_user": {"type": "string"},
                "filemask": {"oneOf": [{"$ref": "unix-permissions"}, {"type": "null"}]},
                "dirmask": {"oneOf": [{"$ref": "unix-permissions"}, {"type": "null"}]},
                "empty_password": {"type": "boolean"},
                "unixext": {"type": "boolean"},
                "zeroconf": {"type": "boolean"},
                "hostlookup": {"type": "boolean"},
                "min_protocol": {"$ref": "service-smb-minprotocol"},
                "max_protocol": {"$ref": "service-smb-maxprotocol"},
                "execute_always": {"type": "boolean"},
                "obey_pam_restrictions": {"type": "boolean"},
                "bind_addresses": {"type": ["array", "null"], "items": {"type": "string"}},
                "auxiliary": {"type": ["string", "null"]},
                "sid": {"type": ["string", "null"]},
            },
            "additionalProperties": False,
        },
    )

    plugin.register_schema_definition(
        "service-smb-doscharset",
        {
            "type": "string",
            "enum": ["CP437", "CP850", "CP852", "CP866", "CP932", "CP949", "CP950", "CP1029", "CP1251", "ASCII"],
        },
    )

    plugin.register_schema_definition(
        "service-smb-unixcharset",
        {"type": "string", "enum": ["UTF-8", "iso-8859-1", "iso-8859-15", "gb2312", "EUC-JP", "ASCII"]},
    )

    plugin.register_schema_definition(
        "service-smb-loglevel", {"type": "string", "enum": list(LogLevel.__members__.keys())}
    )

    plugin.register_schema_definition(
        "service-smb-minprotocol", {"type": ["string", "null"], "enum": [None] + PROTOCOLS}
    )

    plugin.register_schema_definition("service-smb-maxprotocol", {"type": "string", "enum": PROTOCOLS})

    # Register providers
    plugin.register_provider("service.smb", SMBProvider)

    # Register tasks
    plugin.register_task_handler("service.smb.update", SMBConfigureTask)

    # Register debug hooks
    plugin.register_debug_hook(collect_debug)

    set_smb_sid()
    os.unlink("/var/db/samba4/registry.tdb")

    node = ConfigNode("service.smb", dispatcher.configstore)
    configure_params(node.__getstate__(), dispatcher.call_sync("service.smb.ad_enabled"))
开发者ID:freenas,项目名称:middleware,代码行数:104,代码来源:SMBPlugin.py


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