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


Python Cluster.create方法代码示例

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


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

示例1: fn

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import create [as 别名]
 def fn():
     # try to commit wrong data
     Cluster.create(
         {
             "id": "500",
             "release_id": "500"
         }
     )
     self.db.commit()
开发者ID:kansuke4649,项目名称:fuel-web,代码行数:11,代码来源:test_statsender.py

示例2: create_cluster

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import create [as 别名]
    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,代码行数:37,代码来源:base.py

示例3: create_cluster

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import create [as 别名]
    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,代码行数:37,代码来源:base.py


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