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

Python objects.Cluster类代码示例

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

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



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

示例1: 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 = objects.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:zbwzy,项目名称:nailgun,代码行数:30,代码来源:deployment_serializers.py


示例2: mellanox_settings

    def mellanox_settings(cls, node_attrs, cluster, networks):
        """Mellanox settings

        Serialize mellanox node attrsthen it will be
        merged with common attributes, if mellanox plugin or iSER storage
        enabled.
        """
        # Get Mellanox data
        neutron_mellanox_data = Cluster.get_attributes(cluster).editable.get("neutron_mellanox", {})

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

        # Get network manager
        nm = Cluster.get_network_manager(cluster)

        # 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, nm, networks)

        # 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, nm, networks)

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


示例3: create_cluster

    def create_cluster(self, api=True, exclude=None, **kwargs):
        cluster_data = {"name": "cluster-api-" + str(randint(0, 1000000))}
        editable_attributes = kwargs.pop("editable_attributes", None)

        if kwargs:
            cluster_data.update(kwargs)

        if "release_id" not in cluster_data:
            cluster_data["release_id"] = self.create_release(api=False).id

        if exclude and isinstance(exclude, list):
            for ex in exclude:
                try:
                    del cluster_data[ex]
                except KeyError as err:
                    logger.warning(err)
        if api:
            resp = self.app.post(
                reverse("ClusterCollectionHandler"),
                jsonutils.dumps(cluster_data),
                headers=self.default_headers,
                expect_errors=True,
            )
            self.tester.assertEqual(resp.status_code, 201, resp.body)
            cluster = resp.json_body
            cluster_db = Cluster.get_by_uid(cluster["id"])
        else:
            cluster = Cluster.create(cluster_data)
            cluster_db = cluster
            db().commit()
        self.clusters.append(cluster_db)

        if editable_attributes:
            Cluster.patch_attributes(cluster_db, {"editable": editable_attributes})
        return cluster
开发者ID:thefuyang,项目名称:fuel-web,代码行数:35,代码来源:base.py


示例4: update_pending_roles

    def update_pending_roles(cls, instance, new_pending_roles):
        """Update pending_roles for Node instance.

        Logs an error if node doesn't belong to Cluster

        :param instance: Node instance
        :param new_pending_roles: list of new pending role names
        :returns: None
        """
        if not instance.cluster_id:
            logger.warning(
                u"Attempting to assign pending roles to node "
                u"'{0}' which isn't added to cluster".format(
                    instance.full_name))
            return

        logger.debug(
            u"Updating pending roles for node {0}: {1}".format(
                instance.full_name,
                new_pending_roles))

        if new_pending_roles == []:
            # TODO(enchantner): research why the hell we need this
            Cluster.clear_pending_changes(
                instance.cluster,
                node_id=instance.id
            )

        instance.pending_roles = new_pending_roles
        db().flush()
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:30,代码来源:node.py


示例5: create

    def create(cls, data):
        new_group = super(NodeGroup, cls).create(data)
        try:
            cluster = Cluster.get_by_uid(new_group.cluster_id)
            nm = Cluster.get_network_manager(cluster)
            nst = cluster.network_config.segmentation_type
            # We have two node groups here when user adds the first custom
            # node group.
            if NodeGroupCollection.get_by_cluster_id(cluster.id).count() == 2:
                nm.ensure_gateways_present_in_default_node_group(cluster)
            nm.create_network_groups(
                cluster, neutron_segment_type=nst, node_group_id=new_group.id,
                set_all_gateways=True)
            nm.create_admin_network_group(new_group.cluster_id, new_group.id)
        except (
            errors.OutOfVLANs,
            errors.OutOfIPs,
            errors.NoSuitableCIDR
        ) as exc:
            db().delete(new_group)
            raise errors.CannotCreate(exc.message)

        db().flush()
        db().refresh(cluster)
        return new_group
开发者ID:jiaolongsun,项目名称:fuel-web,代码行数:25,代码来源:node_group.py


