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


Python EtcdConfiguration.exists方法代码示例

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


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

示例1: teardown

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
def teardown():
    """
    Teardown for Arakoon package, will be executed when all started tests in this package have ended
    Removal actions of possible things left over after the test-run
    :return: None
    """
    autotest_config = General.get_config()
    backend_name = autotest_config.get('backend', 'name')
    backend = GeneralBackend.get_by_name(backend_name)
    if backend is not None:
        GeneralAlba.remove_alba_backend(backend.alba_backend)

    for storagerouter in GeneralStorageRouter.get_masters():
        root_client = SSHClient(storagerouter, username='root')
        if GeneralService.get_service_status(name='ovs-scheduled-tasks',
                                             client=root_client) is False:
            GeneralService.start_service(name='ovs-scheduled-tasks',
                                         client=root_client)

        for location in TEST_CLEANUP:
            root_client.run('rm -rf {0}'.format(location))

    for key in KEY_CLEANUP:
        if EtcdConfiguration.exists('{0}/{1}'.format(GeneralArakoon.ETCD_CONFIG_ROOT, key), raw = True):
            EtcdConfiguration.delete('{0}/{1}'.format(GeneralArakoon.ETCD_CONFIG_ROOT, key))
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:27,代码来源:__init__.py

示例2: config_files_check_test

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def config_files_check_test():
        """
        Verify some configuration files
        """
        issues_found = ''

        etcd_keys = {
            "/ovs/framework/memcache",
            "/ovs/arakoon/ovsdb/config"
        }

        for key_to_check in etcd_keys:
            if not EtcdConfiguration.exists(key_to_check, raw = True):
                issues_found += "Couldn't find {0}\n".format(key_to_check)

        config_files = {
            "rabbitmq.config": "/etc/rabbitmq/rabbitmq.config",
        }
        grid_ip = General.get_config().get('main', 'grid_ip')
        ssh_pass = General.get_config().get('mgmtcenter', 'password')
        client = SSHClient(grid_ip, username='root', password=ssh_pass)
        for config_file_to_check in config_files.iterkeys():
            if not client.file_exists(config_files[config_file_to_check]):
                issues_found += "Couldn't find {0}\n".format(config_file_to_check)

        assert issues_found == '', "Found the following issues while checking for the config files:{0}\n".format(issues_found)
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:28,代码来源:sanity_checks_test.py

示例3: delete_config

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def delete_config(self):
     """
     Deletes a configuration file
     """
     key = ArakoonClusterConfig.ETCD_CONFIG_KEY.format(self.cluster_id)
     if EtcdConfiguration.exists(key, raw=True):
         EtcdConfiguration.delete(key, raw=True)
开发者ID:DarumasLegs,项目名称:framework,代码行数:9,代码来源:ArakoonInstaller.py

示例4: register

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def register(node_id):
        """
        Adds a Node with a given node_id to the model
        :param node_id: ID of the ALBA node
        :type node_id: str

        :return: None
        """
        node = AlbaNodeList.get_albanode_by_node_id(node_id)
        if node is None:
            main_config = EtcdConfiguration.get('/ovs/alba/asdnodes/{0}/config/main'.format(node_id))
            node = AlbaNode()
            node.ip = main_config['ip']
            node.port = main_config['port']
            node.username = main_config['username']
            node.password = main_config['password']
            node.storagerouter = StorageRouterList.get_by_ip(main_config['ip'])
        data = node.client.get_metadata()
        if data['_success'] is False and data['_error'] == 'Invalid credentials':
            raise RuntimeError('Invalid credentials')
        if data['node_id'] != node_id:
            AlbaNodeController._logger.error('Unexpected node_id: {0} vs {1}'.format(data['node_id'], node_id))
            raise RuntimeError('Unexpected node identifier')
        node.node_id = node_id
        node.type = 'ASD'
        node.save()

        # increase maintenance agents count for all nodes by 1
        for backend in AlbaBackendList.get_albabackends():
            nr_of_agents_key = AlbaNodeController.NR_OF_AGENTS_ETCD_TEMPLATE.format(backend.guid)
            if EtcdConfiguration.exists(nr_of_agents_key):
                EtcdConfiguration.set(nr_of_agents_key, int(EtcdConfiguration.get(nr_of_agents_key) + 1))
            else:
                EtcdConfiguration.set(nr_of_agents_key, 1)
        AlbaNodeController.checkup_maintenance_agents()
