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


Python Node.should_have_public_with_ip方法代码示例

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


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

示例1: get_default_network_to_endpoint_mapping

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
    def get_default_network_to_endpoint_mapping(cls, node):
        mapping = {
            consts.NETWORKS.fuelweb_admin: 'br-fw-admin',
            consts.NETWORKS.storage: 'br-storage',
            consts.NETWORKS.management: 'br-mgmt',
            consts.NETWORKS.private: 'br-prv'}

        # roles can be assigned to br-ex only in case it has a public IP
        if Node.should_have_public_with_ip(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

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

示例2: update_nodes_net_info

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
 def update_nodes_net_info(cls, cluster, nodes):
     """Adds information about networks to each node."""
     for node in Cluster.get_nodes_not_for_deletion(cluster):
         netw_data = node.network_data
         addresses = {}
         for net in node.cluster.network_groups:
             if net.name == 'public' and \
                     not Node.should_have_public_with_ip(node):
                 continue
             if net.meta.get('render_addr_mask'):
                 addresses.update(cls.get_addr_mask(
                     netw_data,
                     net.name,
                     net.meta.get('render_addr_mask')))
         [n.update(addresses) for n in nodes
             if n['uid'] == str(node.uid)]
     return nodes
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:19,代码来源:base_serializers.py

示例3: get_network_to_endpoint_mapping

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
    def get_network_to_endpoint_mapping(cls, node):
        mapping = {
            consts.NETWORKS.fuelweb_admin: 'br-fw-admin',
            consts.NETWORKS.storage: 'br-storage',
            consts.NETWORKS.management: 'br-mgmt'}

        # roles can be assigned to br-ex only in case it has a public IP
        if Node.should_have_public_with_ip(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

        if node.cluster.network_config.segmentation_type in \
                (consts.NEUTRON_SEGMENT_TYPES.gre,
                 consts.NEUTRON_SEGMENT_TYPES.tun):
            mapping[consts.NETWORKS.private] = 'br-mesh'

        mapping.update(cls.get_node_non_default_bridge_mapping(node))
        return mapping
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:19,代码来源:neutron_serializers.py

示例4: update_nodes_net_info

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
 def update_nodes_net_info(cls, cluster, nodes):
     """Adds information about networks to each node.
     This info is deprecated in 7.0 and should be removed in later version.
     """
     nm = Cluster.get_network_manager(cluster)
     for node in Cluster.get_nodes_not_for_deletion(cluster):
         netw_data = []
         for name, data in six.iteritems(nm.get_node_ips(node)):
             data['name'] = name
             netw_data.append(data)
         addresses = {}
         for net in node.cluster.network_groups:
             if net.name == 'public' and \
                     not Node.should_have_public_with_ip(node):
                 continue
             if net.meta.get('render_addr_mask'):
                 addresses.update(cls.get_addr_mask(
                     netw_data,
                     net.name,
                     net.meta.get('render_addr_mask')))
         [n.update(addresses) for n in nodes
          if n['uid'] == str(node.uid)]
     return nodes
开发者ID:linglong0820,项目名称:fuel-web,代码行数:25,代码来源:neutron_serializers.py

示例5: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
    def generate_network_scheme(cls, node, networks):
        """Create a data structure and fill it with static values.

        :param node: instance of db.sqlalchemy.models.node.Node
        :param networks: list of networks data dicts
        :return: dict of network scheme attributes
        """
        attrs = {
            'version': '1.1',
            'provider': 'lnx',
            'interfaces': {},
            'endpoints': {},
            'roles': cls.get_network_role_mapping_to_interfaces(node),
        }

        is_public = Node.should_have_public(node)
        if is_public:
            attrs['endpoints']['br-ex'] = {'IP': 'none'}
            attrs['endpoints']['br-floating'] = {'IP': 'none'}
            attrs['roles']['ex'] = 'br-ex'
            attrs['roles']['neutron/floating'] = 'br-floating'

        nm = Cluster.get_network_manager(node.cluster)

        # Populate IP and GW information to endpoints.
        netgroup_mapping = (cls.get_network_to_endpoint_mapping(node)
                            .items())
        # get_network_to_endpoint_mapping() adds mapping for 'public' only in
        # case the node 'should_have_public_with_ip'. Here we need to add it
        # because proper transformations should be formed no matter if br-ex
        # has IP or not.
        public_mapping = (consts.NETWORKS.public, 'br-ex')
        if is_public and public_mapping not in netgroup_mapping:
            netgroup_mapping.append(public_mapping)

        if node.cluster.network_config.segmentation_type in \
                (consts.NEUTRON_SEGMENT_TYPES.gre,
                 consts.NEUTRON_SEGMENT_TYPES.tun):
            attrs['endpoints']['br-mesh'] = {}
            attrs['roles']['neutron/mesh'] = 'br-mesh'

        netgroups = {}
        nets_by_ifaces = defaultdict(list)
        for ngname, brname in netgroup_mapping:
            # Here we get a dict with network description for this particular
            # node with its assigned IPs and device names for each network.
            netgroup = nm.get_network_by_netname(ngname, networks)
            if netgroup.get('ip'):
                attrs['endpoints'][brname] = {'IP': [netgroup['ip']]}
            netgroups[ngname] = netgroup
            nets_by_ifaces[netgroup['dev']].append({
                'br_name': brname,
                'vlan_id': netgroup['vlan']
            })

        # Add gateway.
        if Node.should_have_public_with_ip(node):
            attrs['endpoints']['br-ex']['gateway'] = \
                netgroups['public']['gateway']
        else:
            gw = nm.get_default_gateway(node.id)
            attrs['endpoints']['br-fw-admin']['gateway'] = gw

        # Fill up interfaces.
        for iface in node.nic_interfaces:
            if iface.bond:
                attrs['interfaces'][iface.name] = {}
            else:
                attrs['interfaces'][iface.name] = \
                    nm.get_iface_properties(iface)

        # Dance around Neutron segmentation type.
        prv_base_ep = None
        if node.cluster.network_config.segmentation_type == \
                consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs['endpoints']['br-prv'] = {'IP': 'none'}
            attrs['roles']['neutron/private'] = 'br-prv'

            netgroup = nm.get_network_by_netname('private', networks)
            # create br-aux if there is no untagged network (endpoint) on the
            # same interface.
            if netgroup['dev'] in nets_by_ifaces:
                for ep in nets_by_ifaces[netgroup['dev']]:
                    if not ep['vlan_id']:
                        prv_base_ep = ep['br_name']
            if not prv_base_ep:
                nets_by_ifaces[netgroup['dev']].append({
                    'br_name': 'br-aux',
                    'vlan_id': None
                })

        attrs['transformations'] = cls.generate_transformations(
            node, nm, nets_by_ifaces, is_public, prv_base_ep)

        if NodeGroupCollection.get_by_cluster_id(
                node.cluster.id).count() > 1:
            cls.generate_routes(node, attrs, nm, netgroup_mapping, netgroups,
                                networks)

        attrs = cls.generate_driver_information(node, attrs, nm, networks)
#.........这里部分代码省略.........
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:103,代码来源:neutron_serializers.py

示例6: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public_with_ip [as 别名]
    def generate_network_scheme(cls, node, networks):
        """Create a data structure and fill it with static values.

        :param node: instance of db.sqlalchemy.models.node.Node
        :param networks: list of networks data dicts
        :return: dict of network scheme attributes
        """
        attrs = {
            "version": "1.1",
            "provider": "lnx",
            "interfaces": {},
            "endpoints": {},
            "roles": cls.get_network_role_mapping_to_interfaces(node),
        }

        is_public = Node.should_have_public(node)
        if is_public:
            attrs["endpoints"]["br-ex"] = {"IP": "none"}
            attrs["endpoints"]["br-floating"] = {"IP": "none"}
            attrs["roles"]["ex"] = "br-ex"
            attrs["roles"]["neutron/floating"] = "br-floating"

        nm = Cluster.get_network_manager(node.cluster)

        # Populate IP and GW information to endpoints.
        netgroup_mapping = cls.get_network_to_endpoint_mapping(node).items()
        # get_network_to_endpoint_mapping() adds mapping for 'public' only in
        # case the node 'should_have_public_with_ip'. Here we need to add it
        # because proper transformations should be formed no matter if br-ex
        # has IP or not.
        public_mapping = (consts.NETWORKS.public, "br-ex")
        if is_public and public_mapping not in netgroup_mapping:
            netgroup_mapping.append(public_mapping)

        if node.cluster.network_config.segmentation_type in (
            consts.NEUTRON_SEGMENT_TYPES.gre,
            consts.NEUTRON_SEGMENT_TYPES.tun,
        ):
            attrs["endpoints"]["br-mesh"] = {}
            attrs["roles"]["neutron/mesh"] = "br-mesh"

        netgroups = {}
        nets_by_ifaces = defaultdict(list)
        for ngname, brname in netgroup_mapping:
            # Here we get a dict with network description for this particular
            # node with its assigned IPs and device names for each network.
            netgroup = nm.get_network_by_netname(ngname, networks)
            if netgroup.get("ip"):
                attrs["endpoints"][brname] = {"IP": [netgroup["ip"]]}
            netgroups[ngname] = netgroup
            nets_by_ifaces[netgroup["dev"]].append({"br_name": brname, "vlan_id": netgroup["vlan"]})

        # Add gateway.
        if Node.should_have_public_with_ip(node):
            attrs["endpoints"]["br-ex"]["gateway"] = netgroups["public"]["gateway"]
        else:
            gw = nm.get_default_gateway(node.id)
            attrs["endpoints"]["br-fw-admin"]["gateway"] = gw

        # Fill up interfaces.
        for iface in node.nic_interfaces:
            if iface.bond:
                attrs["interfaces"][iface.name] = {}
            else:
                attrs["interfaces"][iface.name] = nm.get_iface_properties(iface)

        # Dance around Neutron segmentation type.
        prv_base_ep = None
        if node.cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs["endpoints"]["br-prv"] = {"IP": "none"}
            attrs["roles"]["neutron/private"] = "br-prv"

            netgroup = nm.get_network_by_netname("private", networks)
            # create br-aux if there is no untagged network (endpoint) on the
            # same interface.
            if netgroup["dev"] in nets_by_ifaces:
                for ep in nets_by_ifaces[netgroup["dev"]]:
                    if not ep["vlan_id"]:
                        prv_base_ep = ep["br_name"]
            if not prv_base_ep:
                nets_by_ifaces[netgroup["dev"]].append({"br_name": "br-aux", "vlan_id": None})

        attrs["transformations"] = cls.generate_transformations(node, nm, nets_by_ifaces, is_public, prv_base_ep)

        if NodeGroupCollection.get_by_cluster_id(node.cluster.id).count() > 1:
            cls.generate_routes(node, attrs, nm, netgroup_mapping, netgroups, networks)

        attrs = cls.generate_driver_information(node, attrs, nm, networks)

        if node.cluster.network_config.segmentation_type in (
            consts.NEUTRON_SEGMENT_TYPES.gre,
            consts.NEUTRON_SEGMENT_TYPES.tun,
        ):
            attrs["roles"].pop("neutron/private", None)

        if node.cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs["roles"].pop("neutron/mesh", None)

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


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