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


Python Node.should_have_public方法代码示例

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


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

示例1: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [as 别名]
    def generate_network_scheme(cls, node, networks):
        attrs = super(NeutronNetworkDeploymentSerializer60, cls).generate_network_scheme(node, networks)

        for item in attrs.get("transformations", ()):
            if "tags" in item:
                item["vlan_ids"] = item["tags"]

        # Include information about all subnets that don't belong to this node.
        # This is used during deployment to configure routes to all other
        # networks in the environment.
        nm = Cluster.get_network_manager(node.cluster)
        other_nets = nm.get_networks_not_on_node(node, networks)

        netgroup_mapping = [("storage", "br-storage"), ("management", "br-mgmt"), ("fuelweb_admin", "br-fw-admin")]
        if Node.should_have_public(node):
            netgroup_mapping.append(("public", "br-ex"))

        for ngname, brname in netgroup_mapping:
            netgroup = nm.get_network_by_netname(ngname, networks)
            if netgroup.get("gateway"):
                attrs["endpoints"][brname]["gateway"] = netgroup["gateway"]
            attrs["endpoints"][brname]["other_nets"] = other_nets.get(ngname, [])

        if Node.should_have_public(node):
            attrs["endpoints"]["br-ex"]["default_gateway"] = True
        else:
            gw = nm.get_default_gateway(node.id)
            attrs["endpoints"]["br-fw-admin"]["gateway"] = gw
            attrs["endpoints"]["br-fw-admin"]["default_gateway"] = True

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