开发者ID:DarumasLegs,项目名称:framework-alba-plugin,代码行数:37,代码来源:albanodecontroller.py

示例5: load_metadata

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def load_metadata(self):
        """
        Reads the metadata for an arakoon cluster from reality
        :return: None
        """
        key = ArakoonClusterMetadata.ETCD_METADATA_KEY.format(self.cluster_id)
        if not EtcdConfiguration.exists(key):
            return

        metadata = EtcdConfiguration.get(key)
        if not isinstance(metadata, dict):
            raise ValueError('Metadata should be a dictionary')

        for key in ['in_use', 'internal', 'type']:
            if key not in metadata:
                raise ValueError('Not all required metadata keys are present for arakoon cluster {0}'.format(self.cluster_id))
            value = metadata[key]
            if key == 'in_use':
                if not isinstance(value, bool):
                    raise ValueError('"in_use" should be of type "bool"')
                self.in_use = value
            elif key == 'internal':
                if not isinstance(value, bool):
                    raise ValueError('"internal" should be of type "bool"')
                self.internal = value
            else:
                if value not in ServiceType.ARAKOON_CLUSTER_TYPES:
                    raise ValueError('Unsupported arakoon cluster type {0} found\nPlease choose from {1}'.format(value, ', '.join(ServiceType.ARAKOON_CLUSTER_TYPES)))
                self.cluster_type = value
开发者ID:DarumasLegs,项目名称:framework,代码行数:31,代码来源:ArakoonInstaller.py

示例6: migrate

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def migrate(master_ips=None, extra_ips=None):
        """
        Executes all migrations. It keeps track of an internal "migration version" which is always increasing by one
        :param master_ips: IP addresses of the MASTER nodes
        :param extra_ips: IP addresses of the EXTRA nodes
        """

        data = EtcdConfiguration.get('/ovs/framework/versions') if EtcdConfiguration.exists('/ovs/framework/versions') else {}
        migrators = []
        path = os.path.join(os.path.dirname(__file__), 'migration')
        for filename in os.listdir(path):
            if os.path.isfile(os.path.join(path, filename)) and filename.endswith('.py'):
                name = filename.replace('.py', '')
                module = imp.load_source(name, os.path.join(path, filename))
                for member in inspect.getmembers(module):
                    if inspect.isclass(member[1]) and member[1].__module__ == name and 'object' in [base.__name__ for base in member[1].__bases__]:
                        migrators.append((member[1].identifier, member[1].migrate))

        end_version = 0
        for identifier, method in migrators:
            base_version = data[identifier] if identifier in data else 0
            version = method(base_version, master_ips, extra_ips)
            if version > end_version:
                end_version = version
            data[identifier] = end_version

        EtcdConfiguration.set('/ovs/framework/versions', data)
开发者ID:jeroenmaelbrancke,项目名称:openvstorage,代码行数:29,代码来源:migrator.py

示例7: delete_etcd_config

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def delete_etcd_config(cluster_name):
     """
     Remove the etcd entry for arakoon cluster_name
     :param cluster_name: Name of the arakoon cluster
     :return: None
     """
     etcd_key = GeneralArakoon.ETCD_CONFIG_KEY.format(cluster_name)
     if EtcdConfiguration.exists(etcd_key, raw=True):
         EtcdConfiguration.delete(os.path.dirname(etcd_key))
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:11,代码来源:general_arakoon.py