示例6: test_get_auth_credentials

    def test_get_auth_credentials(self):
        expected_username = "test"
        expected_password = "test"
        expected_tenant = "test"
        expected_auth_host = "0.0.0.0"
        expected_auth_url = "http://{0}:{1}/{2}/".format(
            expected_auth_host, settings.AUTH_PORT,
            settings.OPENSTACK_API_VERSION["keystone"])

        expected = (expected_username, expected_password, expected_tenant,
                    expected_auth_url)

        cluster = self.env.create_cluster(api=False)
        updated_attributes = {
            "editable": {
                "workloads_collector": {
                    "username": {"value": expected_username},
                    "password": {"value": expected_password},
                    "tenant": {"value": expected_tenant}
                }
            }
        }
        Cluster.update_attributes(cluster, updated_attributes)

        get_host_for_auth_path = ("nailgun.statistics.utils."
                                  "get_mgmt_ip_of_cluster_controller")

        with patch(get_host_for_auth_path,
                   return_value=expected_auth_host):
            client_provider = helpers.ClientProvider(cluster)
            creds = client_provider.credentials

            self.assertEqual(expected, creds)
开发者ID:apporc,项目名称:fuel-web,代码行数:33,代码来源:test_client_provider.py


示例7: create_cluster

    def create_cluster(self, api=True, exclude=None, **kwargs):
        cluster_data = {
            'name': 'cluster-api-' + str(randint(0, 1000000)),
        }

        if kwargs:
            cluster_data.update(kwargs)

        if 'release_id' not in cluster_data:
            cluster_data['release_id'] = self.create_release(api=False).id

        if exclude and isinstance(exclude, list):
            for ex in exclude:
                try:
                    del cluster_data[ex]
                except KeyError as err:
                    logger.warning(err)
        if api:
            resp = self.app.post(
                reverse('ClusterCollectionHandler'),
                jsonutils.dumps(cluster_data),
                headers=self.default_headers,
                expect_errors=True
            )
            self.tester.assertEqual(resp.status_code, 201)
            cluster = resp.json_body
            self.clusters.append(
                Cluster.get_by_uid(cluster['id'])
            )
        else:
            cluster = Cluster.create(cluster_data)
            db().commit()
            self.clusters.append(cluster)

        return cluster
开发者ID:slystopad,项目名称:fuel-web,代码行数:35,代码来源:base.py


示例8: _generate_external_network

    def _generate_external_network(cls, cluster):
        public_cidr, public_gw = db().query(
            NetworkGroup.cidr,
            NetworkGroup.gateway
        ).filter_by(
            group_id=Cluster.get_default_group(cluster).id,
            name='public'
        ).first()

        return {
            "L3": {
                "subnet": public_cidr,
                "gateway": public_gw,
                "nameservers": [],
                "floating": utils.join_range(
                    cluster.network_config.floating_ranges[0]),
                "enable_dhcp": False
            },
            "L2": {
                "network_type": "flat",
                "segment_id": None,
                "router_ext": True,
                "physnet": "physnet1"
            },
            "tenant": Cluster.get_creds(cluster)['tenant']['value'],
            "shared": False
        }
开发者ID:anbangr,项目名称:fuel-web,代码行数:27,代码来源:neutron_serializers.py


示例9: remove_from_cluster

    def remove_from_cluster(cls, instance):
        """Remove Node from Cluster.

        Also drops networks assignment for Node and clears both
        roles and pending roles

        :param instance: Node instance
        :returns: None
        """
        if instance.cluster:
            Cluster.clear_pending_changes(
                instance.cluster,
                node_id=instance.id
            )
            netmanager = Cluster.get_network_manager(
                instance.cluster
            )
            netmanager.clear_assigned_networks(instance)
            netmanager.clear_bond_configuration(instance)
        cls.update_roles(instance, [])
        cls.update_pending_roles(instance, [])
        cls.remove_replaced_params(instance)
        instance.cluster_id = None
        instance.group_id = None
        instance.kernel_params = None
        instance.primary_roles = []
        instance.hostname = cls.default_slave_name(instance)

        from nailgun.objects import OpenstackConfig
        OpenstackConfig.disable_by_nodes([instance])

        db().flush()
        db().refresh(instance)
开发者ID:katepimenova,项目名称:fuel-web,代码行数:33,代码来源:node.py


