• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python objects.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: serialize

 def serialize(cls, instance, fields=None):
     from nailgun.objects import Node
     data_dict = super(NodeSerializer, cls).serialize(instance, fields)
     data_dict['fqdn'] = Node.get_node_fqdn(instance)
     data_dict['status'] = Node.get_status(instance)
     data_dict['tags'] = instance.tag_names
     return data_dict
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:7,代码来源:node.py


示例2: generate_network_scheme

    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,代码行数:31,代码来源:neutron_serializers.py


示例3: generate_network_metadata

    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.get_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"],
                "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"],
                "ceph/public": ip_by_net["management"],
                "storage": ip_by_net["storage"],
                "ceph/replication": ip_by_net["storage"],
                "swift/replication": ip_by_net["storage"],
                "cinder/iscsi": ip_by_net["storage"],
                "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:naveenzhang,项目名称:fuel-web,代码行数:56,代码来源:nova_serializers.py


示例4: create_node

    def create_node(self, api=False, exclude=None, expect_http=201, expected_error=None, **kwargs):
        # TODO(alekseyk) Simplify 'interfaces' and 'mac' manipulation logic
        metadata = kwargs.get("meta")
        default_metadata = self.default_metadata()
        if metadata:
            default_metadata.update(metadata)
            meta_ifaces = "interfaces" in metadata

        mac = kwargs.get("mac", self.generate_random_mac())
        if default_metadata["interfaces"]:
            default_metadata["interfaces"][0]["mac"] = mac
            if not metadata or not meta_ifaces:
                for iface in default_metadata["interfaces"][1:]:
                    if "mac" in iface:
                        iface["mac"] = self.generate_random_mac()

        node_data = {"mac": mac, "status": "discover", "ip": "10.20.0.130", "meta": default_metadata}
        if kwargs:
            meta = kwargs.pop("meta", None)
            node_data.update(kwargs)
            if meta:
                kwargs["meta"] = meta

        if exclude and isinstance(exclude, list):
            for ex in exclude:
                try:
                    del node_data[ex]
                except KeyError as err:
                    logger.warning(err)
        if api:
            resp = self.app.post(
                reverse("NodeCollectionHandler"),
                jsonutils.dumps(node_data),
                headers=self.default_headers,
                expect_errors=True,
            )
            self.tester.assertEqual(resp.status_code, expect_http, resp.body)
            if expected_error:
                self.tester.assertEqual(resp.json_body["message"], expected_error)
            if str(expect_http)[0] != "2":
                return None
            self.tester.assertEqual(resp.status_code, expect_http)
            node = resp.json_body
            node_db = Node.get_by_uid(node["id"])
            if "interfaces" not in node_data["meta"] or not node_data["meta"]["interfaces"]:
                self._set_interfaces_if_not_set_in_meta(node_db.id, kwargs.get("meta", None))
            self.nodes.append(node_db)
        else:
            node = Node.create(node_data)
            db().commit()
            self.nodes.append(node)

        return node
开发者ID:thefuyang,项目名称:fuel-web,代码行数:53,代码来源:base.py


示例5: set_default_node_volumes

    def set_default_node_volumes(cls, node):
        from .objects.volumes import VolumeObject

        try:
            VolumeObject.set_default_node_volumes(node)
        except Exception as exc:
            logger.exception(exc)
            msg = "Failed to generate volumes for node '{0}': '{1}'".format(
                node.human_readable_name, six.text_type(exc)
            )
            Notification.create({"topic": "error", "message": msg, "node_id": node.id})

        if node.cluster_id:
            Node.add_pending_change(node, "disks")
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:14,代码来源:extension.py


示例6: mellanox_settings

    def mellanox_settings(cls, node_attrs, node):
        """Serialize mellanox node attrs, then it will be
        merged with common attributes, if mellanox plugin or iSER storage
        enabled.
        """
        # Get Mellanox data
        neutron_mellanox_data =  \
            Cluster.get_attributes(node.cluster).editable\
            .get('neutron_mellanox', {})

        # Get storage data
        storage_data = \
            Cluster.get_attributes(node.cluster).editable.get('storage', {})

        # Get network manager
        nm = Node.get_network_manager(node)

        # Init mellanox dict
        node_attrs['neutron_mellanox'] = {}

        # Find Physical port for VFs generation
        if 'plugin' in neutron_mellanox_data and \
           neutron_mellanox_data['plugin']['value'] == 'ethernet':
            node_attrs = cls.set_mellanox_ml2_config(node_attrs, node, nm)

        # Fix network scheme to have physical port for RDMA if iSER enabled
        if 'iser' in storage_data and storage_data['iser']['value']:
            node_attrs = cls.fix_iser_port(node_attrs, node, nm)

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


