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


Python Cluster.get_network_roles方法代码示例

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


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

示例1: _get_network_role_mapping

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_roles [as 别名]
    def _get_network_role_mapping(cls, node, mapping):
        """Aggregates common logic for methods 'get_network_role_mapping_to_ip'
        and 'get_network_role_mapping_to_interfaces'.
        """
        roles = dict()
        for role in Cluster.get_network_roles(node.cluster):
            default_mapping = mapping.get(role['default_mapping'])
            if default_mapping:
                roles[role['id']] = default_mapping

        return roles
开发者ID:anbangr,项目名称:fuel-web,代码行数:13,代码来源:neutron_serializers.py

示例2: _get_network_role_mapping

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_roles [as 别名]
    def _get_network_role_mapping(cls, node, mapping):
        """Aggregates common logic for mapping retrieval methods

        these methods are:
        - 'get_network_role_mapping_to_ip'
        - 'get_network_role_mapping_to_interfaces'.
        """
        roles = dict()
        for role in Cluster.get_network_roles(node.cluster):
            default_mapping = mapping.get(role["default_mapping"])
            if default_mapping:
                roles[role["id"]] = default_mapping

        return roles
开发者ID:ymkins,项目名称:fuel-web,代码行数:16,代码来源:neutron_serializers.py

示例3: get_vips_by_cluster_id

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_roles [as 别名]
    def get_vips_by_cluster_id(cls, cluster_id,
                               network_id=None, network_role=None):
        """Get VIP filtered by cluster ID.

        VIP is determined by not NULL vip_name field of IPAddr model.

        :param cluster_id: cluster identifier or None to get all records
        :type cluster_id: int|None
        :param network_id: network identifier
        :type network_id: int
        :param network_role: network role
        :type network_role: str
        :return: vips query
        :rtype: SQLAlchemy Query
        """
        query = cls.get_by_cluster_id(cluster_id)\
            .filter(models.IPAddr.vip_name.isnot(None))

        if network_id:
            query = query.filter(models.IPAddr.network == network_id)

        if network_role:
            # Get all network_roles for cluster and gain vip names from it,
            # then bound query to this names.
            # See network_roles.yaml in plugin examples for the details of
            # input structure.
            cluster_obj = Cluster.get_by_uid(cluster_id)
            vips = []

            for cluster_network_role in Cluster.get_network_roles(cluster_obj):
                if cluster_network_role.get('id') == network_role:
                    vips.extend(
                        cluster_network_role
                        .get('properties', {})
                        .get('vip', [])
                    )

            vip_names = (vip['name'] for vip in vips)
            unique_vip_names = list(set(vip_names))
            query = query.filter(models.IPAddr.vip_name.in_(unique_vip_names))

        return query
开发者ID:ekorekin,项目名称:fuel-web,代码行数:44,代码来源:ip_addr.py


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