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')