示例7: update_nodes

    def update_nodes(cls, instance, nodes_ids):
        """Update Cluster nodes by specified node IDs

        Nodes with specified IDs will replace existing ones in Cluster

        :param instance: Cluster instance
        :param nodes_ids: list of nodes ids
        :returns: None
        """

        # TODO(NAME): sepatate nodes
        # for deletion and addition by set().
        new_nodes = []
        if nodes_ids:
            new_nodes = db().query(models.Node).filter(
                models.Node.id.in_(nodes_ids)
            )

        nodes_to_remove = [n for n in instance.nodes
                           if n not in new_nodes]
        nodes_to_add = [n for n in new_nodes
                        if n not in instance.nodes]

        for node in nodes_to_add:
            if not node.online:
                raise errors.NodeOffline(
                    u"Cannot add offline node "
                    u"'{0}' to environment".format(node.id)
                )

        # we should reset hostname to default value to guarantee
        # hostnames uniqueness for nodes outside clusters
        from nailgun.objects import Node
        for node in nodes_to_remove:
            node.hostname = Node.default_slave_name(node)

        map(instance.nodes.remove, nodes_to_remove)
        map(instance.nodes.append, nodes_to_add)

        net_manager = cls.get_network_manager(instance)
        map(
            net_manager.clear_assigned_networks,
            nodes_to_remove
        )
        map(
            net_manager.clear_bond_configuration,
            nodes_to_remove
        )
        cls.replace_provisioning_info_on_nodes(instance, [], nodes_to_remove)
        cls.replace_deployment_info_on_nodes(instance, [], nodes_to_remove)
        from nailgun.objects import NodeCollection
        NodeCollection.reset_network_template(nodes_to_remove)

        map(
            net_manager.assign_networks_by_default,
            nodes_to_add
        )
        cls.update_nodes_network_template(instance, nodes_to_add)
        db().flush()
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:59,代码来源:cluster.py


示例8: get_dpdk_driver

 def get_dpdk_driver(cls, instance, dpdk_drivers):
     from nailgun.objects import Node
     pci_id = instance.meta.get('pci_id', '').lower()
     sriov_enabled = Node.sriov_enabled(instance.node)
     for driver, device_ids in six.iteritems(dpdk_drivers):
         if pci_id in device_ids:
             if sriov_enabled:
                 return consts.DPDK_DRIVER_IN_SRIOV_CASE
             return driver
     return None
开发者ID:openstack,项目名称:fuel-web,代码行数:10,代码来源:interface.py


示例9: generate_network_metadata

    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for node in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.get_slave_name(node)
            node_roles = Node.all_roles(node)
            network_roles = cls.get_network_role_mapping_to_ip(node)

            nodes[name] = {
                "uid": node.uid,
                "fqdn": Node.get_node_fqdn(node),
                "name": name,
                "user_node_name": node.name,
                "swift_zone": node.uid,
                "node_roles": node_roles,
                "network_roles": network_roles,
            }

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


示例10: generate_network_metadata

 def generate_network_metadata(cls, cluster):
     metadata = super(NeutronNetworkTemplateSerializer70,
                      cls).generate_network_metadata(cluster)
     for node_data in metadata['nodes'].values():
         node = Node.get_by_uid(node_data['uid'])
         network_roles = cls._get_network_roles(node)
         ip_per_ep = cls._get_endpoint_to_ip_mapping(node)
         node_data['network_roles'] = {}
         for role, ep in network_roles.items():
             node_data['network_roles'][role] = ip_per_ep.get(ep)
     return metadata
开发者ID:anbangr,项目名称:fuel-web,代码行数:11,代码来源:neutron_serializers.py


示例11: add_vlan_interfaces

    def add_vlan_interfaces(cls, node):
        """Assign fixed_interfaces and vlan_interface.
        They should be equal.
        """
        net_manager = Node.get_network_manager(node)
        fixed_interface = net_manager._get_interface_by_network_name(
            node.id, 'fixed')

        attrs = {'fixed_interface': fixed_interface.name,
                 'vlan_interface': fixed_interface.name}
        return attrs
开发者ID:phillipsio,项目名称:fuel-web,代码行数:11,代码来源:nova_serializers.py


示例12: get_default_network_to_endpoint_mapping

    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,代码行数:11,代码来源:neutron_serializers.py


示例13: get_default_network_to_endpoint_mapping

    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,代码行数:12,代码来源:neutron_serializers.py


示例14: update_nodes_net_info

 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,代码行数:12,代码来源:base_serializers.py


示例15: get_admin_ip_w_prefix

    def get_admin_ip_w_prefix(node):
        """Getting admin ip and assign prefix from admin network."""
        network_manager = Node.get_network_manager(node)
        admin_ip = network_manager.get_admin_ip_for_node(node.id)
        admin_ip = IPNetwork(admin_ip)

        # Assign prefix from admin network
        admin_net = IPNetwork(
            network_manager.get_admin_network_group(node.id).cidr
        )
        admin_ip.prefixlen = admin_net.prefixlen

        return str(admin_ip)
开发者ID:phillipsio,项目名称:fuel-web,代码行数:13,代码来源:base_serializers.py


示例16: generate_network_scheme

    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,代码行数:37,代码来源:neutron_serializers.py


示例17: network_provider_cluster_attrs

    def network_provider_cluster_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = {'quantum': True,
                 'quantum_settings': cls.neutron_attrs(cluster)}

        if cluster.mode == 'multinode':
            for node in cluster.nodes:
                if cls._node_has_role_by_name(node, 'controller'):
                    net_manager = Node.get_network_manager(node)
                    mgmt_cidr = net_manager.get_node_network_by_netname(
                        node,
                        'management'
                    )['ip']
                    attrs['management_vip'] = mgmt_cidr.split('/')[0]
                    break

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


示例18: get_network_to_endpoint_mapping

    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,代码行数:17,代码来源:neutron_serializers.py


示例19: generate_network_scheme

    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,代码行数:43,代码来源:neutron_serializers.py


示例20: _update_public_network

    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,代码行数:20,代码来源:network_group.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python objects.NodeCollection类代码示例发布时间:2022-05-27
下一篇:
Python objects.DeploymentGraph类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap