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:
parent
371b5c978e
commit
b073a7837f
@ -37,6 +37,7 @@ class ChefInstaller(PKInstaller):
|
|||||||
ENV_TMPL_DIR = 'environments'
|
ENV_TMPL_DIR = 'environments'
|
||||||
NODE_TMPL_DIR = 'nodes'
|
NODE_TMPL_DIR = 'nodes'
|
||||||
DATABAG_TMPL_DIR = 'databags'
|
DATABAG_TMPL_DIR = 'databags'
|
||||||
|
TMPL_DIR = 'chef_installer/templates'
|
||||||
|
|
||||||
# keywords in package installer settings of adapter info
|
# keywords in package installer settings of adapter info
|
||||||
DATABAGS = "databags"
|
DATABAGS = "databags"
|
||||||
@ -64,7 +65,7 @@ class ChefInstaller(PKInstaller):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_tmpl_path(cls, adapter_name):
|
def get_tmpl_path(cls, adapter_name):
|
||||||
tmpl_path = os.path.join(
|
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
|
adapter_name
|
||||||
)
|
)
|
||||||
return tmpl_path
|
return tmpl_path
|
||||||
|
@ -59,7 +59,8 @@ class TestChefInstaller(unittest2.TestCase):
|
|||||||
|
|
||||||
ChefInstaller.get_tmpl_path = Mock()
|
ChefInstaller.get_tmpl_path = Mock()
|
||||||
test_tmpl_dir = os.path.join(
|
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'
|
'openstack_icehouse'
|
||||||
)
|
)
|
||||||
ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir
|
ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir
|
||||||
|
@ -24,6 +24,7 @@ reload(compass_setting)
|
|||||||
|
|
||||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
test_tmpl_dir = os.path.join(curr_dir, 'templates')
|
test_tmpl_dir = os.path.join(curr_dir, 'templates')
|
||||||
|
test_plugins_dir = curr_dir
|
||||||
|
|
||||||
test_chef_url = compass_setting.TEST_CHEF_URL
|
test_chef_url = compass_setting.TEST_CHEF_URL
|
||||||
test_client_key = compass_setting.TEST_CLIENT_KEY_PATH
|
test_client_key = compass_setting.TEST_CLIENT_KEY_PATH
|
||||||
|
@ -81,8 +81,8 @@ class TestChefInstaller(unittest2.TestCase):
|
|||||||
hosts_info)
|
hosts_info)
|
||||||
|
|
||||||
ChefInstaller.get_tmpl_path = Mock()
|
ChefInstaller.get_tmpl_path = Mock()
|
||||||
test_tmpl_dir = os.path.join(os.path.join(config_data.test_tmpl_dir,
|
test_tmpl_dir = os.path.join(os.path.join(config_data.test_plugins_dir,
|
||||||
'chef_installer'),
|
'chef_installer/templates'),
|
||||||
'openstack_icehouse')
|
'openstack_icehouse')
|
||||||
ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir
|
ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ MACHINE_LIST_DIR = ''
|
|||||||
PROGRESS_CALCULATOR_DIR = ''
|
PROGRESS_CALCULATOR_DIR = ''
|
||||||
OS_MAPPING_DIR = ''
|
OS_MAPPING_DIR = ''
|
||||||
FLAVOR_MAPPING_DIR = ''
|
FLAVOR_MAPPING_DIR = ''
|
||||||
|
PLUGINS_DIR = ''
|
||||||
|
|
||||||
if (
|
if (
|
||||||
'COMPASS_IGNORE_SETTING' in os.environ and
|
'COMPASS_IGNORE_SETTING' in os.environ and
|
||||||
@ -174,3 +174,6 @@ if not OS_MAPPING_DIR:
|
|||||||
|
|
||||||
if not FLAVOR_MAPPING_DIR:
|
if not FLAVOR_MAPPING_DIR:
|
||||||
FLAVOR_MAPPING_DIR = os.path.join(CONFIG_DIR, 'flavor_mapping')
|
FLAVOR_MAPPING_DIR = os.path.join(CONFIG_DIR, 'flavor_mapping')
|
||||||
|
|
||||||
|
if not PLUGINS_DIR:
|
||||||
|
PLUGINS_DIR = os.path.join(CONFIG_DIR, 'plugins')
|
||||||
|
@ -23,6 +23,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import setting_wrapper as setting
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -221,6 +222,10 @@ def load_configs(
|
|||||||
"""The plugins config_dir is formed as, for example /etc/compass/adapter"""
|
"""The plugins config_dir is formed as, for example /etc/compass/adapter"""
|
||||||
"""Then the plugins config_dir is /etc/compass/plugins/xxx/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 = []
|
configs = []
|
||||||
config_files = []
|
config_files = []
|
||||||
config_dir = str(config_dir)
|
config_dir = str(config_dir)
|
||||||
@ -234,7 +239,7 @@ def load_configs(
|
|||||||
|
|
||||||
"""search for plugins config_dir"""
|
"""search for plugins config_dir"""
|
||||||
index = config_dir.rfind("/")
|
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):
|
if os.path.exists(plugins_path):
|
||||||
for plugin in os.listdir(plugins_path):
|
for plugin in os.listdir(plugins_path):
|
||||||
plugin_path = os.path.join(plugins_path, plugin)
|
plugin_path = os.path.join(plugins_path, plugin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user