本文整理汇总了Python中nailgun.objects.DeploymentGraph.get_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python DeploymentGraph.get_metadata方法的具体用法?Python DeploymentGraph.get_metadata怎么用?Python DeploymentGraph.get_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.DeploymentGraph
的用法示例。
在下文中一共展示了DeploymentGraph.get_metadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_deployment_graph
# 需要导入模块: from nailgun.objects import DeploymentGraph [as 别名]
# 或者: from nailgun.objects.DeploymentGraph import get_metadata [as 别名]
def get_deployment_graph(cls, instance, graph_type=None):
"""Get deployment graph based on release version.
:param instance: Release instance
:type instance: models.Release
:param graph_type: deployment graph type
:type graph_type: basestring|None
:returns: list of deployment tasks
:rtype: list
"""
if graph_type is None:
graph_type = consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE
env_version = instance.environment_version
deployment_graph = DeploymentGraph.get_for_model(instance, graph_type)
if deployment_graph:
deployment_tasks = DeploymentGraph.get_tasks(deployment_graph)
else:
# deployment tasks list should always be returned
deployment_tasks = []
if graph_type == consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE and \
not deployment_tasks:
# upload default legacy graphs
if env_version.startswith('5.0'):
deployment_tasks = yaml.load(
graph_configuration.DEPLOYMENT_50)
elif env_version.startswith('5.1') \
or env_version.startswith('6.0'):
deployment_tasks = yaml.load(
graph_configuration.DEPLOYMENT_51_60)
if deployment_graph:
if deployment_tasks:
DeploymentGraph.update(
deployment_graph, {'tasks': deployment_tasks})
else:
# create graph anyway
deployment_graph = DeploymentGraph.create_for_model(
{'tasks': deployment_tasks}, instance)
if deployment_graph:
metadata = DeploymentGraph.get_metadata(deployment_graph)
else:
metadata = {}
metadata['tasks'] = deployment_tasks
return metadata