示例2: get_default_network_to_endpoint_mapping

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [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'}

        if Node.should_have_public(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

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

示例3: update_nodes_net_info

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [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(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:nebril,项目名称:fuel-web,代码行数:14,代码来源:base_serializers.py

示例4: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [as 别名]
    def generate_network_scheme(cls, node):
        attrs = super(NeutronNetworkDeploymentSerializer60, cls). \
            generate_network_scheme(node)

        for item in attrs.get('transformations', ()):
            if 'tags' in item:
                item['vlan_ids'] = item['tags']

        # Include information about all subnets that don't belong to this node.
        # This is used during deployment to configure routes to all other
        # networks in the environment.
        nm = Cluster.get_network_manager(node.cluster)
        other_nets = nm.get_networks_not_on_node(node)

        netgroup_mapping = [
            ('storage', 'br-storage'),
            ('management', 'br-mgmt'),
            ('fuelweb_admin', 'br-fw-admin'),
        ]
        if Node.should_have_public(node):
            netgroup_mapping.append(('public', 'br-ex'))

        for ngname, brname in netgroup_mapping:
            netgroup = nm.get_node_network_by_netname(node, ngname)
            if netgroup.get('gateway'):
                attrs['endpoints'][brname]['gateway'] = netgroup['gateway']
            attrs['endpoints'][brname]['other_nets'] = \
                other_nets.get(ngname, [])

        if Node.should_have_public(node):
            attrs['endpoints']['br-ex']['default_gateway'] = True
        else:
            gw = nm.get_default_gateway(node.id)
            attrs['endpoints']['br-fw-admin']['gateway'] = gw
            attrs['endpoints']['br-fw-admin']['default_gateway'] = True

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

示例5: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [as 别名]
    def generate_network_scheme(cls, node):
        attrs = super(NeutronNetworkDeploymentSerializer70,
                      cls).generate_network_scheme(node)

        attrs['roles']['neutron/api'] = 'br-mgmt'
        attrs['roles']['neutron/mesh'] = 'br-mgmt'
        attrs['roles']['neutron/private'] = 'br-prv'

        attrs['roles']['mgmt/corosync'] = 'br-mgmt'
        attrs['roles']['mgmt/database'] = 'br-mgmt'
        attrs['roles']['mgmt/messaging'] = 'br-mgmt'
        attrs['roles']['mgmt/api'] = 'br-mgmt'
        attrs['roles']['mgmt/vip'] = 'br-mgmt'

        attrs['roles']['nova/api'] = 'br-mgmt'
        attrs['roles']['murano/api'] = 'br-mgmt'
        attrs['roles']['sahara/api'] = 'br-mgmt'
        attrs['roles']['ceilometer/api'] = 'br-mgmt'
        attrs['roles']['heat/api'] = 'br-mgmt'
        attrs['roles']['keystone/api'] = 'br-mgmt'
        attrs['roles']['horizon'] = 'br-mgmt'
        attrs['roles']['glance/api'] = 'br-mgmt'

        if Node.should_have_public(node):
            attrs['roles']['neutron/floating'] = 'br-floating'
            attrs['roles']['public/vip'] = 'br-ex'
            attrs['roles']['ceph/radosgw'] = 'br-ex'
            attrs['roles']['swift/public'] = 'br-ex'

        attrs['roles']['admin/pxe'] = 'br-fw-admin'

        attrs['roles']['ceph/replication'] = 'br-storage'
        attrs['roles']['ceph/public'] = 'br-mgmt'

        attrs['roles']['swift/replication'] = 'br-storage'
        attrs['roles']['swift/api'] = 'br-mgmt'

        attrs['roles']['cinder/iscsi'] = 'br-storage'
        attrs['roles']['cinder/api'] = 'br-mgmt'

        attrs['roles']['mongo/db'] = 'br-mgmt'

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

示例6: _update_public_network

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [as 别名]
    def _update_public_network(cls, cluster, public_map, roles_metadata):
        """Applies changes to node's public_network checked using public_map.

        :param instance: Cluster object
        :param public_map: dict of Node.id to should_have_public result.
        :param roles_metadata: dict from objects.Cluster.get_roles
        """

        if cluster.network_config.configuration_template is not None:
            return
        from nailgun.objects import Node
        for node in cluster.nodes:
            should_have_public = Node.should_have_public(
                node, roles_metadata)
            if public_map.get(node.id) == should_have_public:
                continue
            if should_have_public:
                cls.assign_public_network(node)
            else:
                cls.unassign_public_network(node)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:22,代码来源:network_group.py

示例7: generate_network_scheme

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [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

示例8: generate_network_metadata

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import should_have_public [as 别名]
    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for n in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.make_slave_name(n)
            node_roles = Node.all_roles(n)

            ip_by_net = {
                'fuelweb_admin': None,
                'storage': None,
                'management': None,
                'public': None
            }
            for net in ip_by_net:
                netgroup = nm.get_node_network_by_netname(n, net)
                if netgroup.get('ip'):
                    ip_by_net[net] = netgroup['ip'].split('/')[0]

            netw_roles = {
                'admin/pxe': ip_by_net['fuelweb_admin'],
                'fw-admin': ip_by_net['fuelweb_admin'],

                'keystone/api': ip_by_net['management'],
                'neutron/api': ip_by_net['management'],
                'swift/api': ip_by_net['management'],
                'sahara/api': ip_by_net['management'],
                'ceilometer/api': ip_by_net['management'],
                'cinder/api': ip_by_net['management'],
                'glance/api': ip_by_net['management'],
                'heat/api': ip_by_net['management'],
                'nova/api': ip_by_net['management'],
                'murano/api': ip_by_net['management'],
                'horizon': ip_by_net['management'],

                'management': ip_by_net['management'],
                'mgmt/api': ip_by_net['management'],
                'mgmt/database': ip_by_net['management'],
                'mgmt/messaging': ip_by_net['management'],
                'mgmt/corosync': ip_by_net['management'],
                'mgmt/memcache': ip_by_net['management'],
                'mgmt/vip': ip_by_net['management'],

                'mongo/db': ip_by_net['management'],

                'neutron/mesh': ip_by_net['management'],

                'ceph/public': ip_by_net['management'],

                'neutron/private': None,
                'neutron/floating': None,

                'storage': ip_by_net['storage'],
                'ceph/replication': ip_by_net['storage'],
                'swift/replication': ip_by_net['storage'],
                'cinder/iscsi': ip_by_net['storage'],

            }
            if Node.should_have_public(n):
                netw_roles.update({
                    'ex': ip_by_net['public'],
                    'public/vip': ip_by_net['public'],
                    'ceph/radosgw': ip_by_net['public'],
                })

            nodes[name] = {
                "uid": n.uid,
                "fqdn": n.fqdn,
                "name": name,
                "user_node_name": n.name,
                "swift_zone": n.uid,
                "node_roles": node_roles,
                "network_roles": netw_roles
            }

        return dict(
            nodes=nodes,
            vips=nm.assign_vips_for_net_groups(cluster)
        )
开发者ID:nebril,项目名称:fuel-web,代码行数:81,代码来源:neutron_serializers.py


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