示例10: remove_from_cluster

    def remove_from_cluster(cls, instance):
        """Remove Node from Cluster.
        Also drops networks assignment for Node and clears both
        roles and pending roles

        :param instance: Node instance
        :returns: None
        """
        if instance.cluster:
            Cluster.clear_pending_changes(
                instance.cluster,
                node_id=instance.id
            )
            netmanager = Cluster.get_network_manager(
                instance.cluster
            )
            netmanager.clear_assigned_networks(instance)
            netmanager.clear_bond_configuration(instance)
        cls.update_roles(instance, [])
        cls.update_pending_roles(instance, [])
        cls.remove_replaced_params(instance)
        instance.cluster_id = None
        instance.group_id = None
        instance.kernel_params = None
        instance.reset_name_to_default()
        db().flush()
        db().refresh(instance)
开发者ID:apporc,项目名称:fuel-web,代码行数:27,代码来源:node.py


示例11: update_pending_roles

    def update_pending_roles(cls, instance, new_pending_roles):
        if not instance.cluster_id:
            logger.warning(
                u"Attempting to assign pending roles to node "
                u"'{0}' which isn't added to cluster".format(
                    instance.name or instance.id
                )
            )
            return

        logger.debug(
            u"Updating pending roles for node {0}: {1}".format(
                instance.id,
                new_pending_roles
            )
        )

        if new_pending_roles == []:
            instance.pending_role_list = []
            # research why the hell we need this
            Cluster.clear_pending_changes(
                instance.cluster,
                node_id=instance.id
            )
        else:
            instance.pending_role_list = db().query(models.Role).filter_by(
                release_id=instance.cluster.release_id,
            ).filter(
                models.Role.name.in_(new_pending_roles)
            ).all()

        db().flush()
        db().refresh(instance)
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:33,代码来源:node.py


示例12: update_volumes

    def update_volumes(cls, instance):
        attrs = instance.attributes
        if not attrs:
            attrs = cls.create_attributes(instance)

        try:
            attrs.volumes = instance.volume_manager.gen_volumes_info()
        except Exception as exc:
            msg = (
                u"Failed to generate volumes "
                u"info for node '{0}': '{1}'"
            ).format(
                instance.name or instance.mac or instance.id,
                str(exc) or "see logs for details"
            )
            logger.warning(traceback.format_exc())
            Notification.create({
                "topic": "error",
                "message": msg,
                "node_id": instance.id
            })

        if instance.cluster_id:
            Cluster.add_pending_changes(
                instance.cluster,
                "disks",
                node_id=instance.id
            )

        db().add(attrs)
        db().flush()
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:31,代码来源:node.py


示例13: update_pending_roles

    def update_pending_roles(cls, instance, new_pending_roles):
        """Update pending_roles for Node instance.
        Logs an error if node doesn't belong to Cluster

        :param instance: Node instance
        :param new_pending_roles: list of new pending role names
        :returns: None
        """
        if not instance.cluster_id:
            logger.warning(
                u"Attempting to assign pending roles to node "
                u"'{0}' which isn't added to cluster".format(instance.name or instance.id)
            )
            return

        logger.debug(u"Updating pending roles for node {0}: {1}".format(instance.id, new_pending_roles))

        if new_pending_roles == []:
            instance.pending_role_list = []
            # TODO(enchantner): research why the hell we need this
            Cluster.clear_pending_changes(instance.cluster, node_id=instance.id)
        else:
            instance.pending_role_list = (
                db()
                .query(models.Role)
                .filter_by(release_id=instance.cluster.release_id)
                .filter(models.Role.name.in_(new_pending_roles))
                .all()
            )

        db().flush()
        db().refresh(instance)
开发者ID:blkart,项目名称:fuel-web,代码行数:32,代码来源:node.py


示例14: check_creds

        def check_creds(updated_attrs, expected_creds):
            Cluster.update_attributes(cluster, updated_attributes)
            with patch(get_host_for_auth_path,
                       return_value=expected_auth_host):
                client_provider = helpers.ClientProvider(cluster)
                creds = client_provider.credentials

                self.assertEqual(expected_creds, creds)
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:8,代码来源:test_client_provider.py


