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


Python StorageRouterList.get_storagerouters方法代码示例

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


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

示例1: _configure_arakoon_to_volumedriver

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def _configure_arakoon_to_volumedriver():
     print "Update existing vPools"
     logger.info("Update existing vPools")
     for storagerouter in StorageRouterList.get_storagerouters():
         config = ArakoonClusterConfig("voldrv")
         config.load_config()
         arakoon_nodes = []
         for node in config.nodes:
             arakoon_nodes.append({"host": node.ip, "port": node.client_port, "node_id": node.name})
         with Remote(
             storagerouter.ip, [os, RawConfigParser, EtcdConfiguration, StorageDriverConfiguration], "ovs"
         ) as remote:
             configuration_dir = "{0}/storagedriver/storagedriver".format(
                 EtcdConfiguration.get("/ovs/framework/paths|cfgdir")
             )
             if not remote.os.path.exists(configuration_dir):
                 remote.os.makedirs(configuration_dir)
             for json_file in remote.os.listdir(configuration_dir):
                 vpool_name = json_file.replace(".json", "")
                 if json_file.endswith(".json"):
                     if remote.os.path.exists("{0}/{1}.cfg".format(configuration_dir, vpool_name)):
                         continue  # There's also a .cfg file, so this is an alba_proxy configuration file
                     storagedriver_config = remote.StorageDriverConfiguration("storagedriver", vpool_name)
                     storagedriver_config.load()
                     storagedriver_config.configure_volume_registry(
                         vregistry_arakoon_cluster_id="voldrv", vregistry_arakoon_cluster_nodes=arakoon_nodes
                     )
                     storagedriver_config.configure_distributed_lock_store(
                         dls_type="Arakoon", dls_arakoon_cluster_id="voldrv", dls_arakoon_cluster_nodes=arakoon_nodes
                     )
                     storagedriver_config.save(reload_config=True)
开发者ID:jamie-liu,项目名称:openvstorage,代码行数:33,代码来源:storagedriver.py

示例2: print_current_mds_layout

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def print_current_mds_layout():
     """
     Prints the current MDS layout
     """
     output = ['',
               'Open vStorage - MDS debug information',
               '=====================================',
               'timestamp: {0}'.format(time.time()),
               '']
     for storagerouter in StorageRouterList.get_storagerouters():
         output.append('+ {0} ({1})'.format(storagerouter.name, storagerouter.ip))
         vpools = set(sd.vpool for sd in storagerouter.storagedrivers)
         for vpool in vpools:
             output.append('  + {0}'.format(vpool.name))
             for mds_service in vpool.mds_services:
                 if mds_service.service.storagerouter_guid == storagerouter.guid:
                     masters, slaves = 0, 0
                     for junction in mds_service.vdisks:
                         if junction.is_master:
                             masters += 1
                         else:
                             slaves += 1
                     capacity = mds_service.capacity
                     if capacity == -1:
                         capacity = 'infinite'
                     load, _ = MDSServiceController.get_mds_load(mds_service)
                     if load == float('inf'):
                         load = 'infinite'
                     else:
                         load = '{0}%'.format(round(load, 2))
                     output.append('    + {0} - port {1} - {2} master(s), {3} slave(s) - capacity: {4}, load: {5}'.format(
                         mds_service.number, mds_service.service.ports[0], masters, slaves, capacity, load
                     ))
     print '\n'.join(output)
开发者ID:openvstorage,项目名称:framework,代码行数:36,代码来源:mdsservice.py

示例3: _dtl_status

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
    def _dtl_status(self):
        """
        Retrieve the DTL status for a vDisk
        """
        sd_status = self.info.get('failover_mode', 'UNKNOWN').lower()
        if sd_status == '':
            sd_status = 'unknown'
        if sd_status != 'ok_standalone':
            return sd_status

        # Verify whether 'ok_standalone' is the correct status for this vDisk
        vpool_dtl = self.vpool.configuration['dtl_enabled']
        if self.has_manual_dtl is True or vpool_dtl is False:
            return sd_status

        domains = []
        possible_dtl_targets = set()
        for sr in StorageRouterList.get_storagerouters():
            if sr.guid == self.storagerouter_guid:
                domains = [junction.domain for junction in sr.domains]
            elif len(sr.storagedrivers) > 0:
                possible_dtl_targets.add(sr)

        if len(domains) > 0:
            possible_dtl_targets = set()
            for domain in domains:
                possible_dtl_targets.update(StorageRouterList.get_primary_storagerouters_for_domain(domain))

        if len(possible_dtl_targets) == 0:
            return sd_status
        return 'checkup_required'
