本文整理汇总了Python中nailgun.objects.Release.is_lcm_supported方法的典型用法代码示例。如果您正苦于以下问题:Python Release.is_lcm_supported方法的具体用法?Python Release.is_lcm_supported怎么用?Python Release.is_lcm_supported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Release
的用法示例。
在下文中一共展示了Release.is_lcm_supported方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_cluster_attributes
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import is_lcm_supported [as 别名]
def process_cluster_attributes(cls, cluster, attributes):
"""Generate Cluster-Plugins relation based on attributes.
Iterates through plugins attributes, creates
or deletes Cluster <-> Plugins relation if plugin
is enabled or disabled.
:param cluster: A cluster instance
:type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
:param attributes: Cluster attributes
:type attributes: dict
"""
from nailgun.objects import Release
plugins = {}
# Detach plugins data
for k in list(attributes):
if cls.is_plugin_data(attributes[k]):
plugins[k] = attributes.pop(k)['metadata']
propagate_task_deploy = get_in(
attributes, 'common', 'propagate_task_deploy', 'value')
if propagate_task_deploy is not None:
legacy_tasks_are_ignored = not propagate_task_deploy
else:
legacy_tasks_are_ignored = not get_in(
cluster.attributes.editable,
'common', 'propagate_task_deploy', 'value')
for container in six.itervalues(plugins):
default = container.get('default', False)
for attrs in container.get('versions', []):
version_metadata = attrs.pop('metadata')
plugin_id = version_metadata['plugin_id']
plugin = Plugin.get_by_uid(plugin_id)
if not plugin:
logger.warning(
'Plugin with id "%s" is not found, skip it', plugin_id)
continue
enabled = container['enabled'] \
and plugin_id == container['chosen_id']
if (enabled and
Release.is_lcm_supported(cluster.release) and
legacy_tasks_are_ignored and
cls.contains_legacy_tasks(
wrap_plugin(Plugin.get_by_uid(plugin.id)))):
raise errors.InvalidData(
'Cannot enable plugin with legacy tasks unless '
'propagate_task_deploy attribute is set. '
'Ensure tasks.yaml is empty and all tasks '
'has version >= 2.0.0.')
ClusterPlugin.set_attributes(
cluster.id, plugin.id, enabled=enabled,
attrs=attrs if enabled or default else None
)