示例15: remove_tag

 def remove_tag(cls, instance, tag_name):
     from nailgun.objects import Cluster
     cls.remove_tag_from_roles(instance, tag_name)
     res = instance.tags_metadata.pop(tag_name, None)
     for cluster in instance.clusters:
         if tag_name not in cluster.tags_metadata:
             Cluster.remove_tag_from_roles(cluster, tag_name)
             Cluster.remove_primary_tag(cluster, tag_name)
     return bool(res)
开发者ID:openstack,项目名称:fuel-web,代码行数:9,代码来源:release.py


示例16: add_pending_change

    def add_pending_change(cls, instance, change):
        """Add pending change into Cluster.

        :param instance: Node instance
        :param change: string value of cluster change
        :returns: None
        """
        if instance.cluster:
            Cluster.add_pending_changes(instance.cluster, change, node_id=instance.id)
开发者ID:blkart,项目名称:fuel-web,代码行数:9,代码来源:node.py


示例17: fn

 def fn():
     # try to commit wrong data
     Cluster.create(
         {
             "id": "500",
             "release_id": "500"
         }
     )
     self.db.commit()
开发者ID:kansuke4649,项目名称:fuel-web,代码行数:9,代码来源:test_statsender.py


示例18: 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


示例19: _update_cluster_data

    def _update_cluster_data(cls, instance):
        cluster = instance.cluster

        if instance.name == "deploy":
            if instance.status == "ready":
                # If for some reasosns orchestrator
                # didn't send ready status for node
                # we should set it explicitly
                for n in cluster.nodes:
                    if n.status == "deploying":
                        n.status = "ready"
                        n.progress = 100

                cls.__update_cluster_status(cluster, "operational")

                Cluster.clear_pending_changes(cluster)

            elif instance.status == "error" and not TaskHelper.before_deployment_error(instance):
                # We don't want to set cluster status to
                # error because we don't want to lock
                # settings if cluster wasn't delpoyed

                cls.__update_cluster_status(cluster, "error")

        elif instance.name == "deployment" and instance.status == "error":
            cls.__update_cluster_status(cluster, "error")

            q_nodes_to_error = TaskHelper.get_nodes_to_deployment_error(cluster)

            cls.__update_nodes_to_error(q_nodes_to_error, error_type="deploy")

        elif instance.name == "provision" and instance.status == "error":
            cls.__update_cluster_status(cluster, "error")

            q_nodes_to_error = TaskHelper.get_nodes_to_provisioning_error(cluster)

            cls.__update_nodes_to_error(q_nodes_to_error, error_type="provision")

        elif instance.name == "stop_deployment":
            if instance.status == "error":
                cls.__update_cluster_status(cluster, "error")
            else:
                cls.__update_cluster_status(cluster, "stopped")

        elif instance.name == consts.TASK_NAMES.update:
            if instance.status == consts.TASK_STATUSES.error:
                cls.__update_cluster_status(cluster, consts.CLUSTER_STATUSES.update_error)

                q_nodes_to_error = TaskHelper.get_nodes_to_deployment_error(cluster)
                cls.__update_nodes_to_error(q_nodes_to_error, error_type=consts.NODE_ERRORS.deploy)

            elif instance.status == consts.TASK_STATUSES.ready:
                cls.__update_cluster_status(cluster, consts.CLUSTER_STATUSES.operational)
                cluster.release_id = cluster.pending_release_id
                cluster.pending_release_id = None
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:55,代码来源:task.py


示例20: remove_from_cluster

 def remove_from_cluster(cls, instance):
     Cluster.clear_pending_changes(
         instance.cluster,
         node_id=instance.id
     )
     Cluster.get_network_manager(
         instance.cluster
     ).clear_assigned_networks(instance)
     instance.cluster_id = None
     instance.roles = instance.pending_roles = []
     instance.reset_name_to_default()
     db().flush()
     db().refresh(instance)
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:13,代码来源:node.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python objects.ClusterPlugins类代码示例发布时间:2022-05-27
下一篇:
Python notifier.notify函数代码示例发布时间: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