开发者ID:openvstorage,项目名称:framework,代码行数:33,代码来源:vdisk.py

示例4: pulse

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
    def pulse():
        """
        Update the heartbeats for the Current Routers
        :return: None
        """
        logger = LogHandler.get('extensions', name='heartbeat')
        machine_id = System.get_my_machine_id()
        current_time = int(time.time())

        routers = StorageRouterList.get_storagerouters()
        for node in routers:
            if node.machine_id == machine_id:
                with volatile_mutex('storagerouter_heartbeat_{0}'.format(node.guid)):
                    node_save = StorageRouter(node.guid)
                    node_save.heartbeats['process'] = current_time
                    node_save.save()
                StorageRouterController.ping.s(node.guid, current_time).apply_async(routing_key='sr.{0}'.format(machine_id))
            else:
                try:
                    # check timeout of other nodes and clear arp cache
                    if node.heartbeats and 'process' in node.heartbeats:
                        if current_time - node.heartbeats['process'] >= HeartBeat.ARP_TIMEOUT:
                            check_output("/usr/sbin/arp -d '{0}'".format(node.name.replace(r"'", r"'\''")), shell=True)
                except CalledProcessError:
                    logger.exception('Error clearing ARP cache')
开发者ID:grimpy,项目名称:openvstorage,代码行数:27,代码来源:heartbeat.py

示例5: _configure_arakoon_to_volumedriver

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def _configure_arakoon_to_volumedriver():
     print 'Update existing vPools'
     logger.info('Update existing vPools')
     for storagerouter in StorageRouterList.get_storagerouters():
         with Remote(storagerouter.ip, [os, RawConfigParser, Configuration, StorageDriverConfiguration, ArakoonManagementEx], 'ovs') as remote:
             arakoon_cluster_config = remote.ArakoonManagementEx().getCluster('voldrv').getClientConfig()
             arakoon_nodes = []
             for node_id, node_config in arakoon_cluster_config.iteritems():
                 arakoon_nodes.append({'host': node_config[0][0],
                                       'port': node_config[1],
                                       'node_id': node_id})
             configuration_dir = '{0}/storagedriver/storagedriver'.format(
                 remote.Configuration.get('ovs.core.cfgdir'))
             if not remote.os.path.exists(configuration_dir):
                 remote.os.makedirs(configuration_dir)
             for json_file in remote.os.listdir(configuration_dir):
                 vpool_name = json_file.replace('.json', '')
                 if json_file.endswith('.json'):
                     if remote.os.path.exists('{0}/{1}.cfg'.format(configuration_dir, vpool_name)):
                         continue  # There's also a .cfg file, so this is an alba_proxy configuration file
                     storagedriver_config = remote.StorageDriverConfiguration('storagedriver', vpool_name)
                     storagedriver_config.load()
                     storagedriver_config.configure_volume_registry(vregistry_arakoon_cluster_id='voldrv',
                                                                    vregistry_arakoon_cluster_nodes=arakoon_nodes)
                     storagedriver_config.configure_distributed_lock_store(dls_type='Arakoon',
                                                                           dls_arakoon_cluster_id='voldrv',
                                                                           dls_arakoon_cluster_nodes=arakoon_nodes)
                     storagedriver_config.save()
开发者ID:JasperLue,项目名称:openvstorage,代码行数:30,代码来源:storagedriver.py

