diff --git a/compass/deployment/installers/pk_installers/chef_installer/chef_installer.py b/compass/deployment/installers/pk_installers/chef_installer/chef_installer.py index 2f798eb8..d0583b76 100644 --- a/compass/deployment/installers/pk_installers/chef_installer/chef_installer.py +++ b/compass/deployment/installers/pk_installers/chef_installer/chef_installer.py @@ -37,6 +37,7 @@ class ChefInstaller(PKInstaller): ENV_TMPL_DIR = 'environments' NODE_TMPL_DIR = 'nodes' DATABAG_TMPL_DIR = 'databags' + TMPL_DIR = 'chef_installer/templates' # keywords in package installer settings of adapter info DATABAGS = "databags" @@ -64,7 +65,7 @@ class ChefInstaller(PKInstaller): @classmethod def get_tmpl_path(cls, adapter_name): tmpl_path = os.path.join( - os.path.join(compass_setting.TMPL_DIR, 'chef_installer'), + os.path.join(compass_setting.PLUGINS_DIR, cls.TMPL_DIR), adapter_name ) return tmpl_path 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 6b349eb7..4b7c9b37 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 @@ -59,7 +59,8 @@ class TestChefInstaller(unittest2.TestCase): ChefInstaller.get_tmpl_path = Mock() test_tmpl_dir = os.path.join( - os.path.join(config_data.test_tmpl_dir, 'chef_installer'), + os.path.join(config_data.test_plugins_dir, + 'chef_installer/templates'), 'openstack_icehouse' ) ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/db_passwords.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/db_passwords.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/db_passwords.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/db_passwords.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/secrets.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/secrets.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/secrets.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/secrets.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/service_passwords.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/service_passwords.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/service_passwords.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/service_passwords.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/user_passwords.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/user_passwords.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/databags/user_passwords.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/databags/user_passwords.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/environments/base.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/environments/base.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/environments/base.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/environments/base.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/environments/multinodes.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/environments/multinodes.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/environments/multinodes.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/environments/multinodes.tmpl diff --git a/compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/nodes/os_compute_worker.tmpl b/compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/nodes/os_compute_worker.tmpl similarity index 100% rename from compass/tests/deployment/test_data/templates/chef_installer/openstack_icehouse/nodes/os_compute_worker.tmpl rename to compass/tests/deployment/test_data/chef_installer/templates/openstack_icehouse/nodes/os_compute_worker.tmpl diff --git a/compass/tests/deployment/test_data/config_data.py b/compass/tests/deployment/test_data/config_data.py index 44757f46..14896e61 100644 --- a/compass/tests/deployment/test_data/config_data.py +++ b/compass/tests/deployment/test_data/config_data.py @@ -24,6 +24,7 @@ reload(compass_setting) curr_dir = os.path.dirname(os.path.realpath(__file__)) test_tmpl_dir = os.path.join(curr_dir, 'templates') +test_plugins_dir = curr_dir test_chef_url = compass_setting.TEST_CHEF_URL test_client_key = compass_setting.TEST_CLIENT_KEY_PATH 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 bb924cc1..18f09c5c 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 @@ -81,8 +81,8 @@ class TestChefInstaller(unittest2.TestCase): hosts_info) ChefInstaller.get_tmpl_path = Mock() - test_tmpl_dir = os.path.join(os.path.join(config_data.test_tmpl_dir, - 'chef_installer'), + test_tmpl_dir = os.path.join(os.path.join(config_data.test_plugins_dir, + 'chef_installer/templates'), 'openstack_icehouse') ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir diff --git a/compass/utils/setting_wrapper.py b/compass/utils/setting_wrapper.py index 507710ef..3c659b44 100644 --- a/compass/utils/setting_wrapper.py +++ b/compass/utils/setting_wrapper.py @@ -98,7 +98,7 @@ MACHINE_LIST_DIR = '' PROGRESS_CALCULATOR_DIR = '' OS_MAPPING_DIR = '' FLAVOR_MAPPING_DIR = '' - +PLUGINS_DIR = '' if ( 'COMPASS_IGNORE_SETTING' in os.environ and @@ -174,3 +174,6 @@ if not OS_MAPPING_DIR: if not FLAVOR_MAPPING_DIR: FLAVOR_MAPPING_DIR = os.path.join(CONFIG_DIR, 'flavor_mapping') + +if not PLUGINS_DIR: + PLUGINS_DIR = os.path.join(CONFIG_DIR, 'plugins') diff --git a/compass/utils/util.py b/compass/utils/util.py index d61243e1..de1bcee1 100644 --- a/compass/utils/util.py +++ b/compass/utils/util.py @@ -23,6 +23,7 @@ import logging import os import os.path import re +import setting_wrapper as setting import sys import warnings @@ -221,6 +222,10 @@ def load_configs( """The plugins config_dir is formed as, for example /etc/compass/adapter""" """Then the plugins config_dir is /etc/compass/plugins/xxx/adapter""" + # TODO(Carl) instead of using config_dir, it should use a name such as + # adapter etc, however, doing it requires a lot client sites changes, + # will do it later. + configs = [] config_files = [] config_dir = str(config_dir) @@ -234,7 +239,7 @@ def load_configs( """search for plugins config_dir""" index = config_dir.rfind("/") - plugins_path = os.path.join(config_dir[0:index], "plugins") + plugins_path = setting.PLUGINS_DIR if os.path.exists(plugins_path): for plugin in os.listdir(plugins_path): plugin_path = os.path.join(plugins_path, plugin) diff --git a/conf/templates/chef_installer/ceph_firefly/environments/base.tmpl b/plugins/chef_installer/templates/ceph_firefly/environments/base.tmpl similarity index 100% rename from conf/templates/chef_installer/ceph_firefly/environments/base.tmpl rename to plugins/chef_installer/templates/ceph_firefly/environments/base.tmpl diff --git a/conf/templates/chef_installer/ceph_openstack_icehouse/environments/base.tmpl b/plugins/chef_installer/templates/ceph_openstack_icehouse/environments/base.tmpl similarity index 100% rename from conf/templates/chef_installer/ceph_openstack_icehouse/environments/base.tmpl rename to plugins/chef_installer/templates/ceph_openstack_icehouse/environments/base.tmpl diff --git a/conf/templates/chef_installer/ceph_openstack_icehouse/environments/ha_multinodes.tmpl b/plugins/chef_installer/templates/ceph_openstack_icehouse/environments/ha_multinodes.tmpl similarity index 100% rename from conf/templates/chef_installer/ceph_openstack_icehouse/environments/ha_multinodes.tmpl rename to plugins/chef_installer/templates/ceph_openstack_icehouse/environments/ha_multinodes.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/databags/db_passwords.tmpl b/plugins/chef_installer/templates/openstack_icehouse/databags/db_passwords.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/databags/db_passwords.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/databags/db_passwords.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/databags/secrets.tmpl b/plugins/chef_installer/templates/openstack_icehouse/databags/secrets.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/databags/secrets.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/databags/secrets.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/databags/service_passwords.tmpl b/plugins/chef_installer/templates/openstack_icehouse/databags/service_passwords.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/databags/service_passwords.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/databags/service_passwords.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/databags/user_passwords.tmpl b/plugins/chef_installer/templates/openstack_icehouse/databags/user_passwords.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/databags/user_passwords.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/databags/user_passwords.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/environments/base.tmpl b/plugins/chef_installer/templates/openstack_icehouse/environments/base.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/environments/base.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/environments/base.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/environments/fusionsphere.tmpl b/plugins/chef_installer/templates/openstack_icehouse/environments/fusionsphere.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/environments/fusionsphere.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/environments/fusionsphere.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/environments/ha_multinodes.tmpl b/plugins/chef_installer/templates/openstack_icehouse/environments/ha_multinodes.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/environments/ha_multinodes.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/environments/ha_multinodes.tmpl diff --git a/conf/templates/chef_installer/openstack_icehouse/nodes/os_compute_worker.tmpl b/plugins/chef_installer/templates/openstack_icehouse/nodes/os_compute_worker.tmpl similarity index 100% rename from conf/templates/chef_installer/openstack_icehouse/nodes/os_compute_worker.tmpl rename to plugins/chef_installer/templates/openstack_icehouse/nodes/os_compute_worker.tmpl