本文整理汇总了Python中nailgun.objects.Cluster.remove_primary_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.remove_primary_tag方法的具体用法?Python Cluster.remove_primary_tag怎么用?Python Cluster.remove_primary_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Cluster
的用法示例。
在下文中一共展示了Cluster.remove_primary_tag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_tag
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import remove_primary_tag [as 别名]
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)
示例2: update_role
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import remove_primary_tag [as 别名]
def update_role(cls, instance, role):
from nailgun.objects import Cluster
"""Update existing Release instance with specified role.
Previous ones are deleted.
:param instance: a Release instance
:param role: a role dict
:returns: None
"""
old_role = instance.roles_metadata.get(role['name'], {})
instance.roles_metadata[role['name']] = role['meta']
if old_role:
deleted_tags = set(old_role['tags']) - set(role['meta']['tags'])
for cluster in instance.clusters:
for tag in deleted_tags:
if role['name'] not in cluster.roles_metadata:
Cluster.remove_primary_tag(cluster, tag)
instance.volumes_metadata['volumes_roles_mapping'][role['name']] = \
role.get('volumes_roles_mapping', [])
# notify about changes
instance.volumes_metadata.changed()