當前位置: 首頁>>代碼示例>>Python>>正文


Python objects.NodeCollection類代碼示例

本文整理匯總了Python中nailgun.objects.NodeCollection的典型用法代碼示例。如果您正苦於以下問題:Python NodeCollection類的具體用法?Python NodeCollection怎麽用?Python NodeCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NodeCollection類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_pagination_of_node_collection

    def test_pagination_of_node_collection(self):
        def assert_pagination_and_cont_rng(q, cr, sz, first, last, ttl, valid):
            self.assertEqual(q.count(), sz)
            self.assertEqual(cr.first, first)
            self.assertEqual(cr.last, last)
            self.assertEqual(cr.total, ttl)
            self.assertEqual(cr.valid, valid)

        self.env.create_nodes(5)
        # test pagination limited to 2 first items
        pagination = Pagination(limit=2)
        q, cr = NodeCollection.scope(pagination)
        assert_pagination_and_cont_rng(q, cr, 2, 1, 2, 5, True)
        # test invalid pagination
        pagination = Pagination(offset=5)
        q, cr = NodeCollection.scope(pagination)
        assert_pagination_and_cont_rng(q, cr, 0, 0, 0, 5, False)
        # test limit=0, offset ignored
        pagination = Pagination(limit=0, offset=999)
        q, cr = NodeCollection.scope(pagination)
        assert_pagination_and_cont_rng(q, cr, 0, 0, 0, 5, True)
        # test limit+offset+order_by
        pagination = Pagination(limit=3, offset=1, order_by='-id')
        q, cr = NodeCollection.scope(pagination)
        assert_pagination_and_cont_rng(q, cr, 3, 2, 4, 5, True)
        ids = sorted([i.id for i in self.env.nodes])
        n = q.all()
        self.assertEqual(n[0].id, ids[3])
        self.assertEqual(n[1].id, ids[2])
        self.assertEqual(n[2].id, ids[1])
開發者ID:openstack,項目名稱:fuel-web,代碼行數:30,代碼來源:test_handlers.py

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

示例3: get_clusters_info

 def get_clusters_info(self):
     clusters = ClusterCollection.all()
     clusters_info = []
     for cluster in clusters:
         release = cluster.release
         nodes_num = NodeCollection.filter_by(
             None, cluster_id=cluster.id).count()
         cluster_info = {
             'id': cluster.id,
             'nodes_num': nodes_num,
             'release': {
                 'os': release.operating_system,
                 'name': release.name,
                 'version': release.version
             },
             'mode': cluster.mode,
             'nodes': self.get_nodes_info(cluster.nodes),
             'node_groups': self.get_node_groups_info(cluster.node_groups),
             'status': cluster.status,
             'attributes': self.get_attributes(cluster.attributes.editable,
                                               self.attributes_white_list),
             'vmware_attributes': self.get_attributes(
                 cluster.vmware_attributes.editable,
                 self.vmware_attributes_white_list
             ),
             'net_provider': cluster.net_provider,
             'fuel_version': cluster.fuel_version,
             'is_customized': cluster.is_customized,
             'network_configuration': self.get_network_configuration_info(
                 cluster),
             'installed_plugins': self.get_cluster_plugins_info(cluster)
         }
         clusters_info.append(cluster_info)
     return clusters_info
開發者ID:TorstenS73,項目名稱:fuel-web,代碼行數:34,代碼來源:installation_info.py

示例4: get_installation_info

    def get_installation_info(self):
        clusters_info = self.get_clusters_info()
        allocated_nodes_num = sum([c['nodes_num'] for c in clusters_info])
        unallocated_nodes_num = NodeCollection.filter_by(
            None, cluster_id=None).count()

        info = {
            'master_node_uid': self.get_master_node_uid(),
            'fuel_release': self.fuel_release_info(),
            'clusters': clusters_info,
            'clusters_num': len(clusters_info),
            'allocated_nodes_num': allocated_nodes_num,
            'unallocated_nodes_num': unallocated_nodes_num
        }

        return info
開發者ID:CGenie,項目名稱:fuel-web,代碼行數:16,代碼來源:installation_info.py

示例5: get_clusters_info

 def get_clusters_info(self):
     clusters = ClusterCollection.all()
     clusters_info = []
     for cluster in clusters:
         release = cluster.release
         nodes_num = NodeCollection.filter_by(
             None, cluster_id=cluster.id).count()
         cluster_info = {
             'id': cluster.id,
             'nodes_num': nodes_num,
             'release': {
                 'os': release.operating_system,
                 'name': release.name,
                 'version': release.version
             },
             'mode': cluster.mode,
             'nodes': self.get_nodes_info(cluster.nodes),
             'status': cluster.status
         }
         clusters_info.append(cluster_info)
     return clusters_info
開發者ID:CGenie,項目名稱:fuel-web,代碼行數:21,代碼來源:installation_info.py

示例6: get_clusters_info

 def get_clusters_info(self):
     clusters = ClusterCollection.all()
     clusters_info = []
     for cluster in clusters:
         release = cluster.release
         nodes_num = NodeCollection.filter_by(
             None, cluster_id=cluster.id).count()
         cluster_info = {
             'id': cluster.id,
             'nodes_num': nodes_num,
             'release': {
                 'os': release.operating_system,
                 'name': release.name,
                 'version': release.version
             },
             'mode': cluster.mode,
             'nodes': self.get_nodes_info(cluster.nodes),
             'node_groups': self.get_node_groups_info(cluster.node_groups),
             'status': cluster.status,
             'extensions': cluster.extensions,
             'attributes': self.get_attributes(
                 Cluster.get_editable_attributes(cluster),
                 self.attributes_white_list
             ),
             'plugin_links': self.get_plugin_links(
                 cluster.plugin_links),
             'net_provider': cluster.net_provider,
             'fuel_version': cluster.fuel_version,
             'is_customized': cluster.is_customized,
             'network_configuration': self.get_network_configuration_info(
                 cluster),
             'installed_plugins': self.get_cluster_plugins_info(cluster),
             'components': cluster.components,
             'cluster_plugins': cluster.cluster_plugins,
             'roles_metadata': cluster.roles_metadata,
             'tags_metadata': cluster.tags_metadata,
             'volumes_metadata': cluster.volumes_metadata,
         }
         clusters_info.append(cluster_info)
     return clusters_info
開發者ID:openstack,項目名稱:fuel-web,代碼行數:40,代碼來源:installation_info.py


注:本文中的nailgun.objects.NodeCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。