示例8: _process_disk

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
        def _process_disk(_info, _disks, _node):
            disk = _info.get('disk')
            if disk is None:
                return
            disk_status = 'uninitialized'
            disk_status_detail = ''
            disk_alba_backend_guid = ''
            if disk['available'] is False:
                osd = _info.get('osd')
                disk_alba_state = disk['state']['state']
                if disk_alba_state == 'ok':
                    if osd is None:
                        disk_status = 'initialized'
                    elif osd['id'] is None:
                        alba_id = osd['alba_id']
                        if alba_id is None:
                            disk_status = 'available'
                        else:
                            disk_status = 'unavailable'
                            alba_backend = alba_backend_map.get(alba_id)
                            if alba_backend is not None:
                                disk_alba_backend_guid = alba_backend.guid
                    else:
                        disk_status = 'error'
                        disk_status_detail = 'communicationerror'
                        disk_alba_backend_guid = self.guid

                        for asd in _node.asds:
                            if asd.asd_id == disk['asd_id'] and asd.statistics != {}:
                                disk_status = 'warning'
                                disk_status_detail = 'recenterrors'

                                read = osd['read'] or [0]
                                write = osd['write'] or [0]
                                errors = osd['errors']
                                global_interval_key = '/ovs/alba/backends/global_gui_error_interval'
                                backend_interval_key = '/ovs/alba/backends/{0}/gui_error_interval'.format(self.guid)
                                interval = EtcdConfiguration.get(global_interval_key)
                                if EtcdConfiguration.exists(backend_interval_key):
                                    interval = EtcdConfiguration.get(backend_interval_key)
                                if len(errors) == 0 or (len(read + write) > 0 and max(min(read), min(write)) > max(error[0] for error in errors) + interval):
                                    disk_status = 'claimed'
                                    disk_status_detail = ''
                elif disk_alba_state == 'decommissioned':
                    disk_status = 'unavailable'
                    disk_status_detail = 'decommissioned'
                else:
                    disk_status = 'error'
                    disk_status_detail = disk['state']['detail']
                    alba_backend = alba_backend_map.get(osd.get('alba_id'))
                    if alba_backend is not None:
                        disk_alba_backend_guid = alba_backend.guid
            disk['status'] = disk_status
            disk['status_detail'] = disk_status_detail
            disk['alba_backend_guid'] = disk_alba_backend_guid
            _disks.append(disk)
开发者ID:tbogaert,项目名称:framework-alba-plugin,代码行数:58,代码来源:albabackend.py

示例9: load

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def load(self):
     """
     Loads the configuration from a given file, optionally a remote one
     """
     self.configuration = {}
     if EtcdConfiguration.dir_exists(self.path.format('')):
         self.is_new = False
         for key in self.params[self.config_type]:
             if EtcdConfiguration.exists(self.path.format(key)):
                 self.configuration[key] = json.loads(EtcdConfiguration.get(self.path.format(key), raw=True))
     else:
         self._logger.debug('Could not find config {0}, a new one will be created'.format(self.path.format('')))
     self.dirty_entries = []
开发者ID:DarumasLegs,项目名称:framework,代码行数:15,代码来源:storagedriver.py

示例10: load

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def load(self):
     """
     Loads the configuration from a given file, optionally a remote one
     :param client: If provided, load remote configuration
     """
     contents = '{}'
     if EtcdConfiguration.exists(self.path):
         contents = EtcdConfiguration.get(self.path, raw=True)
         self.is_new = False
     else:
         logger.debug('Could not find config {0}, a new one will be created'.format(self.path))
     self.dirty_entries = []
     self.configuration = json.loads(contents)
开发者ID:loulancn,项目名称:openvstorage,代码行数:15,代码来源:storagedriver.py

示例11: get_config

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def get_config(cluster_name):
        """
        Retrieve the configuration for given cluster
        :param cluster_name: Name of the cluster
        :return: RawConfigParser object
        """
        etcd_key = GeneralArakoon.ETCD_CONFIG_KEY.format(cluster_name)
        if not EtcdConfiguration.exists(etcd_key, raw=True):
            raise ValueError('Unknown arakoon cluster_name {0} provided'.format(cluster_name))

        voldrv_config = EtcdConfiguration.get(etcd_key, raw=True)
        parser = RawConfigParser()
        parser.readfp(StringIO(voldrv_config))
        return parser
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:16,代码来源:general_arakoon.py

