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


Python StorageRouterList.get_primary_storagerouters_for_domain方法代码示例

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


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

示例1: _dtl_status

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_primary_storagerouters_for_domain [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

示例2: get_mds_storagedriver_config_set

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_primary_storagerouters_for_domain [as 别名]
    def get_mds_storagedriver_config_set(vpool, check_online=False):
        """
        Builds a configuration for all StorageRouters from a given VPool with following goals:
        * Primary MDS is the local one
        * All slaves are on different hosts
        * Maximum `mds_safety` nodes are returned
        The configuration returned is the default configuration used by the volumedriver of which in normal use-cases
        only the 1st entry is used, because at volume creation time, the volumedriver needs to create 1 master MDS
        During ensure_safety, we actually create/set the MDS slaves for each volume

        :param vpool: vPool to get storagedriver configuration for
        :type vpool: VPool

        :param check_online: Check whether the storage routers are actually responsive
        :type check_online: bool

        :return: MDS configuration for a vPool
        :rtype: dict
        """
        mds_per_storagerouter = {}
        mds_per_load = {}
        for storagedriver in vpool.storagedrivers:
            storagerouter = storagedriver.storagerouter
            if check_online is True:
                try:
                    SSHClient(storagerouter)
                except UnableToConnectException:
                    continue
            mds_service, load = MDSServiceController.get_preferred_mds(storagerouter, vpool)
            if mds_service is None:
                raise RuntimeError('Could not find an MDS service')
            mds_per_storagerouter[storagerouter] = {'host': storagerouter.ip, 'port': mds_service.service.ports[0]}
            if load not in mds_per_load:
                mds_per_load[load] = []
            mds_per_load[load].append(storagerouter)

        safety = Configuration.get('/ovs/framework/storagedriver|mds_safety')
        config_set = {}
        for storagerouter, ip_info in mds_per_storagerouter.iteritems():
            config_set[storagerouter.guid] = [ip_info]
            for importance in ['primary', 'secondary']:
                domains = [junction.domain for junction in storagerouter.domains if junction.backup is (importance == 'secondary')]
                possible_storagerouters = set()
                for domain in domains:
                    possible_storagerouters.update(StorageRouterList.get_primary_storagerouters_for_domain(domain))

                for load in sorted(mds_per_load):
                    if len(config_set[storagerouter.guid]) >= safety:
                        break
                    other_storagerouters = mds_per_load[load]
                    random.shuffle(other_storagerouters)
                    for other_storagerouter in other_storagerouters:
                        if len(config_set[storagerouter.guid]) >= safety:
                            break
                        if other_storagerouter != storagerouter and other_storagerouter in possible_storagerouters:
                            config_set[storagerouter.guid].append(mds_per_storagerouter[other_storagerouter])
        return config_set
开发者ID:openvstorage,项目名称:framework,代码行数:59,代码来源:mdsservice.py

示例3: ensure_safety

# 需要导入模块: from ovs.dal.lists.storagerouterlist import StorageRouterList [as 别名]
# 或者: from ovs.dal.lists.storagerouterlist.StorageRouterList import get_primary_storagerouters_for_domain [as 别名]
    def ensure_safety(vdisk, excluded_storagerouters=None):
        """
        Ensures (or tries to ensure) the safety of a given vdisk (except hypervisor).
        Assumptions:
        * A local overloaded master is better than a non-local non-overloaded master
        * Prefer master/services to be on different hosts, a subsequent slave on the same node doesn't add safety
        * Don't actively overload services (e.g. configure an MDS as slave causing it to get overloaded)
        * Too much safety is not wanted (it adds loads to nodes while not required)
        :param vdisk: vDisk to calculate a new safety for
        :type vdisk: VDisk

        :param excluded_storagerouters: Storagerouters to leave out of calculation (Eg: When 1 is down or unavailable)
        :type excluded_storagerouters: list

        :return: None
        """

        def _add_suitable_nodes(_importance, _safety):
            if len(nodes) < _safety:
                for local_load in sorted(all_info_dict[_importance]["loads"]):
                    for local_service in all_info_dict[_importance]["loads"][local_load]:
                        if len(nodes) < _safety and local_service.storagerouter.ip not in nodes:
                            try:
                                SSHClient(local_service.storagerouter)
                                new_services.append(local_service)
                                nodes.add(local_service.storagerouter.ip)
                            except UnableToConnectException:
                                MDSServiceController._logger.debug(
                                    "MDS safety: vDisk {0}: Skipping storagerouter with IP {1} as it is unreachable".format(
                                        vdisk.guid, service.storagerouter.ip
                                    )
                                )
            return nodes, new_services

        MDSServiceController._logger.debug(
            "MDS safety: vDisk {0}: Start checkup for virtual disk {1}".format(vdisk.guid, vdisk.name)
        )
        tlogs = Configuration.get("/ovs/framework/storagedriver|mds_tlogs")
        safety = Configuration.get("/ovs/framework/storagedriver|mds_safety")
        max_load = Configuration.get("/ovs/framework/storagedriver|mds_maxload")

        ######################
        # GATHER INFORMATION #
        ######################
        vdisk.reload_client("storagedriver")
        vdisk.reload_client("objectregistry")

        vdisk.invalidate_dynamics(["storagedriver_id", "storagerouter_guid"])
        if vdisk.storagerouter_guid is None:
            raise SRCObjectNotFoundException(
                "Cannot ensure MDS safety for vDisk {0} with guid {1} because vDisk is not attached to any Storage Router".format(
                    vdisk.name, vdisk.guid
                )
            )

        if excluded_storagerouters is None:
            excluded_storagerouters = []

        # Sorted was added merely for unittests, because they rely on specific order of services and their ports
        # Default sorting behavior for relations used to be based on order in which relations were added
        # Now sorting is based on guid (DAL speedup changes)
        nodes = set()
        services = sorted(
            [
                mds_service.service
                for mds_service in vdisk.vpool.mds_services
                if mds_service.service.storagerouter not in excluded_storagerouters
            ],
            key=lambda k: k.ports,
        )
        service_per_key = {}
        for service in services:
            nodes.add(service.storagerouter.ip)
            service_per_key["{0}:{1}".format(service.storagerouter.ip, service.ports[0])] = service

        # Create a pool of StorageRouters being a part of the primary and secondary domains of this Storage Router
        vdisk_storagerouter = StorageRouter(vdisk.storagerouter_guid)
        primary_domains = [junction.domain for junction in vdisk_storagerouter.domains if junction.backup is False]
        secondary_domains = [junction.domain for junction in vdisk_storagerouter.domains if junction.backup is True]
        primary_storagerouters = set()
        secondary_storagerouters = set()
        for domain in primary_domains:
            primary_storagerouters.update(StorageRouterList.get_primary_storagerouters_for_domain(domain))
        for domain in secondary_domains:
            secondary_storagerouters.update(StorageRouterList.get_primary_storagerouters_for_domain(domain))

        # In case no domains have been configured
        if len(primary_storagerouters) == 0:
            primary_storagerouters = set(StorageRouterList.get_storagerouters())

        if vdisk_storagerouter not in primary_storagerouters or vdisk_storagerouter in secondary_storagerouters:
            raise ValueError(
                "StorageRouter {0} for vDisk {1} should be part of the primary domains and NOT be part of the secondary domains".format(
                    vdisk_storagerouter.name, vdisk.name
                )
            )

        # Remove all storagerouters from secondary which are present in primary
        secondary_storagerouters = secondary_storagerouters.difference(primary_storagerouters)

#.........这里部分代码省略.........
开发者ID:grimpy,项目名称:openvstorage,代码行数:103,代码来源:mdsservice.py


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