本文整理汇总了Python中nailgun.objects.Plugin.update方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.update方法的具体用法?Python Plugin.update怎么用?Python Plugin.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Plugin
的用法示例。
在下文中一共展示了Plugin.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_metadata
# 需要导入模块: from nailgun.objects import Plugin [as 别名]
# 或者: from nailgun.objects.Plugin import update [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()
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()
mocked_metadata = {
self._find_path('metadata'): plugin_metadata,
self._find_path('environment_config'): attributes_metadata,
self._find_path('node_roles'): roles_metadata,
self._find_path('volumes'): volumes_metadata,
self._find_path('network_roles'): network_roles_metadata,
self._find_path('deployment_tasks'): deployment_tasks,
self._find_path('tasks'): tasks,
self._find_path('components'): components_metadata
}
with mock.patch.object(
self.plugin_adapter, '_load_config') as load_conf:
load_conf.side_effect = lambda key: mocked_metadata[key]
Plugin.update(self.plugin, self.plugin_adapter.get_metadata())
for key, val in six.iteritems(plugin_metadata):
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.volumes_metadata, volumes_metadata)
self.assertEqual(
self.plugin.tasks, tasks)
self.assertEqual(
self.plugin.components_metadata, components_metadata)
# 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/'
})
self.assertEqual(
self.plugin_adapter.get_deployment_tasks()[0][k],
v)
示例2: test_get_metadata
# 需要导入模块: from nailgun.objects import Plugin [as 别名]
# 或者: from nailgun.objects.Plugin import update [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()
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()
plugin_metadata.update({
'attributes_metadata': attributes_metadata,
'roles_metadata': roles_metadata,
'volumes_metadata': volumes_metadata,
'network_roles_metadata': network_roles_metadata,
'deployment_tasks': deployment_tasks,
'tasks': tasks,
'components_metadata': components_metadata
})
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(plugin_metadata):
if key 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.volumes_metadata, volumes_metadata)
self.assertEqual(
self.plugin.tasks, tasks)
self.assertEqual(
self.plugin.components_metadata, components_metadata)
# 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/'
})
self.assertEqual(
self.plugin_adapter.get_deployment_tasks()[0][k],
v)
示例3: test_graphs_creation
# 需要导入模块: from nailgun.objects import Plugin [as 别名]
# 或者: from nailgun.objects.Plugin import update [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'
}
]
)
示例4: test_tags_saved_on_plugins_update
# 需要导入模块: from nailgun.objects import Plugin [as 别名]
# 或者: from nailgun.objects.Plugin import update [as 别名]
def test_tags_saved_on_plugins_update(self):
Plugin.update(self.plugin,
{'roles_metadata': self.plugin.roles_metadata})
for role, meta in self.plugin.roles_metadata.items():
self.assertIn('tags', meta)