Seperate chef installer as a plugin (move chef templates to plugins directory)

Bug: 1506700

This is the second change list of a series of changes that will eventually
convert chef installer as a plugin.
It moves chef installer related templates files to the plugins/chef_installer/templats
PLUGINS_DIR was introduced to indicate where the plugins directory will be, it may be in /etc/compass or in a different place util.py's load_configs will use it when reading plugins configs.

Change-Id: Ieb599e3e7c8cecd8355e77d89e3da8548f78a93a
This commit is contained in:
Carl Li 2015-10-24 18:05:39 -07:00
parent 371b5c978e
commit b073a7837f
24 changed files with 17 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

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