From d800d968b1e3749b0e545ac352f4a561cffaa4a5 Mon Sep 17 00:00:00 2001 From: "Vladimir Sharshov (warpc)" Date: Thu, 2 Apr 2015 14:57:31 +0300 Subject: [PATCH] Fuel plugin install --force now can install new plugin Without this changes fuel return error if you will try to install new plugin using install with --force Change-Id: Id3b2966f78bf24bb47f05b7d0a02bb101b7843b5 Closes-Bug: #1439128 --- fuelclient/objects/plugins.py | 9 +++++---- fuelclient/tests/v1/unit/test_plugins_object.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fuelclient/objects/plugins.py b/fuelclient/objects/plugins.py index ce3ed10..6685dc6 100644 --- a/fuelclient/objects/plugins.py +++ b/fuelclient/objects/plugins.py @@ -180,11 +180,12 @@ class PluginV2(BasePlugin): @classmethod @master_only def install(cls, plugin_path, force=False): - action = 'install' if force: - action = 'reinstall' - - utils.exec_cmd('yum -y {0} {1}'.format(action, plugin_path)) + utils.exec_cmd( + 'yum -y install {0} || yum -y reinstall {0}' + .format(plugin_path)) + else: + utils.exec_cmd('yum -y install {0}'.format(plugin_path)) @classmethod @master_only diff --git a/fuelclient/tests/v1/unit/test_plugins_object.py b/fuelclient/tests/v1/unit/test_plugins_object.py index b556aa9..444d4fa 100644 --- a/fuelclient/tests/v1/unit/test_plugins_object.py +++ b/fuelclient/tests/v1/unit/test_plugins_object.py @@ -122,7 +122,9 @@ class TestPluginV2(base.UnitTestCase): def test_install_w_force(self, exec_mock, master_only_mock): self.plugin.install(self.path, force=True) - exec_mock.assert_called_once_with('yum -y reinstall /tmp/plugin/path') + exec_mock.assert_called_once_with( + 'yum -y install /tmp/plugin/path' + ' || yum -y reinstall /tmp/plugin/path') master_only_mock.assert_called_once_with() @patch('fuelclient.objects.plugins.utils.exec_cmd')