From 37232fe05fbdc9be7cd28212d265849ce1f254e5 Mon Sep 17 00:00:00 2001 From: Andriy Popovych Date: Wed, 15 Jul 2015 11:29:25 +0300 Subject: [PATCH] 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 --- fuelclient/objects/plugins.py | 9 ++++++++- fuelclient/tests/v1/unit/test_plugins_object.py | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fuelclient/objects/plugins.py b/fuelclient/objects/plugins.py index 775e1cb..f9e4934 100644 --- a/fuelclient/objects/plugins.py +++ b/fuelclient/objects/plugins.py @@ -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): diff --git a/fuelclient/tests/v1/unit/test_plugins_object.py b/fuelclient/tests/v1/unit/test_plugins_object.py index d1a8a53..8ccc3ba 100644 --- a/fuelclient/tests/v1/unit/test_plugins_object.py +++ b/fuelclient/tests/v1/unit/test_plugins_object.py @@ -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')