本文整理汇总了Python中nailgun.plugins.manager.PluginManager类的典型用法代码示例。如果您正苦于以下问题:Python PluginManager类的具体用法?Python PluginManager怎么用?Python PluginManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_raise_exception_when_plugin_overlap_release_component
def test_raise_exception_when_plugin_overlap_release_component(self):
release = self.env.create_release(
version='2015.1-8.1',
operating_system='Ubuntu',
modes=[consts.CLUSTER_MODES.ha_compact],
components_metadata=self.env.get_default_components())
self.env.create_plugin(
name='plugin_with_components',
package_version='4.0.0',
fuel_version=['8.0'],
releases=[{
'repository_path': 'repositories/ubuntu',
'version': '2015.1-8.1', 'os': 'ubuntu',
'mode': ['ha'],
'deployment_scripts_path': 'deployment_scripts/'}],
components_metadata=self.env.get_default_components())
expected_message = (
'Plugin plugin_with_components is overlapping with release '
'by introducing the same component with name '
'"hypervisor:test_hypervisor"')
with self.assertRaisesRegexp(errors.AlreadyExists,
expected_message):
PluginManager.get_components_metadata(release)
示例2: test_raise_exception_when_plugin_overlap_release_volumes
def test_raise_exception_when_plugin_overlap_release_volumes(self):
cluster = self.env.create_cluster(api=False)
plugin_name = 'test_plugin_3'
volumes_metadata = {
'volumes_roles_mapping': {
plugin_name: [
{'allocate_size': 'min', 'id': plugin_name}
]
},
'volumes': [
{'id': 'os', 'type': 'vg'},
{'id': plugin_name, 'type': 'vg'}
]
}
self.env.create_plugin(
api=True,
cluster=cluster,
name=plugin_name,
package_version='3.0.0',
fuel_version=['7.0'],
volumes_metadata=volumes_metadata
)
expected_message = (
'Plugin test_plugin_3-0.1.0 is overlapping with release '
'by introducing the same volume with id "os"')
with self.assertRaisesRegexp(errors.AlreadyExists,
expected_message):
PluginManager.get_volumes_metadata(cluster)
示例3: test_raise_exception_when_plugin_overlap_another_plugin_volumes
def test_raise_exception_when_plugin_overlap_another_plugin_volumes(self):
plugin_name = 'test_plugin_4'
volumes_metadata = {
'volumes_roles_mapping': {
plugin_name: [
{'allocate_size': 'min', 'id': plugin_name}
]
},
'volumes': [
{'id': 'test_plugin_2', 'type': 'vg'},
{'id': plugin_name, 'type': 'vg'}
]
}
self.env.create_plugin(
cluster=self.cluster,
name=plugin_name,
package_version='3.0.0',
fuel_version=['7.0'],
volumes_metadata=volumes_metadata
)
expected_message = (
'Plugin test_plugin_4-0.1.0 is overlapping with plugin '
'test_plugin_2-0.1.0 by introducing the same volume '
'with id "test_plugin_2"')
with self.assertRaisesRegexp(errors.AlreadyExists,
expected_message):
PluginManager.get_volumes_metadata(self.cluster)
示例4: patch_attributes
def patch_attributes(cls, instance, data):
PluginManager.process_cluster_attributes(instance, data['editable'])
instance.attributes.editable = dict_merge(
instance.attributes.editable, data['editable'])
cls.add_pending_changes(instance, "attributes")
cls.get_network_manager(instance).update_restricted_networks(instance)
db().flush()
示例5: update_attributes
def update_attributes(cls, instance, data):
PluginManager.process_cluster_attributes(instance, data['editable'])
for key, value in data.iteritems():
setattr(instance.attributes, key, value)
cls.add_pending_changes(instance, "attributes")
db().flush()
示例6: create_attributes
def create_attributes(cls, instance):
"""Create attributes for interface with default values.
:param instance: NodeNICInterface instance
:type instance: NodeNICInterface model
:returns: None
"""
instance.attributes = cls._get_default_attributes(instance)
PluginManager.add_plugin_attributes_for_interface(instance)
db().flush()
示例7: test_get_specific_version
def test_get_specific_version(self):
versions = [
{'metadata': {'plugin_id': '1'}},
{'metadata': {'plugin_id': '2'}}
]
plugin_version_attrs = PluginManager._get_specific_version(
versions, '1')
self.assertEqual(versions[0], plugin_version_attrs)
not_existed_plugin_version_attrs = PluginManager._get_specific_version(
versions, '3')
self.assertEqual({}, not_existed_plugin_version_attrs)
示例8: POST
def POST(self):
""":returns: JSONized REST object.
:http: * 200 (plugins successfully synced)
* 404 (plugin not found in db)
* 400 (problem with parsing metadata file)
"""
data = self.checked_data()
ids = data.get("ids", None)
try:
PluginManager.sync_plugins_metadata(plugin_ids=ids)
except errors.ParseError as exc:
raise self.http(400, msg=six.text_type(exc))
raise self.http(200)
示例9: update
def update(cls, instance, data):
"""Update data of native and plugin attributes for interface.
:param instance: NodeNICInterface instance
:type instance: NodeNICInterface model
:param data: Data to update
:type data: dict
:returns: instance of an object (model)
"""
attributes = data.pop('attributes', None)
if attributes:
PluginManager.update_nic_attributes(attributes)
instance.attributes = utils.dict_merge(
instance.attributes, attributes)
return super(NIC, cls).update(instance, data)
示例10: serialize
def serialize(self):
plugins = PluginManager.get_cluster_plugins_with_tasks(self.cluster)
return itertools.chain(
self.create_repositories(plugins),
self.sync_scripts(plugins),
self.deployment_tasks(plugins)
)
示例11: serialize
def serialize(self):
tasks = []
plugins = PluginManager.get_cluster_plugins_with_tasks(self.cluster)
tasks.extend(self.create_repositories(plugins))
tasks.extend(self.sync_scripts(plugins))
tasks.extend(self.deployment_tasks(plugins))
return tasks
示例12: validate_allowed_attributes
def validate_allowed_attributes(cls, cluster, data, force):
"""Validates if attributes are hot pluggable or not.
:param cluster: A cluster instance
:type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
:param data: Changed attributes of cluster
:type data: dict
:param force: Allow forcefully update cluster attributes
:type force: bool
:raises: errors.NotAllowed
"""
# TODO(need to enable restrictions check for cluster attributes[1])
# [1] https://bugs.launchpad.net/fuel/+bug/1519904
# Validates only that plugin can be installed on deployed env.
# If cluster is locked we have to check which attributes
# we want to change and block an entire operation if there
# one with always_editable=False.
if not cluster.is_locked or force:
return
editable_cluster = objects.Cluster.get_editable_attributes(
cluster, all_plugins_versions=True)
editable_request = data.get('editable', {})
for attr_name, attr_request in six.iteritems(editable_request):
attr_cluster = editable_cluster.get(attr_name, {})
meta_cluster = attr_cluster.get('metadata', {})
meta_request = attr_request.get('metadata', {})
if PluginManager.is_plugin_data(attr_cluster):
if meta_request['enabled']:
changed_ids = [meta_request['chosen_id']]
if meta_cluster['enabled']:
changed_ids.append(meta_cluster['chosen_id'])
changed_ids = set(changed_ids)
elif meta_cluster['enabled']:
changed_ids = [meta_cluster['chosen_id']]
else:
continue
for plugin in meta_cluster['versions']:
plugin_id = plugin['metadata']['plugin_id']
always_editable = plugin['metadata']\
.get('always_editable', False)
if plugin_id in changed_ids and not always_editable:
raise errors.NotAllowed(
"Plugin '{0}' version '{1}' couldn't be changed "
"after or during deployment."
.format(attr_name,
plugin['metadata']['plugin_version']),
log_message=True
)
elif not meta_cluster.get('always_editable', False):
raise errors.NotAllowed(
"Environment attribute '{0}' couldn't be changed "
"after or during deployment.".format(attr_name),
log_message=True
)
示例13: get_all_components
def get_all_components(cls, instance):
"""Get all components related to release
Due to components architecture compatible/incompatible are duplex
relations. So if some component is compatible/incompatible with another
the last one also should have such relation.
:param instance: Release instance
:type instance: Release DB instance
:returns: list -- list of all components
"""
plugin_components = PluginManager.get_components_metadata(instance)
components = copy.deepcopy(
instance.components_metadata + plugin_components)
# we should provide commutative property for compatible/incompatible
# relations between components
for comp_i, comp_j in itertools.permutations(components, 2):
if cls._check_relation(comp_j, comp_i, 'incompatible'):
comp_i.setdefault('incompatible', []).append({
'name': comp_j['name'],
'message': "Not compatible with {0}".format(
comp_j.get('label') or comp_j.get('name'))})
if cls._check_relation(comp_j, comp_i, 'compatible'):
comp_i.setdefault('compatible', []).append({
'name': comp_j['name']})
return components
示例14: get_network_roles
def get_network_roles(cls, instance):
"""Method for receiving network roles for particular cluster
:param instance: nailgun.db.sqlalchemy.models.Cluster instance
:returns: List of network roles' descriptions
"""
return instance.release.network_roles_metadata + PluginManager.get_network_roles(instance)
示例15: get_attributes
def get_attributes(cls, instance, all_plugins_versions=False):
"""Get attributes for current Cluster instance.
:param instance: Cluster instance
:param all_plugins_versions: Get attributes of all versions of plugins
:returns: dict
"""
try:
attrs = db().query(models.Attributes).filter(
models.Attributes.cluster_id == instance.id
).one()
except MultipleResultsFound:
raise errors.InvalidData(
u"Multiple rows with attributes were found for cluster '{0}'"
.format(instance.name)
)
except NoResultFound:
raise errors.InvalidData(
u"No attributes were found for cluster '{0}'"
.format(instance.name)
)
attrs = dict(attrs)
# Merge plugins attributes into editable ones
plugin_attrs = PluginManager.get_plugins_attributes(
instance, all_versions=all_plugins_versions)
plugin_attrs = traverse(plugin_attrs, AttributesGenerator, {
'cluster': instance,
'settings': settings,
})
attrs['editable'].update(plugin_attrs)
return attrs