本文整理汇总了Python中nailgun.objects.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_all_newest
def test_all_newest(self):
for version in ['1.0.0', '2.0.0', '0.0.1']:
plugin_data = self.env.get_default_plugin_metadata(
version=version,
name='multiversion_plugin')
Plugin.create(plugin_data)
single_plugin_data = self.env.get_default_plugin_metadata(
name='single_plugin')
Plugin.create(single_plugin_data)
newest_plugins = PluginCollection.all_newest()
self.assertEqual(len(newest_plugins), 2)
single_plugin = filter(
lambda p: p.name == 'single_plugin',
newest_plugins)
multiversion_plugin = filter(
lambda p: p.name == 'multiversion_plugin',
newest_plugins)
self.assertEqual(len(single_plugin), 1)
self.assertEqual(len(multiversion_plugin), 1)
self.assertEqual(multiversion_plugin[0].version, '2.0.0')
开发者ID:TorstenS73,项目名称:fuel-web,代码行数:25,代码来源:test_object_plugin.py
示例2: setUp
def setUp(self):
super(TestMigrationPluginsClusterAttrs, self).setUp()
self.cluster = self.env.create()
self.plugins = [
Plugin.create(self.env.get_default_plugin_metadata(
name='plugin_name_1')),
Plugin.create(self.env.get_default_plugin_metadata(
name='plugin_name_2'))]
开发者ID:ekorekin,项目名称:fuel-web,代码行数:8,代码来源:test_migration_plugins_cluster_attrs_use_ids_mapping.py
示例3: test_get_metadata
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)
开发者ID:huyupeng,项目名称:fuel-web,代码行数:54,代码来源:test_plugin_adapters.py
示例4: test_get_metadata
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)
开发者ID:openstack,项目名称:fuel-web,代码行数:53,代码来源:test_plugin_adapters.py
示例5: validate
def validate(cls, data):
if data:
parsed = super(PluginSyncValidator, cls).validate(data)
cls.validate_schema(parsed, plugin.SYNC_SCHEMA)
# Check plugin with given id exists in DB
# otherwise raise ObjectNotFound exception
for plugin_id in parsed.get('ids'):
Plugin.get_by_uid(plugin_id, fail_if_not_found=True)
return parsed
else:
return {}
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:12,代码来源:plugin.py
示例6: _create_test_plugins
def _create_test_plugins(self):
plugin_ids = []
for version in ['1.0.0', '2.0.0', '0.0.1', '3.0.0']:
plugin_data = self.env.get_default_plugin_metadata(
version=version,
name='multiversion_plugin')
plugin = Plugin.create(plugin_data)
plugin_ids.append(plugin.id)
single_plugin_data = self.env.get_default_plugin_metadata(
name='single_plugin')
plugin = Plugin.create(single_plugin_data)
plugin_ids.append(plugin.id)
return plugin_ids
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:15,代码来源:test_object_plugin.py
示例7: setUp
def setUp(self):
super(TestNailgunReceiver, self).setUp()
self.env.create(
status=consts.CLUSTER_STATUSES.operational,
nodes_kwargs=[
{'roles': ['controller'],
'status': consts.NODE_STATUSES.ready}])
self.cluster = self.env.clusters[0]
for i in range(2):
meta = self.env.get_default_plugin_metadata(
name='name{0}'.format(i),
title='title{0}'.format(i),
description='description{0}'.format(i))
self.plugin = Plugin.create(meta)
self.cluster.plugins.append(self.plugin)
ClusterPlugins.set_attributes(self.cluster.id,
self.plugin.id,
enabled=True)
self.task = self.env.create_task(
name=consts.TASK_NAMES.deployment,
status=consts.TASK_STATUSES.ready,
cluster_id=self.cluster.id)
开发者ID:dnikishov,项目名称:fuel-web,代码行数:26,代码来源:test_receiver.py
示例8: test_add_nodes_for_cluster_plugin_with_empty_attributes
def test_add_nodes_for_cluster_plugin_with_empty_attributes(self):
meta = base.reflect_db_metadata()
self.env.create_node(
cluster_id=self.cluster.id,
roles=['compute']
)
plugin = Plugin.create({
'name': 'plugin_a_with_node_attributes',
'title': 'Test Plugin',
'package_version': '5.0.0',
'version': '1.0.0',
'node_attributes_metadata': {}
})
cluster_plugin = ClusterPlugin.create({
'cluster_id': self.cluster.id,
'plugin_id': plugin.id,
'enabled': False,
'attributes': plugin.node_attributes_metadata
})
NodeClusterPlugin.add_nodes_for_cluster_plugin(cluster_plugin)
node_cluster_plugins = self.db.execute(
meta.tables['node_cluster_plugins'].select()
).fetchall()
self.assertEqual(0, len(node_cluster_plugins))
开发者ID:openstack,项目名称:fuel-web,代码行数:26,代码来源:test_object_plugin.py
示例9: _create_test_plugins
def _create_test_plugins(self):
plugin_ids = []
for version in ["1.0.0", "2.0.0", "0.0.1", "3.0.0", "4.0.0", "5.0.0"]:
plugin_data = self.env.get_default_plugin_metadata(version=version, name="multiversion_plugin")
plugin = Plugin.create(plugin_data)
plugin_ids.append(plugin.id)
single_plugin_data = self.env.get_default_plugin_metadata(name="single_plugin")
plugin = Plugin.create(single_plugin_data)
plugin_ids.append(plugin.id)
incompatible_plugin_data = self.env.get_default_plugin_metadata(name="incompatible_plugin", releases=[])
plugin = Plugin.create(incompatible_plugin_data)
plugin_ids.append(plugin.id)
return plugin_ids
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:16,代码来源:test_object_plugin.py
示例10: setUp
def setUp(self):
super(TestClusterCompatibilityValidation, self).setUp()
self.plugin = Plugin.create(self.env.get_default_plugin_metadata(
releases=[{
'version': '2014.2-6.0',
'os': 'ubuntu',
'mode': ['ha']}]))
self.plugin_adapter = adapters.PluginAdapterV1(self.plugin)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:8,代码来源:test_plugin_adapters.py
示例11: setUp
def setUp(self):
super(TestClusterCompatiblityValidation, self).setUp()
self.plugin = Plugin.create(self.env.get_default_plugin_metadata(
releases=[{
'version': '2014.2-6.0',
'os': 'ubuntu',
'mode': ['ha']}]))
self.attr_plugin = attr_plugin.ClusterAttributesPluginV1(self.plugin)
开发者ID:nebril,项目名称:fuel-web,代码行数:8,代码来源:test_attributes_plugin.py
示例12: create_plugin
def create_plugin(self, api=False, cluster=None, **kwargs):
plugin_data = self.get_default_plugin_metadata()
plugin_data.update(kwargs)
if api:
resp = self.app.post(
reverse("PluginCollectionHandler"),
jsonutils.dumps(plugin_data),
headers=self.default_headers,
expect_errors=False,
)
plugin = Plugin.get_by_uid(resp.json_body["id"])
self.plugins.append(plugin)
else:
plugin = Plugin.create(plugin_data)
self.plugins.append(plugin)
# Enable plugin for specific cluster
if cluster:
cluster.plugins.append(plugin)
return plugin
开发者ID:thefuyang,项目名称:fuel-web,代码行数:23,代码来源:base.py
示例13: setUp
def setUp(self):
super(TestPluginBase, self).setUp()
self.plugin_metadata = self.env.get_default_plugin_metadata(
package_version=self.package_version,
roles_metadata={
'role_x': {
'name': 'Role X',
'description': 'Role X is ...',
},
'role_y': {
'name': 'Role Y',
'description': 'Role Y is ...',
'restrictions': [],
'fault_tolerance': '5%'
},
'role_z': {
'name': 'Role Z',
'description': 'Role Z is ...',
'restrictions': [
'settings:some.stuff.value == false'
],
'fault_tolerance': '10%'
}
}
)
self.plugin = Plugin.create(self.plugin_metadata)
self.cluster = self.env.create(
cluster_kwargs={'mode': consts.CLUSTER_MODES.multinode},
release_kwargs={
'version': '2015.1-8.0',
'operating_system': 'Ubuntu',
'modes': [consts.CLUSTER_MODES.multinode,
consts.CLUSTER_MODES.ha_compact]})
self.plugin_adapter = plugins.wrap_plugin(self.plugin)
self.env_config = self.env.get_default_plugin_env_config()
self.get_config = lambda *args: mock.mock_open(
read_data=yaml.dump(self.env_config))()
db().flush()
开发者ID:openstack,项目名称:fuel-web,代码行数:39,代码来源:test_plugin_adapters.py
示例14: test_graphs_creation
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'
}
]
)
开发者ID:openstack,项目名称:fuel-web,代码行数:90,代码来源:test_plugin_adapters.py
示例15: test_tags_saved_on_plugins_update
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)
开发者ID:openstack,项目名称:fuel-web,代码行数:5,代码来源:test_plugin_adapters.py
示例16: setUp
def setUp(self):
super(TestClusterCompatiblityValidation, self).setUp()
self.plugin = Plugin.create(self.env.get_default_plugin_metadata())
self.attr_plugin = attr_plugin.ClusterAttributesPlugin(self.plugin)
开发者ID:Zipfer,项目名称:fuel-web,代码行数:4,代码来源:test_attributes_plugin.py
注:本文中的nailgun.objects.Plugin类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论