本文整理汇总了Python中nailgun.objects.Cluster.patch_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.patch_attributes方法的具体用法?Python Cluster.patch_attributes怎么用?Python Cluster.patch_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Cluster
的用法示例。
在下文中一共展示了Cluster.patch_attributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_cluster
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import patch_attributes [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
示例2: test_neutron_networking_parameters_baremetal
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import patch_attributes [as 别名]
def test_neutron_networking_parameters_baremetal(self):
attributes_metadata = """
editable:
additional_components:
ironic:
value: %r
type: "checkbox"
"""
cluster = self.env.create_cluster(
api=False,
net_provider=consts.CLUSTER_NET_PROVIDERS.neutron)
# Ensure baremetal_* fields are not serialized when Ironic disabled
nw_params = NeutronNetworkConfigurationSerializer. \
serialize_network_params(cluster)
self.assertNotIn('baremetal_gateway', nw_params)
self.assertNotIn('baremetal_range', nw_params)
# Ensure baremetal_* fields are serialized when Ironic enabled
Cluster.patch_attributes(
cluster, yaml.load(attributes_metadata % True))
self.db.refresh(cluster)
nw_params = NeutronNetworkConfigurationSerializer. \
serialize_network_params(cluster)
self.assertIn('baremetal_gateway', nw_params)
self.assertIn('baremetal_range', nw_params)