示例12: _create_unit

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def _create_unit(fleet_name, template_file):
     from ovs.extensions.db.etcd.configuration import EtcdConfiguration
     start = time.time()
     while time.time() - start < 60:
         try:
             unit = FLEET_CLIENT.create_unit(fleet_name, fleet.Unit(from_string=template_file))
             return unit
         except fleet.APIError as ae:
             if ae.code == 500:
                 FleetCtl._logger.warning('API Error in fleet, most likely caused by etcd, retrying. {0}'.format(ae))
                 key = '/_coreos.com/fleet/job/{0}/object'.format(fleet_name)
                 if EtcdConfiguration.exists(key):
                     EtcdConfiguration.delete(key)
                 time.sleep(1)
             else:
                 raise
     raise RuntimeError('Failed to create ')
开发者ID:DarumasLegs,项目名称:framework,代码行数:19,代码来源:fleetctl.py

示例13: get_path

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
 def get_path(binary_name):
     """
     Retrieve the absolute path for binary
     :param binary_name: Binary to get path for
     :return: Path
     """
     machine_id = System.get_my_machine_id()
     config_location = '/ovs/framework/hosts/{0}/paths|{1}'.format(machine_id, binary_name)
     if not EtcdConfiguration.exists(config_location):
         try:
             path = check_output('which {0}'.format(binary_name), shell=True).strip()
             EtcdConfiguration.set(config_location, path)
         except CalledProcessError:
             return None
     else:
         path = EtcdConfiguration.get(config_location)
     return path
开发者ID:dawnpower,项目名称:framework,代码行数:19,代码来源:ubuntu.py

示例14: get_arakoon_metadata_by_cluster_name

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def get_arakoon_metadata_by_cluster_name(cluster_name):
        """
        Retrieve arakoon cluster information based on its name
        :param cluster_name: Name of the arakoon cluster
        :type cluster_name: str

        :return: Arakoon cluster metadata information
        :rtype: ArakoonClusterMetadata
        """
        if not EtcdConfiguration.exists('/ovs/arakoon', raw=True):
            raise ValueError('Etcd key "/ovs/arakoon" not found')

        for cluster in EtcdConfiguration.list('/ovs/arakoon'):
            if cluster == cluster_name:
                arakoon_metadata = ArakoonClusterMetadata(cluster_id=cluster_name)
                arakoon_metadata.load_metadata()
                return arakoon_metadata
        raise ValueError('No arakoon cluster found with name "{0}"'.format(cluster_name))
开发者ID:DarumasLegs,项目名称:framework,代码行数:20,代码来源:ArakoonInstaller.py

示例15: verify_namespaces

# 需要导入模块: from ovs.extensions.db.etcd.configuration import EtcdConfiguration [as 别名]
# 或者: from ovs.extensions.db.etcd.configuration.EtcdConfiguration import exists [as 别名]
    def verify_namespaces():
        """
        Verify namespaces for all backends
        """
        logger.info('verify namespace task scheduling started')

        job_factor = 10
        job_factor_key = '/ovs/alba/backends/job_factor'
        if EtcdConfiguration.exists(job_factor_key):
            job_factor = EtcdConfiguration.get(job_factor_key)
        else:
            EtcdConfiguration.set(job_factor_key, job_factor)

        for albabackend in AlbaBackendList.get_albabackends():
            config = 'etcd://127.0.0.1:2379/ovs/arakoon/{0}-abm/config'.format(albabackend.backend.name)
            namespaces = AlbaCLI.run('list-namespaces', config=config, as_json=True)
            for namespace in namespaces:
                logger.info('verifying namespace: {0} scheduled ...'.format(namespace['name']))
                AlbaCLI.run('verify-namespace {0} --factor={1}'.format(namespace['name'], job_factor))

        logger.info('verify namespace task scheduling finished')
开发者ID:tbogaert,项目名称:framework-alba-plugin,代码行数:23,代码来源:albascheduledtask.py


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