本文整理匯總了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