本文整理汇总了Python中nailgun.objects.DeploymentGraph.get_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python DeploymentGraph.get_tasks方法的具体用法?Python DeploymentGraph.get_tasks怎么用?Python DeploymentGraph.get_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.DeploymentGraph
的用法示例。
在下文中一共展示了DeploymentGraph.get_tasks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_deployment_graph
# 需要导入模块: from nailgun.objects import DeploymentGraph [as 别名]
# 或者: from nailgun.objects.DeploymentGraph import get_tasks [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
示例2: test_get_metadata
# 需要导入模块: from nailgun.objects import DeploymentGraph [as 别名]
# 或者: from nailgun.objects.DeploymentGraph import get_tasks [as 别名]
def test_get_metadata(self):
plugin_metadata = self.env.get_default_plugin_metadata()
attributes_metadata = self.env.get_default_plugin_env_config()
roles_metadata = self.env.get_default_plugin_node_roles_config()
tags_metadata = self.env.get_default_plugin_node_tags_config()
volumes_metadata = self.env.get_default_plugin_volumes_config()
network_roles_metadata = self.env.get_default_network_roles_config()
deployment_tasks = self.env.get_default_plugin_deployment_tasks()
tasks = self.env.get_default_plugin_tasks()
components_metadata = self.env.get_default_components()
nic_attributes_metadata = self.env.get_default_plugin_nic_config()
bond_attributes_metadata = self.env.get_default_plugin_bond_config()
node_attributes_metadata = self.env.get_default_plugin_node_config()
plugin_metadata.update({
'attributes_metadata': attributes_metadata,
'roles_metadata': roles_metadata,
'tags_metadata': tags_metadata,
'volumes_metadata': volumes_metadata,
'network_roles_metadata': network_roles_metadata,
'deployment_tasks': deployment_tasks,
'tasks': tasks,
'components_metadata': components_metadata,
'nic_attributes_metadata': nic_attributes_metadata,
'bond_attributes_metadata': bond_attributes_metadata,
'node_attributes_metadata': node_attributes_metadata,
'graphs': [{
'type': 'custom',
'name': 'custom',
'tasks': [
{'id': 'task{}'.format(n), 'type': 'puppet'}
for n in range(2)
]
}]
})
with mock.patch.object(
self.plugin_adapter, 'loader') as loader:
loader.load.return_value = (plugin_metadata, ReportNode())
Plugin.update(self.plugin, self.plugin_adapter.get_metadata())
for key, val in six.iteritems(
{
k: v for (k, v) in six.iteritems(plugin_metadata)
if k not in ('deployment_tasks', 'graphs')
}
):
self.assertEqual(
getattr(self.plugin, key), val)
self.assertEqual(
self.plugin.attributes_metadata,
attributes_metadata['attributes'])
self.assertEqual(
self.plugin.roles_metadata, roles_metadata)
self.assertEqual(
self.plugin.tags_metadata, tags_metadata)
self.assertEqual(
self.plugin.volumes_metadata, volumes_metadata)
self.assertEqual(
self.plugin.tasks, tasks)
self.assertEqual(
self.plugin.components_metadata, components_metadata)
self.assertEqual(
self.plugin.nic_attributes_metadata,
nic_attributes_metadata)
self.assertEqual(
self.plugin.bond_attributes_metadata,
bond_attributes_metadata)
self.assertEqual(
self.plugin.node_attributes_metadata,
node_attributes_metadata)
# check custom graph
dg = DeploymentGraph.get_for_model(
self.plugin, graph_type='custom'
)
self.assertEqual(dg.name, 'custom')
self.assertItemsEqual(
DeploymentGraph.get_tasks(dg),
[
{
'id': 'task{}'.format(i),
'task_name':
'task{}'.format(i),
'type': 'puppet',
'version': '1.0.0'
} for i in range(2)
]
)
# deployment tasks returning all non-defined fields, so check
# should differ from JSON-stored fields
plugin_tasks = self.env.get_default_plugin_deployment_tasks()
self.assertGreater(len(plugin_tasks), 0)
for k, v in six.iteritems(plugin_tasks[0]):
# this field is updated by plugin adapter
if k is 'parameters':
v.update({
'cwd': '/etc/fuel/plugins/testing_plugin-0.1/'
})
#.........这里部分代码省略.........
示例3: test_graphs_creation
# 需要导入模块: from nailgun.objects import DeploymentGraph [as 别名]
# 或者: from nailgun.objects.DeploymentGraph import get_tasks [as 别名]
def test_graphs_creation(self):
metadata_update = {
'name': 'graphs_plugin',
'description': 'testing graphs',
'package_version': '5.0.0',
'graphs': [
{
'type': 'default',
'name': 'default',
'tasks': [
{'id': 'default', 'type': 'puppet'}
]
},
{
'type': 'custom',
'name': 'custom',
'tasks': [
{'id': 'custom', 'type': 'puppet'}
]
}
]}
metadata = self.env.get_default_plugin_metadata()
metadata.update(metadata_update)
plugin = Plugin.create(metadata)
def_graph = DeploymentGraph.get_for_model(
plugin, graph_type='default'
)
self.assertEqual(def_graph.name, 'default')
self.assertEqual(
DeploymentGraph.get_tasks(def_graph),
[
{
'id': 'default',
'task_name': 'default',
'type': 'puppet',
'version': '1.0.0'
}
]
)
custom_graph = DeploymentGraph.get_for_model(
plugin, graph_type='custom'
)
self.assertEqual(custom_graph.name, 'custom')
self.assertEqual(
DeploymentGraph.get_tasks(custom_graph),
[
{
'id': 'custom',
'task_name': 'custom',
'type': 'puppet',
'version': '1.0.0'
}
]
)
Plugin.update(plugin, metadata)
def_graph = DeploymentGraph.get_for_model(
plugin, graph_type='default'
)
self.assertEqual(def_graph.name, 'default')
self.assertEqual(
DeploymentGraph.get_tasks(def_graph),
[
{
'id': 'default',
'task_name': 'default',
'type': 'puppet',
'version': '1.0.0'
}
]
)
custom_graph = DeploymentGraph.get_for_model(
plugin, graph_type='custom'
)
self.assertEqual(custom_graph.name, 'custom')
self.assertEqual(
DeploymentGraph.get_tasks(custom_graph),
[
{
'id': 'custom',
'task_name': 'custom',
'type': 'puppet',
'version': '1.0.0'
}
]
)