Sync metadata files for plugins immediately after installation
To avoid extra step with plugin sync, let's sync metadata files after installation by default Change-Id: I31f5b63a1ffe0e7cb39f823ea8870ff4a938ac17 Implements: blueprint role-as-a-plugin
This commit is contained in:
@@ -284,6 +284,10 @@ class Plugins(base.BaseObject):
|
||||
"""Checks all of the plugins on file systems,
|
||||
and makes sure that they have consistent information
|
||||
in API service.
|
||||
|
||||
:params plugin_ids: list of ids for plugins which should be synced
|
||||
:type plugin_ids: list
|
||||
:returns: None
|
||||
"""
|
||||
post_data = None
|
||||
if plugin_ids:
|
||||
@@ -316,7 +320,10 @@ class Plugins(base.BaseObject):
|
||||
version = plugin.version_from_file(plugin_path)
|
||||
|
||||
plugin.install(plugin_path, force=force)
|
||||
return cls.register(name, version, force=force)
|
||||
response = cls.register(name, version, force=force)
|
||||
cls.sync(plugin_ids=[response['id']])
|
||||
|
||||
return response
|
||||
|
||||
@classmethod
|
||||
def remove(cls, plugin_name, plugin_version):
|
||||
|
||||
@@ -216,16 +216,18 @@ class TestPluginsObject(base.UnitTestCase):
|
||||
get_mock.assert_called_once_with(self.name, self.version)
|
||||
del_mock.assert_called_once_with('plugins/123')
|
||||
|
||||
@patch.object(Plugins, 'sync')
|
||||
@patch.object(Plugins, 'register')
|
||||
@patch.object(Plugins, 'make_obj_by_file')
|
||||
def test_install(self, make_obj_by_file_mock, register_mock):
|
||||
def test_install(self, make_obj_by_file_mock, register_mock, sync_mock):
|
||||
plugin_obj = self.mock_make_obj_by_file(make_obj_by_file_mock)
|
||||
|
||||
register_mock.return_value = {'id': 1}
|
||||
self.plugin.install(self.path)
|
||||
|
||||
plugin_obj.install.assert_called_once_with(self.path, force=False)
|
||||
register_mock.assert_called_once_with(
|
||||
'retrieved_name', 'retrieved_version', force=False)
|
||||
sync_mock.assert_called_once_with(plugin_ids=[1])
|
||||
|
||||
@patch.object(Plugins, 'unregister')
|
||||
@patch.object(Plugins, 'make_obj_by_name')
|
||||
|
||||
Reference in New Issue
Block a user