示例6: _configure_arakoon_to_volumedriver

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def _configure_arakoon_to_volumedriver(offline_node_ips=None):
     print 'Update existing vPools'
     logger.info('Update existing vPools')
     if offline_node_ips is None:
         offline_node_ips = []
     for storagerouter in StorageRouterList.get_storagerouters():
         config = ArakoonClusterConfig('voldrv')
         config.load_config()
         arakoon_nodes = []
         for node in config.nodes:
             arakoon_nodes.append({'host': node.ip,
                                   'port': node.client_port,
                                   'node_id': node.name})
         with Remote(storagerouter.ip, [os, RawConfigParser, EtcdConfiguration, StorageDriverConfiguration], 'ovs') as remote:
             configuration_dir = '{0}/storagedriver/storagedriver'.format(EtcdConfiguration.get('/ovs/framework/paths|cfgdir'))
             if not remote.os.path.exists(configuration_dir):
                 remote.os.makedirs(configuration_dir)
             for json_file in remote.os.listdir(configuration_dir):
                 vpool_name = json_file.replace('.json', '')
                 if json_file.endswith('.json'):
                     if remote.os.path.exists('{0}/{1}.cfg'.format(configuration_dir, vpool_name)):
                         continue  # There's also a .cfg file, so this is an alba_proxy configuration file
                     storagedriver_config = remote.StorageDriverConfiguration('storagedriver', vpool_name)
                     storagedriver_config.load()
                     storagedriver_config.configure_volume_registry(vregistry_arakoon_cluster_id='voldrv',
                                                                    vregistry_arakoon_cluster_nodes=arakoon_nodes)
                     storagedriver_config.configure_distributed_lock_store(dls_type='Arakoon',
                                                                           dls_arakoon_cluster_id='voldrv',
                                                                           dls_arakoon_cluster_nodes=arakoon_nodes)
                     storagedriver_config.save(reload_config=True)
开发者ID:jeroenmaelbrancke,项目名称:openvstorage,代码行数:32,代码来源:storagedriver.py

示例7: _run_and_validate_dtl_checkup

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
    def _run_and_validate_dtl_checkup(self, vdisk, validations):
        """
        Execute the DTL checkup for a vDisk and validate the settings afterwards
        """
        single_node = len(StorageRouterList.get_storagerouters()) == 1
        VDiskController.dtl_checkup(vdisk_guid=vdisk.guid)
        config = vdisk.storagedriver_client.get_dtl_config(vdisk.volume_id)
        config_mode = vdisk.storagedriver_client.get_dtl_config_mode(vdisk.volume_id)
        msg = '{0} node - {{0}} - Actual: {{1}} - Expected: {{2}}'.format('Single' if single_node is True else 'Multi')

        validations.append({'key': 'config_mode', 'value': DTLConfigMode.MANUAL})
        for validation in validations:
            key = validation['key']
            value = validation['value']
            if key == 'config':
                actual_value = config
            elif key == 'host':
                actual_value = config.host
            elif key == 'port':
                actual_value = config.port
            elif key == 'mode':
                actual_value = config.mode
            else:
                actual_value = config_mode

            if isinstance(value, list):
                self.assertTrue(expr=actual_value in value,
                                msg=msg.format(key.capitalize(), actual_value, ', '.join(value)))
            else:
                self.assertEqual(first=actual_value,
                                 second=value,
                                 msg=msg.format(key.capitalize(), actual_value, value))
        return config
开发者ID:grimpy,项目名称:openvstorage,代码行数:35,代码来源:test_dtl_checkup.py

示例8: on_demote

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def on_demote(cluster_ip, master_ip):
     """
     Handles the demote for the StorageDrivers
     :param cluster_ip: IP of the node to demote
     :param master_ip: IP of the master node
     """
     client = SSHClient(cluster_ip, username='root')
     servicetype = ServiceTypeList.get_by_name('Arakoon')
     current_service = None
     remaining_ips = []
     for service in servicetype.services:
         if service.name == 'arakoon-voldrv':
             if service.storagerouter.ip == cluster_ip:
                 current_service = service
             else:
                 remaining_ips.append(service.storagerouter.ip)
     if current_service is not None:
         print '* Shrink StorageDriver cluster'
         ArakoonInstaller.shrink_cluster(master_ip, cluster_ip, 'voldrv')
         if ServiceManager.has_service(current_service.name, client=client) is True:
             ServiceManager.stop_service(current_service.name, client=client)
             ServiceManager.remove_service(current_service.name, client=client)
         ArakoonInstaller.restart_cluster_remove('voldrv', remaining_ips)
         current_service.delete()
         for storagerouter in StorageRouterList.get_storagerouters():
             ArakoonInstaller.deploy_to_slave(master_ip, storagerouter.ip, 'voldrv')
         StorageDriverController._configure_arakoon_to_volumedriver()
开发者ID:JasperLue,项目名称:openvstorage,代码行数:29,代码来源:storagedriver.py

