From 02d07a8ad1b5adcea5ead830496c848419599111 Mon Sep 17 00:00:00 2001 From: Carl Li Date: Wed, 28 Oct 2015 19:40:24 -0700 Subject: [PATCH] Seperate chef installer as a plugin (move chef_installer.py to plugins directory) Bug: 1506700 This is the third change list of a series of changes that will eventually convert chef installer as a plugin. It moves chef_installer.py to the plugins/chef_installer/implementation The related test was modified accordingly but should be moved to plugins directory in the next change list. Change-Id: Idb2a6f7f9b1e612d737674d811e9b4e6d7b6212b --- compass/deployment/installers/installer.py | 7 +++++++ .../pk_installers/chef_installer/__init__.py | 0 .../pk_installers/chef_installer/test_chef.py | 5 +++-- .../chef_installer/test_chef_installer.py | 5 +++-- plugins/__init__.py | 13 +++++++++++++ plugins/chef_installer/__init__.py | 13 +++++++++++++ plugins/chef_installer/implementation/__init__.py | 13 +++++++++++++ .../implementation}/chef_installer.py | 0 8 files changed, 52 insertions(+), 4 deletions(-) delete mode 100644 compass/deployment/installers/pk_installers/chef_installer/__init__.py create mode 100644 plugins/__init__.py create mode 100644 plugins/chef_installer/__init__.py create mode 100644 plugins/chef_installer/implementation/__init__.py rename {compass/deployment/installers/pk_installers/chef_installer => plugins/chef_installer/implementation}/chef_installer.py (100%) diff --git a/compass/deployment/installers/installer.py b/compass/deployment/installers/installer.py index 80af157c..99e074f2 100644 --- a/compass/deployment/installers/installer.py +++ b/compass/deployment/installers/installer.py @@ -25,6 +25,7 @@ import os import simplejson as json from compass.deployment.installers.config_manager import BaseConfigManager +from compass.utils import setting_wrapper as compass_setting from compass.utils import util @@ -272,6 +273,12 @@ class PKInstaller(BaseInstaller): return None path = os.path.join(cls.INSTALLER_BASE_DIR, name) + if not os.path.exists(path): + path = os.path.join(os.path.join(os.path.join( + compass_setting.PLUGINS_DIR, name), "implementation"), name) + if not os.path.exists(path): + logging.info("Installer '%s' is not existed!" % name) + return None installer = super(PKInstaller, cls).get_installer(name, path, adapter_info, cluster_info, diff --git a/compass/deployment/installers/pk_installers/chef_installer/__init__.py b/compass/deployment/installers/pk_installers/chef_installer/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/compass/tests/deployment/installers/pk_installers/chef_installer/test_chef.py b/compass/tests/deployment/installers/pk_installers/chef_installer/test_chef.py index 4b7c9b37..dbb2f392 100644 --- a/compass/tests/deployment/installers/pk_installers/chef_installer/test_chef.py +++ b/compass/tests/deployment/installers/pk_installers/chef_installer/test_chef.py @@ -33,12 +33,13 @@ reload(compass_setting) from compass.deployment.installers.config_manager import BaseConfigManager -from compass.deployment.installers.pk_installers.chef_installer.chef_installer\ - import ChefInstaller from compass.tests.deployment.test_data import config_data from compass.utils import flags from compass.utils import logsetting +# TODO(Carl) move this test to plugins +from plugins.chef_installer.implementation.chef_installer import ChefInstaller + class TestChefInstaller(unittest2.TestCase): """Test installer functionality.""" diff --git a/compass/tests_serverside/deployment/installers/pk_installers/chef_installer/test_chef_installer.py b/compass/tests_serverside/deployment/installers/pk_installers/chef_installer/test_chef_installer.py index 18f09c5c..f6e469ac 100644 --- a/compass/tests_serverside/deployment/installers/pk_installers/chef_installer/test_chef_installer.py +++ b/compass/tests_serverside/deployment/installers/pk_installers/chef_installer/test_chef_installer.py @@ -33,8 +33,9 @@ reload(compass_setting) from compass.deployment.installers.config_manager import BaseConfigManager -from compass.deployment.installers.pk_installers.chef_installer.chef_installer\ - import ChefInstaller + +# TODO(Carl) move this test to plugins +from plugins.chef_installer.implementation.chef_installer import ChefInstaller class TestChefInstaller(unittest2.TestCase): diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 00000000..4ee55a4c --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2014 Huawei Technologies Co. Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/plugins/chef_installer/__init__.py b/plugins/chef_installer/__init__.py new file mode 100644 index 00000000..4ee55a4c --- /dev/null +++ b/plugins/chef_installer/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2014 Huawei Technologies Co. Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/plugins/chef_installer/implementation/__init__.py b/plugins/chef_installer/implementation/__init__.py new file mode 100644 index 00000000..4ee55a4c --- /dev/null +++ b/plugins/chef_installer/implementation/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2014 Huawei Technologies Co. Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/compass/deployment/installers/pk_installers/chef_installer/chef_installer.py b/plugins/chef_installer/implementation/chef_installer.py similarity index 100% rename from compass/deployment/installers/pk_installers/chef_installer/chef_installer.py rename to plugins/chef_installer/implementation/chef_installer.py