示例9: remove

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def remove(license_guid):
     """
     Removes a license
     """
     clients = {}
     storagerouters = StorageRouterList.get_storagerouters()
     try:
         for storagerouter in storagerouters:
             clients[storagerouter] = SSHClient(storagerouter.ip)
     except UnableToConnectException:
         raise RuntimeError('Not all StorageRouters are reachable')
     lic = License(license_guid)
     if lic.can_remove is True:
         remove_functions = Toolbox.fetch_hooks('license', '{0}.remove'.format(lic.component))
         result = remove_functions[0](component=lic.component, data=lic.data, valid_until=lic.valid_until, signature=lic.signature)
         if result is True:
             lic.delete()
             license_contents = []
             for lic in LicenseList.get_licenses():
                 license_contents.append(lic.hash)
             for storagerouter in storagerouters:
                 client = clients[storagerouter]
                 client.file_write('/opt/OpenvStorage/config/licenses', '{0}\n'.format('\n'.join(license_contents)))
         return result
     return None
开发者ID:DarumasLegs,项目名称:framework,代码行数:27,代码来源:license.py

示例10: pulse

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
    def pulse():
        """
        Update the heartbeats for all Storage Routers
        :return: None
        """
        logger = LogHandler.get('extensions', name='heartbeat')

        current_time = int(time.time())
        machine_id = System.get_my_machine_id()
        amqp = '{0}://{1}:{2}@{3}//'.format(EtcdConfiguration.get('/ovs/framework/messagequeue|protocol'),
                                            EtcdConfiguration.get('/ovs/framework/messagequeue|user'),
                                            EtcdConfiguration.get('/ovs/framework/messagequeue|password'),
                                            EtcdConfiguration.get('/ovs/framework/hosts/{0}/ip'.format(machine_id)))

        celery_path = OSManager.get_path('celery')
        worker_states = check_output("{0} inspect ping -b {1} --timeout=5 2> /dev/null | grep OK | perl -pe 's/\x1b\[[0-9;]*m//g' || true".format(celery_path, amqp), shell=True)
        routers = StorageRouterList.get_storagerouters()
        for node in routers:
            if node.heartbeats is None:
                node.heartbeats = {}
            if '[email protected]{0}: OK'.format(node.name) in worker_states:
                node.heartbeats['celery'] = current_time
            if node.machine_id == machine_id:
                node.heartbeats['process'] = current_time
            else:
                try:
                    # check timeout of other nodes and clear arp cache
                    if node.heartbeats and 'process' in node.heartbeats:
                        if current_time - node.heartbeats['process'] >= HeartBeat.ARP_TIMEOUT:
                            check_output("/usr/sbin/arp -d {0}".format(node.name), shell=True)
                except CalledProcessError:
                    logger.exception('Error clearing ARP cache')
            node.save()
开发者ID:DarumasLegs,项目名称:framework,代码行数:35,代码来源:heartbeat.py

示例11: get_available_actions

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def get_available_actions(self):
     """
     Gets a list of all available actions
     """
     actions = []
     storagerouters = StorageRouterList.get_storagerouters()
     if len(storagerouters) > 1:
         actions.append('MOVE_AWAY')
     return Response(actions, status=status.HTTP_200_OK)
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:11,代码来源:storagerouters.py

示例12: get_available_actions

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def get_available_actions(self):
     """
     Gets a list of all available actions
     """
     actions = []
     storagerouters = StorageRouterList.get_storagerouters()
     if len(storagerouters) > 1:
         actions.append('MOVE_AWAY')
     return actions
开发者ID:DarumasLegs,项目名称:framework,代码行数:11,代码来源:storagerouters.py

示例13: list

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def list(self, query=None):
     """
     Overview of all Storage Routers
     """
     if query is None:
         return StorageRouterList.get_storagerouters()
     else:
         query = json.loads(query)
         return DataList(StorageRouter, query)
开发者ID:DarumasLegs,项目名称:framework,代码行数:11,代码来源:storagerouters.py

示例14: list

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def list(self, query=None):
     """
     Overview of all Storage Routers
     :param query: A query to filter the StorageRouters
     :type query: DataQuery
     """
     if query is None:
         return StorageRouterList.get_storagerouters()
     else:
         return DataList(StorageRouter, query)
开发者ID:grimpy,项目名称:openvstorage,代码行数:12,代码来源:storagerouters.py

示例15: list

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_storagerouters [as 别名]
 def list(self, query=None):
     """
     Overview of all Storage Routers
     """
     if query is None:
         return StorageRouterList.get_storagerouters()
     else:
         query = json.loads(query)
         query_result = DataList({"object": StorageRouter, "data": DataList.select.GUIDS, "query": query}).data
         return DataObjectList(query_result, StorageRouter)
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:12,代码来源:storagerouters.py


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