support testmode in chef

Change-Id: I9c43ff2aaf3ae96aa4ef826e0a0caddffffbaba2
This commit is contained in:
xiaodongwang 2014-04-15 19:33:14 -07:00 committed by Gerrit Code Review
parent a5867abbc6
commit 36a7843d6d
29 changed files with 3447 additions and 860 deletions

View File

@ -45,7 +45,10 @@ def main():
databag_items = []
databagitem_dir = os.path.join(databags_dir, databag)
for item in os.listdir(databagitem_dir):
databag_items.append(os.path.join(databagitem_dir, item))
if item.endswith('.json'):
databag_items.append(os.path.join(databagitem_dir, item))
else:
logging.info('ignore %s in %s', item, databagitem_dir)
for databag_item in databag_items:
logging.info('add databag item %s to databag %s',

View File

@ -37,8 +37,10 @@ def main():
roles_dir = flags.OPTIONS.roles_dir
for item in os.listdir(roles_dir):
role_file = os.path.join(roles_dir, item)
rolelist.append(role_file)
if item.endswith('.rb'):
rolelist.append(os.path.join(roles_dir, item))
else:
logging.info('ignore %s in %s', item, roles_dir)
for role in rolelist:
logging.info('add role %s', role)

View File

@ -19,6 +19,7 @@
import fnmatch
import functools
import logging
import traceback
from compass.config_management.installers import package_installer
from compass.config_management.utils.config_translator import ConfigTranslator
@ -28,6 +29,50 @@ from compass.utils import setting_wrapper as setting
from compass.utils import util
FROM_GLOBAL_TRANSLATORS = {
'openstack': ConfigTranslator(
mapping={
'/read_config_mapping': [KeyTranslator(
translated_keys=(
config_translator_callbacks.get_keys_from_config_mapping),
translated_value=(
config_translator_callbacks.get_value_from_config_mapping)
)],
}
),
}
TO_GLOBAL_TRANSLATORS = {
'openstack': ConfigTranslator(
mapping={
'/test_roles/*': [KeyTranslator(
translated_keys=[
functools.partial(
config_translator_callbacks.get_key_from_pattern,
from_pattern=r'^/test_roles/(?P<role>.*)$',
to_pattern=(
'/role_assign_policy/default'
'/dependencies/%(role)s'
)
)
],
from_values={'testmode': '/testmode'},
translated_value=functools.partial(
config_translator_callbacks.add_value,
check_value_callback=(
lambda value, value_list: (
set(value) & set(value_list))
),
add_value_callback=(
lambda value, value_list: value_list.extend(value)
)
),
override=True
)],
}
),
}
TO_CLUSTER_TRANSLATORS = {
'openstack': ConfigTranslator(
mapping={
@ -36,12 +81,19 @@ TO_CLUSTER_TRANSLATORS = {
config_translator_callbacks.get_keys_from_config_mapping),
translated_value=(
config_translator_callbacks.get_value_from_config_mapping)
)]
)],
'/testmode': [KeyTranslator(
translated_keys=['/debugging/debug', '/debugging/verbose'],
translated_value=functools.partial(
config_translator_callbacks.set_value,
return_value_callback=lambda value: str(value)
),
override=True
)],
}
),
}
FROM_CLUSTER_TRANSLATORS = {
'openstack': ConfigTranslator(
mapping={
@ -54,12 +106,6 @@ FROM_CLUSTER_TRANSLATORS = {
'/role_mapping': [KeyTranslator(
translated_keys=['/role_mapping']
)],
'/read_config_mapping': [KeyTranslator(
translated_keys=(
config_translator_callbacks.get_keys_from_config_mapping),
translated_value=(
config_translator_callbacks.get_value_from_config_mapping)
)],
}
),
}
@ -132,11 +178,13 @@ class Installer(package_installer.Installer):
NAME = 'chef'
def __init__(self, **kwargs):
super(Installer, self).__init__(**kwargs)
import chef
super(Installer, self).__init__(**kwargs)
self.installer_url_ = setting.CHEF_INSTALLER_URL
self.global_databag_name_ = setting.CHEF_GLOBAL_DATABAG_NAME
self.api_ = chef.autoconfigure()
self.tmp_databags_ = {}
self.tmp_databag_items_ = {}
logging.debug('%s instance created', self)
def __repr__(self):
@ -145,56 +193,92 @@ class Installer(package_installer.Installer):
self.global_databag_name_)
@classmethod
def _cluster_databag_name(cls, clusterid, target_system):
def _cluster_databag_name(cls, clusterid):
"""get cluster databag name."""
return '%s_%s' % (target_system, clusterid)
return '%s' % clusterid
@classmethod
def _get_client_name(cls, fullname, target_system):
def _get_client_name(cls, fullname):
"""get client name."""
return cls._get_node_name(fullname, target_system)
return cls._get_node_name(fullname)
def _clean_host_attributes(self, config, target_system):
"""clean node attributes about target system."""
import chef
node_name = self._get_node_name(config['fullname'])
client_name = self._get_client_name(config['fullname'])
node = chef.Node(node_name, api=self.api_)
roles_per_target_system = node.get('roles_per_target_system', {})
if target_system in roles_per_target_system:
del roles_per_target_system[target_system]
node['roles_per_target_system'] = roles_per_target_system
if not roles_per_target_system:
try:
node.delete()
client = chef.Client(client_name, api=self.api_)
client.delete()
logging.debug(
'delete %s for host %s ', target_system, node_name)
except Exception:
logging.debug(
'failed to delete %s for host %s: %s',
target_system, node_name,
''.join(traceback.format_stack()))
else:
node.run_list = []
for _, roles in node['roles'].items():
for role in roles:
node.run_list.append('role[%s]' % role)
node.save()
logging.debug('node %s is updated for %s',
node_name, target_system)
def _update_host_attributes(self, config, target_system):
"""chef manage node attributes."""
from chef import Node
roles = config['roles']
node_name = "%s.%s" % (target_system, config['fullname'])
node = Node(node_name, api=self.api_)
node['cluster'] = self._cluster_databag_name(
config['clusterid'],
target_system)
"""chef manage node attributes about target system."""
import chef
node_name = self._get_node_name(config['fullname'])
node = chef.Node(node_name, api=self.api_)
node['cluster'] = self._cluster_databag_name(config['clusterid'])
roles_per_target_system = node.get('roles_per_target_system', {})
roles_per_target_system[target_system] = config['roles']
node['roles_per_target_system'] = roles_per_target_system
node.run_list = []
for _, roles in roles_per_target_system.items():
for role in roles:
node.run_list.append('role[%s]' % role)
for role in roles:
node.run_list.append('role[%s]' % role)
node.save()
logging.debug('update %s for host %s',
target_system, node_name)
@classmethod
def _get_node_name(cls, fullname, target_system):
def _get_node_name(cls, fullname):
"""get node name."""
return '%s.%s' % (target_system, fullname)
return fullname
def os_installer_config(self, config, target_system, **kwargs):
"""get os installer config."""
return {
'%s_url' % self.NAME: self.installer_url_,
'chef_client_name': self._get_client_name(
config['fullname'], target_system),
'chef_node_name': self._get_node_name(
config['fullname'], target_system)
'chef_client_name': self._get_client_name(config['fullname']),
'chef_node_name': self._get_node_name(config['fullname'])
}
def get_target_systems(self, oses):
"""get target systems."""
from chef import DataBag
databags = DataBag.list(api=self.api_)
import chef
databags = chef.DataBag.list(api=self.api_)
target_systems = {}
for os_version in oses:
target_systems[os_version] = []
for databag in databags:
target_system = databag
global_databag_item = self._get_global_databag_item(
self._get_databag(target_system))
global_databag_item = self._get_global_databag_item(target_system)
support_oses = global_databag_item['support_oses']
for os_version in oses:
for support_os in support_oses:
@ -206,148 +290,181 @@ class Installer(package_installer.Installer):
def get_roles(self, target_system):
"""get supported roles."""
global_databag_item = self._get_global_databag_item(
self._get_databag(target_system))
global_databag_item = self._get_global_databag_item(target_system)
return global_databag_item['all_roles']
def _get_databag(self, target_system):
"""get databag."""
import chef
return chef.DataBag(target_system, api=self.api_)
if target_system not in self.tmp_databags_:
self.tmp_databags_[target_system] = chef.DataBag(
target_system, api=self.api_)
def _get_databag_item(self, bag, bag_item_name):
return self.tmp_databags_[target_system]
def _get_databag_item(self, target_system, bag_item_name):
"""get databag item."""
from chef import DataBagItem
return DataBagItem(bag, bag_item_name, api=self.api_)
import chef
databag_items = self.tmp_databag_items_.setdefault(
target_system, {})
if bag_item_name not in databag_items:
databag = self._get_databag(target_system)
databag_items[bag_item_name] = chef.DataBagItem(
databag, bag_item_name, api=self.api_)
def _get_global_databag_item(self, bag):
return dict(databag_items[bag_item_name])
def _update_databag_item(
self, target_system, bag_item_name, config, save=True
):
"""update databag item."""
import chef
databag_items = self.tmp_databag_items_.setdefault(
target_system, {})
if bag_item_name not in databag_items:
databag = self._get_databag(target_system)
databag_items[bag_item_name] = chef.DataBagItem(
databag, bag_item_name, api=self.api_)
bag_item = databag_items[bag_item_name]
for key, value in config.items():
bag_item[key] = value
if save:
bag_item.save()
logging.debug('save databag item %s to target system %s',
bag_item_name, target_system)
else:
logging.debug(
'ignore saving databag item %s to target system %s',
bag_item_name, target_system)
def _clean_databag_item(self, target_system, bag_item_name):
"""clean databag item."""
import chef
databag_items = self.tmp_databag_items_.setdefault(
target_system, {})
if bag_item_name not in databag_items:
databag = self._get_databag(target_system)
databag_items[bag_item_name] = chef.DataBagItem(
databag, bag_item_name, api=self.api_)
bag_item = databag_items[bag_item_name]
try:
bag_item.delete()
logging.debug(
'databag item %s is removed from target_system %s',
bag_item_name, target_system)
except Exception:
logging.debug(
'no databag item %s to delete from target_system %s: %s',
bag_item_name, target_system,
''.join(traceback.format_stack()))
del databag_items[bag_item_name]
def _get_global_databag_item(self, target_system):
"""get global databag item."""
return self._get_databag_item(
bag, self.global_databag_name_)
target_system, self.global_databag_name_)
def _get_cluster_databag_item(self, bag, clusterid, target_system):
def _clean_global_databag_item(self, target_system):
"""clean global databag item."""
self._clean_databag_item(
target_system, self.global_databag_name_)
def _update_global_databag_item(self, target_system, config):
"""update global databag item."""
self._update_databag_item(
target_system, self.global_databag_name_, config, save=False)
def _get_cluster_databag_item(self, target_system, clusterid):
"""get cluster databag item."""
return self._get_databag_item(
bag, self._cluster_databag_name(clusterid, target_system))
target_system, self._cluster_databag_name(clusterid))
def _clean_cluster_databag_item(self, target_system, clusterid):
"""clean cluster databag item."""
self._clean_databag_item(
target_system, self._cluster_databag_name(clusterid))
def _update_cluster_databag_item(self, target_system, clusterid, config):
"""update cluster databag item."""
self._update_databag_item(
target_system, self._cluster_databag_name(clusterid),
config, save=True)
def get_global_config(self, target_system, **kwargs):
"""get global config."""
bag_item = self._get_global_databag_item(target_system)
return FROM_GLOBAL_TRANSLATORS[target_system].translate(bag_item)
def get_cluster_config(self, clusterid, target_system, **kwargs):
"""get cluster config."""
bag = self._get_databag(target_system)
global_bag_item = dict(self._get_global_databag_item(bag))
bag_item = dict(self._get_cluster_databag_item(
bag, clusterid, target_system))
util.merge_dict(bag_item, global_bag_item, False)
global_bag_item = self._get_global_databag_item(
target_system)
cluster_bag_item = self._get_cluster_databag_item(
target_system, clusterid)
util.merge_dict(cluster_bag_item, global_bag_item, False)
return FROM_CLUSTER_TRANSLATORS[target_system].translate(bag_item)
return FROM_CLUSTER_TRANSLATORS[target_system].translate(
cluster_bag_item)
def clean_cluster_config(self, clusterid, config,
target_system, **kwargs):
"""clean cluster config."""
try:
bag = self._get_databag(target_system)
bag_item = self._get_cluster_databag_item(
bag, clusterid, target_system)
bag_item.delete()
logging.debug('databag item is removed for cluster %s '
'config %s target_system %s',
clusterid, config, target_system)
except Exception:
logging.debug('no databag item to delete for cluster %s '
'config %s target_system %s',
clusterid, config, target_system)
self._clean_cluster_databag_item(target_system, clusterid)
def update_global_config(self, config, target_system, **kwargs):
"""update global config."""
global_bag_item = self._get_global_databag_item(target_system)
translated_config = TO_GLOBAL_TRANSLATORS[target_system].translate(
config)
util.merge_dict(global_bag_item, translated_config, True)
self._update_global_databag_item(target_system, global_bag_item)
def update_cluster_config(self, clusterid, config,
target_system, **kwargs):
"""update cluster config."""
self.clean_cluster_config(clusterid, config,
target_system, **kwargs)
bag = self._get_databag(target_system)
global_bag_item = dict(self._get_global_databag_item(bag))
bag_item = self._get_cluster_databag_item(
bag, clusterid, target_system)
bag_item_dict = dict(bag_item)
util.merge_dict(bag_item_dict, global_bag_item, False)
global_bag_item = self._get_global_databag_item(target_system)
cluster_bag_item = self._get_cluster_databag_item(
target_system, clusterid)
util.merge_dict(cluster_bag_item, global_bag_item, False)
translated_config = TO_CLUSTER_TRANSLATORS[target_system].translate(
config)
util.merge_dict(bag_item_dict, translated_config)
for key, value in bag_item_dict.items():
bag_item[key] = value
bag_item.save()
def _clean_client(self, hostid, config, target_system, **kwargs):
"""clean client."""
from chef import Client
try:
client = Client(
self._get_client_name(
config['fullname'], target_system),
api=self.api_)
client.delete()
logging.debug('client is removed for host %s '
'config %s target_system %s',
hostid, config, target_system)
except Exception:
logging.debug('no client to delete for host %s '
'config %s target_system %s',
hostid, config, target_system)
def _clean_node(self, hostid, config, target_system, **kwargs):
"""clean node."""
from chef import Node
try:
node = Node(
self._get_node_name(
config['fullname'], target_system),
api=self.api_
)
node.delete()
logging.debug('node is removed for host %s '
'config %s target_system %s',
hostid, config, target_system)
except Exception:
logging.debug('no node to delete for host %s '
'config %s target_system %s',
hostid, config, target_system)
util.merge_dict(cluster_bag_item, translated_config, True)
self._update_cluster_databag_item(
target_system, clusterid, cluster_bag_item)
def clean_host_config(self, hostid, config, target_system, **kwargs):
"""clean host config."""
self._clean_client(hostid, config, target_system, **kwargs)
self._clean_node(hostid, config, target_system, **kwargs)
self._clean_host_attributes(config, target_system)
def reinstall_host(self, hostid, config, target_system, **kwargs):
"""reinstall host."""
self._clean_client(hostid, config, target_system, **kwargs)
self._clean_node(hostid, config, target_system, **kwargs)
self._clean_host_attributes(config, target_system)
self._update_host_attributes(config, target_system)
def update_host_config(self, hostid, config, target_system, **kwargs):
"""update host cnfig."""
self.clean_host_config(hostid, config,
target_system=target_system, **kwargs)
"""update host config."""
clusterid = config['clusterid']
bag = self._get_databag(target_system)
global_bag_item = dict(self._get_global_databag_item(bag))
bag_item = self._get_cluster_databag_item(
bag, clusterid, target_system)
bag_item_dict = dict(bag_item)
util.merge_dict(bag_item_dict, global_bag_item, False)
global_bag_item = self._get_global_databag_item(target_system)
cluster_bag_item = self._get_cluster_databag_item(
target_system, clusterid)
util.merge_dict(cluster_bag_item, global_bag_item, False)
util.merge_dict(config, {
'client_name': self._get_client_name(
config['fullname'], target_system),
'node_name': self._get_node_name(
config['fullname'], target_system)
'client_name': self._get_client_name(config['fullname']),
'node_name': self._get_node_name(config['fullname'])
})
translated_config = TO_HOST_TRANSLATORS[target_system].translate(
config)
util.merge_dict(bag_item_dict, translated_config)
for key, value in bag_item_dict.items():
bag_item[key] = value
bag_item.save()
util.merge_dict(cluster_bag_item, translated_config, True)
self._update_cluster_databag_item(
target_system, clusterid, cluster_bag_item)
self._update_host_attributes(config, target_system)
package_installer.register(Installer)

View File

@ -118,9 +118,15 @@ TO_HOST_TRANSLATOR = ConfigTranslator(
should_exist='management')
), KeyTranslator(
translated_keys=['/ksmeta/promisc_nics'],
from_values={'condition': '../promisc'},
translated_value=config_translator_callbacks.add_value,
override=True,
from_values={'promisc': '../promisc'},
translated_value=functools.partial(
config_translator_callbacks.add_value,
get_value_callback=lambda config: [
value for value in config.split(',') if value
],
return_value_callback=lambda values: ','.join(values)
),
override=True
)],
}
)
@ -270,7 +276,6 @@ class Installer(os_installer.Installer):
def update_host_config(self, hostid, config, **kwargs):
"""update host config."""
self.clean_host_config(hostid, config, **kwargs)
profile = self._get_profile(**kwargs)
sys_id = self._get_system(config)
system_config = self._get_modify_system(

View File

@ -21,6 +21,7 @@ import os.path
from compass.config_management.providers import config_provider
from compass.config_management.utils import config_filter
from compass.config_management.utils import config_filter_callbacks
from compass.db import database
from compass.db.model import Adapter
from compass.db.model import Cluster
@ -35,16 +36,49 @@ from compass.db.model import SwitchConfig
from compass.utils import setting_wrapper as setting
CLUSTER_ALLOWS = ['/security', '/networking', '/partition']
CLUSTER_DENIES = []
HOST_ALLOWS = [
'/roles',
'/has_dashboard_roles',
'/dashboard_roles',
'/haproxy_roles',
'/networking/interfaces/*/ip'
]
HOST_DENIES = []
GET_CLUSTER_ALLOWS = {
'*': config_filter.AllowRule()
}
GET_CLUSTER_DENIES = {
'/networking/global/ha_vip': config_filter.DenyRule(
check=config_filter_callbacks.deny_if_empty)
}
GET_HOST_ALLOWS = {
'*': config_filter.AllowRule()
}
GET_HOST_DENIES = {
'/roles': config_filter.DenyRule(
check=config_filter_callbacks.deny_if_empty
),
'/dashboard_roles': config_filter.DenyRule(
check=config_filter_callbacks.deny_if_empty
),
'/haproxy_roles': config_filter.DenyRule(
check=config_filter_callbacks.deny_if_empty
),
}
UPDATE_CLUSTER_ALLOWS = {
'/security': config_filter.AllowRule(),
'/networking': config_filter.AllowRule(),
'/partition': config_filter.AllowRule()
}
UPDATE_CLUSTER_DENIES = {
'/networking/global/ha_vip': config_filter.DenyRule(
check=config_filter_callbacks.deny_if_empty)
}
UPDATE_HOST_ALLOWS = {
'/roles': config_filter.AllowRule(
check=config_filter_callbacks.allow_if_not_empty),
'/has_dashboard_roles': config_filter.AllowRule(),
'/dashboard_roles': config_filter.AllowRule(
check=config_filter_callbacks.allow_if_not_empty
),
'/haproxy_roles': config_filter.AllowRule(
check=config_filter_callbacks.allow_if_not_empty
),
'/networking/interfaces/*/ip': config_filter.AllowRule()
}
UPDATE_HOST_DENIES = {}
class DBProvider(config_provider.ConfigProvider):
@ -55,10 +89,14 @@ class DBProvider(config_provider.ConfigProvider):
session scope.
"""
NAME = 'db'
CLUSTER_FILTER = config_filter.ConfigFilter(
CLUSTER_ALLOWS, CLUSTER_DENIES)
HOST_FILTER = config_filter.ConfigFilter(
HOST_ALLOWS, HOST_DENIES)
GET_CLUSTER_FILTER = config_filter.ConfigFilter(
GET_CLUSTER_ALLOWS, GET_CLUSTER_DENIES)
GET_HOST_FILTER = config_filter.ConfigFilter(
GET_HOST_ALLOWS, GET_HOST_DENIES)
UPDATE_CLUSTER_FILTER = config_filter.ConfigFilter(
UPDATE_CLUSTER_ALLOWS, UPDATE_CLUSTER_DENIES)
UPDATE_HOST_FILTER = config_filter.ConfigFilter(
UPDATE_HOST_ALLOWS, UPDATE_HOST_DENIES)
def __init__(self):
pass
@ -67,20 +105,29 @@ class DBProvider(config_provider.ConfigProvider):
"""Get cluster config from db."""
session = database.current_session()
cluster = session.query(Cluster).filter_by(id=clusterid).first()
if cluster:
return cluster.config
else:
if not cluster:
return {}
return self.GET_CLUSTER_FILTER.filter(cluster.config)
def get_host_config(self, hostid):
"""Get host config from db."""
session = database.current_session()
host = session.query(ClusterHost).filter_by(id=hostid).first()
if host:
return host.config
else:
if not host:
return {}
return self.GET_HOST_FILTER.filter(host.config)
def update_cluster_config(self, clusterid, config):
"""Update cluster config to db."""
session = database.current_session()
cluster = session.query(Cluster).filter_by(id=clusterid).first()
if not cluster:
return
cluster.config = self.UPDATE_CLUSTER_FILTER.filter(config)
def update_host_config(self, hostid, config):
"""Update host config to db."""
session = database.current_session()
@ -88,8 +135,7 @@ class DBProvider(config_provider.ConfigProvider):
if not host:
return
filtered_config = self.HOST_FILTER.filter(config)
host.config = filtered_config
host.config = self.UPDATE_HOST_FILTER.filter(config)
def update_adapters(self, adapters, roles_per_target_system):
"""Update adapter config to db."""

View File

@ -61,6 +61,8 @@ class FileProvider(config_provider.ConfigProvider):
config_globals = {}
config_locals = {}
content = ''
logging.debug('read config from %s and format is %s',
filename, config_format)
try:
with open(filename) as file_handler:
content = file_handler.read()

View File

@ -21,16 +21,44 @@ import logging
from compass.config_management.utils import config_reference
class AllowRule(object):
"""class to define allow rule."""
def __init__(self, check=None):
self.check_ = check
def allow(self, key, ref):
"""Check if the ref is OK to add to filtered config."""
if not self.check_:
return True
else:
return self.check_(key, ref)
class DenyRule(object):
def __init__(self, check=None):
self.check_ = check
def deny(self, key, ref):
"""Check if the ref is OK to del from filtered config."""
if not self.check_:
return True
else:
return self.check_(key, ref)
class ConfigFilter(object):
"""config filter based on allows and denies rules."""
def __init__(self, allows=['*'], denies=[]):
def __init__(self, allows={'*': AllowRule()}, denies={}):
"""Constructor
:param allows: glob path to copy to the filtered configuration.
:type allows: list of str
:param denies: glob path to remove from the filtered configuration.
:type denies: list of str
:param allows: dict of glob path and allow rule to copy to the
filtered configuration.
:type allows: dict of str to AllowRule
:param denies: dict of glob path and deny rule to remove from
the filtered configuration.
:type denies: dict of str to DenyRule
"""
self.allows_ = allows
self.denies_ = denies
@ -42,31 +70,41 @@ class ConfigFilter(object):
def _is_allows_valid(self):
"""Check if allows are valid."""
if not isinstance(self.allows_, list):
if not isinstance(self.allows_, dict):
raise TypeError(
'allows type is %s but expected type is list: %s' % (
'allows type is %s but expected type is dict: %s' % (
type(self.allows_), self.allows_))
for i, allow in enumerate(self.allows_):
if not isinstance(allow, basestring):
for allow_key, allow_rule in self.allows_.items():
if not isinstance(allow_key, basestring):
raise TypeError(
'allows[%s] type is %s but expected type '
'is str or unicode: %s' % (
i, type(allow), allow))
'allow_key %s type is %s but expected type '
'is str or unicode' % (allow_key, type(allow_rule)))
if not isinstance(allow_rule, AllowRule):
raise TypeError(
'allows[%s] %s type is %s but expected type '
'is AllowRule' % (
allow_key, allow_rule, type(allow_rule)))
def _is_denies_valid(self):
"""Check if denies are valid."""
if not isinstance(self.denies_, list):
if not isinstance(self.denies_, dict):
raise TypeError(
'denies type is %s but expected type is list: %s' % (
'denies type is %s but expected type is dict: %s' % (
type(self.denies_), self.denies_))
for i, deny in enumerate(self.denies_):
if not isinstance(deny, basestring):
for deny_key, deny_rule in self.denies_.items():
if not isinstance(deny_key, basestring):
raise TypeError(
'denies[%s] type is %s but expected type '
'deny_key %s type is %s but expected type '
'is str or unicode: %s' % (
i, type(deny), deny))
deny_key, deny_rule, type(deny_rule)))
if not isinstance(deny_rule, DenyRule):
raise TypeError(
'denies[%s] %s type is %s but expected type '
'is DenyRule' % (deny_key, deny_rule, type(deny_rule)))
def _is_valid(self):
"""Check if config filter is valid."""
@ -92,22 +130,25 @@ class ConfigFilter(object):
def _filter_allows(self, ref, filtered_ref):
"""copy ref config with the allows to filtered ref."""
for allow in self.allows_:
if not allow:
continue
logging.debug('filter by allow rule %s', allow)
for sub_key, sub_ref in ref.ref_items(allow):
logging.debug('%s is added to filtered config', sub_key)
filtered_ref.setdefault(sub_key).update(sub_ref.config)
for allow_key, allow_rule in self.allows_.items():
logging.debug('filter by allow rule %s', allow_key)
for sub_key, sub_ref in ref.ref_items(allow_key):
if allow_rule.allow(sub_key, sub_ref):
logging.debug('%s is added to filtered config', sub_key)
filtered_ref.setdefault(sub_key).update(sub_ref.config)
else:
logging.debug('%s is ignored to add to filtered config',
sub_key)
def _filter_denies(self, filtered_ref):
"""remove config from filter_ref by denies."""
for deny in self.denies_:
if not deny:
continue
logging.debug('filter by deny rule %s', deny)
for ref_key in filtered_ref.ref_keys(deny):
logging.debug('%s is removed from filtered config', ref_key)
del filtered_ref[ref_key]
for deny_key, deny_rule in self.denies_.items():
logging.debug('filter by deny rule %s', deny_key)
for ref_key, ref in filtered_ref.ref_items(deny_key):
if deny_rule.deny(ref_key, ref):
logging.debug('%s is removed from filtered config',
ref_key)
del filtered_ref[ref_key]
else:
logging.debug('%s is ignored to del from filtered config',
ref_key)

View File

@ -0,0 +1,31 @@
# 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.
"""callback lib for config filter callbacks."""
def allow_if_not_empty(_key, ref):
"""allow if ref is not empty."""
if not ref.config:
return False
else:
return True
def deny_if_empty(_key, ref):
"""deny if ref is empty."""
if not ref.config:
return True
else:
return False

View File

@ -639,7 +639,6 @@ class ConfigManager(object):
target_systems):
"""update clusters and hosts of each cluster configs."""
logging.debug('update cluster_hosts: %s', cluster_hosts)
for clusterid, hostids in cluster_hosts.items():
global_config = self.get_global_config(
os_version=os_versions[clusterid],

View File

@ -74,6 +74,9 @@ def _get_bundled_exclusives(exclusives, bundle_mapping):
def _get_max(lhs, rhs):
"""Get max value."""
if lhs < 0 and rhs < 0:
return min(lhs, rhs)
if lhs < 0:
return lhs
@ -86,10 +89,10 @@ def _get_max(lhs, rhs):
def _get_min(lhs, rhs):
"""Get min value."""
if lhs < 0:
return rhs
return max(rhs, 0)
if rhs < 0:
return lhs
return max(lhs, 0)
return min(lhs, rhs)
@ -106,19 +109,18 @@ def _get_bundled_max_mins(maxs, mins, default_max, default_min, role_bundles):
"""Get max and mins for each bundled role."""
bundled_maxs = {}
bundled_mins = {}
default_min = max(default_min, 0)
default_max = _get_max(default_max, default_min)
for bundled_role, roles in role_bundles.items():
bundled_min = None
bundled_max = None
for role in roles:
new_max = maxs.get(role, default_max)
new_min = mins.get(role, default_min)
new_max = maxs.get(role, maxs.get('default', default_max))
new_min = mins.get(role, mins.get('default', default_min))
new_max = _get_max(new_max, new_min)
if bundled_min is None:
bundled_min = new_min
else:
bundled_min = min(bundled_min, max(new_min, 0))
bundled_min = _get_min(bundled_min, new_min)
if bundled_max is None:
bundled_max = new_max
@ -130,7 +132,7 @@ def _get_bundled_max_mins(maxs, mins, default_max, default_min, role_bundles):
bundled_min = default_min
if bundled_max is None:
bundled_max = max(default_max, bundled_min)
bundled_max = _get_max(default_max, bundled_min)
bundled_mins[bundled_role] = bundled_min
bundled_maxs[bundled_role] = bundled_max
@ -288,16 +290,68 @@ def _sort_roles(lower_roles, roles):
lower_roles[lower_key] = updated_roles
logging.debug('sorted roles are %s', lower_roles)
def _update_dependencies(lower_roles, default_dependencies, dependencies):
"""update dependencies to lower roles."""
for lower_key, roles in lower_roles.items():
new_roles = []
for role in roles:
new_dependencies = dependencies.get(
role, dependencies.get('default', default_dependencies)
)
for new_dependency in new_dependencies:
if new_dependency not in new_roles:
new_roles.append(new_dependency)
if role not in new_roles:
new_roles.append(role)
lower_roles[lower_key] = new_roles
logging.debug(
'roles after adding dependencies %s default dependencies %s are: %s',
dependencies, default_dependencies, lower_roles)
def _update_post_roles(lower_roles, default_post_roles, post_roles):
"""update post roles to lower roles."""
for lower_key, roles in lower_roles.items():
new_roles = []
for role in reversed(roles):
new_post_roles = post_roles.get(
role, post_roles.get('default', default_post_roles)
)
for new_post_role in reversed(new_post_roles):
if new_post_role not in new_roles:
new_roles.append(new_post_role)
if role not in new_roles:
new_roles.append(role)
lower_roles[lower_key] = list(reversed(new_roles))
logging.debug(
'roles after adding post roles %s default %s are: %s',
post_roles, default_post_roles, lower_roles)
def assign_roles(_upper_ref, _from_key, lower_refs, to_key,
roles=[], maxs={}, mins={}, default_max=-1,
default_min=0, exclusives=[], bundles=[], **_kwargs):
default_min=0, exclusives=[], bundles=[],
default_dependencies=[], dependencies={},
default_post_roles=[], post_roles={}, **_kwargs):
"""Assign roles to lower configs."""
logging.debug(
'assignRoles with roles=%s, maxs=%s, mins=%s, '
'default_max=%s, default_min=%s, exclusives=%s, bundles=%s',
'default_max=%s, default_min=%s, exclusives=%s, bundles=%s'
'default_dependencies=%s, dependencies=%s'
'default_post_roles=%s, post_roles=%s',
roles, maxs, mins, default_max,
default_min, exclusives, bundles)
default_min, exclusives, bundles,
default_dependencies, dependencies,
default_post_roles, post_roles)
bundle_mapping, role_bundles = _get_role_bundle_mapping(roles, bundles)
bundled_exclusives = _get_bundled_exclusives(exclusives, bundle_mapping)
bundled_maxs, bundled_mins = _get_bundled_max_mins(
@ -322,6 +376,8 @@ def assign_roles(_upper_ref, _from_key, lower_refs, to_key,
bundled_maxs)
_sort_roles(lower_roles, roles)
_update_dependencies(lower_roles, default_dependencies, dependencies)
_update_post_roles(lower_roles, default_post_roles, post_roles)
return lower_roles

View File

@ -247,6 +247,7 @@ class KeyTranslator(object):
def translate(self, ref, key, translated_ref):
"""Translate content in ref[key] to translated_ref."""
logging.debug('translate %s', key)
for ref_key, sub_ref in ref.ref_items(key):
translated_keys = self._get_translated_keys(ref_key, sub_ref)
for translated_key in translated_keys:

View File

@ -38,6 +38,7 @@ def get_key_from_pattern(
to_pattern, group)
raise error
logging.debug('got translated key %s for %s', translated_key, path)
return translated_key
@ -78,14 +79,19 @@ def get_value_from_config_mapping(
translated_value = ref.get(value)
logging.debug('got translated_value %s from %s',
translated_value, value)
else:
elif isinstance(value, list):
for value_in_list in value:
translated_value = ref.get(value_in_list)
logging.debug('got translated_value %s from %s',
translated_value, value_in_list)
if translated_value:
if translated_value is not None:
break
else:
logging.error('unexpected type %s: %s',
type(value), value)
translated_value = None
logging.debug('got translated_value %s from translated_path %s',
translated_value, translated_path)
return translated_value
@ -109,13 +115,17 @@ def get_value_from_role_mapping(
translated_value = ref.get(value)
logging.debug('got translated_value %s from %s',
translated_value, value)
else:
elif isinstance(value, list):
for value_in_list in value:
translated_value = ref.get(value_in_list)
logging.debug('got translated_value %s from %s',
translated_value, value_in_list)
if translated_value:
if translated_value is not None:
break
else:
logging.error('unexpected type %s: %s',
type(value), value)
translated_value = None
logging.debug('got translated_value %s from roles %s '
'and translated_path %s',
@ -149,28 +159,74 @@ def get_encrypted_value(ref, _path, _translated_ref, _translated_path,
return crypt.crypt(ref.config, crypt_method)
def get_value_if(ref, _path, _translated_ref, _translated_path,
condition=False, **_kwargs):
"""Get value if condition is true."""
if not condition:
return None
return ref.config
def set_value(ref, _path, _translated_ref,
_translated_path,
return_value_callback=None, **kwargs):
"""Set value into translated config."""
condition = True
for _, arg in kwargs.items():
if not arg:
condition = False
if condition:
translated_value = ref.config
else:
translated_value = None
if not return_value_callback:
return translated_value
else:
return return_value_callback(translated_value)
def add_value(ref, _path, translated_ref,
_translated_path, condition='', **_kwargs):
"""Append value into translated config if condition."""
translated_path,
get_value_callback=None,
check_value_callback=None,
add_value_callback=None,
return_value_callback=None, **kwargs):
"""Append value into translated config."""
if not translated_ref.config:
value_list = []
else:
value_list = [
value for value in translated_ref.config.split(',') if value
]
if not get_value_callback:
value_list = translated_ref.config
else:
value_list = get_value_callback(translated_ref.config)
if condition and ref.config not in value_list:
value_list.append(ref.config)
logging.debug('%s value list is %s', translated_path, value_list)
if not isinstance(value_list, list):
raise TypeError(
'%s value %s type %s but expected type is list' % (
translated_path, value_list, type(value_list)))
return ','.join(value_list)
condition = True
for _, arg in kwargs.items():
if not arg:
condition = False
logging.debug('%s add_value condition is %s', translated_path, condition)
if condition:
if not check_value_callback:
value_in_list = ref.config in value_list
else:
value_in_list = check_value_callback(ref.config, value_list)
if value_in_list:
logging.debug('%s found value %s in %s',
translated_path, value_list, value_in_list)
if not value_in_list:
if not add_value_callback:
value_list.append(ref.config)
else:
add_value_callback(ref.config, value_list)
logging.debug('%s value %s after added', translated_path, value_list)
if not return_value_callback:
return value_list
else:
return return_value_callback(value_list)
def override_if_any(_ref, _path, _translated_ref, _translated_path, **kwargs):

View File

@ -60,3 +60,5 @@ role_assign_policy = {
'bundles': [],
},
}
testmode = False

View File

@ -0,0 +1,64 @@
networking = {
'global': {
'default_no_proxy': ['127.0.0.1', 'localhost'],
'search_path_pattern': '%(clusterid)s.%(search_path)s %(search_path)s',
'noproxy_pattern': '%(hostname)s.%(clusterid)s,%(ip)s'
},
'interfaces': {
'management': {
'dns_pattern': '%(hostname)s.%(clusterid)s.%(search_path)s',
'netmask': '255.255.255.0',
'nic': 'eth0',
'promisc': 0,
},
'tenant': {
'netmask': '255.255.255.0',
'nic': 'eth0',
'dns_pattern': 'virtual-%(hostname)s.%(clusterid)s.%(search_path)s',
'promisc': 0,
},
'public': {
'netmask': '255.255.255.0',
'nic': 'eth1',
'dns_pattern': 'floating-%(hostname)s.%(clusterid)s.%(search_path)s',
'promisc': 1,
},
'storage': {
'netmask': '255.255.255.0',
'nic': 'eth0',
'dns_pattern': 'storage-%(hostname)s.%(clusterid)s.%(search_path)s',
'promisc': 0,
},
},
}
security = {
'server_credentials': {
'username': 'root',
'password': 'huawei',
},
'console_credentials': {
'username': 'admin',
'password': 'huawei',
},
'service_credentials': {
'username': 'admin',
'password': 'huawei',
},
}
role_assign_policy = {
'policy_by_host_numbers': {
},
'default': {
'roles': [],
'maxs': {},
'mins': {},
'default_max': -1,
'default_min': 0,
'exclusives': [],
'bundles': [],
},
}
testmode = True

View File

@ -104,82 +104,84 @@ cobbler_MOCK = {
}
chef_MOCK = {
'configs': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-compute-worker', 'os-network'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller','os-compute-worker','os-network']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
@ -212,81 +214,90 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host1.1',
'chef_node_name': u'openstack.host1.1'
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'openstack_1': {
'credential': {
'identity': {
'users': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-single-controller', 'os-network', 'os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-single-controller]', 'role[os-network]', 'role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'network': {
'service': {'host': '192.168.20.100'}
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
},

View File

@ -120,82 +120,84 @@ cobbler_MOCK = {
}
chef_MOCK = {
'configs': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'dashboard_roles': ['os-single-controller'],
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-compute-worker', 'os-network'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller','os-compute-worker','os-network']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'dashboard_roles': ['os-single-controller'],
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-network', 'os-compute-worker']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
@ -228,8 +230,8 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host1.1',
'chef_node_name': 'openstack.host1.1'
'chef_client_name': 'host1.1',
'chef_node_name': 'host1.1'
},
},{
'profile': 'CentOS',
@ -260,81 +262,97 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host2.1',
'chef_node_name': 'openstack.host2.1'
'chef_client_name': 'host2.1',
'chef_node_name': 'host2.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'openstack_1': {
'credential': {
'identity': {
'users': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-single-controller'],
},
'cluster': '1',
'run_list': ['role[os-single-controller]']
},
'host2.1': {
'roles_per_target_system': {
'openstack': ['os-network', 'os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-network]', 'role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'network': {
'service': {'host': '192.168.20.100'}
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
},

View File

@ -212,82 +212,84 @@ cobbler_MOCK = {
}
chef_MOCK = {
'configs': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'dashboard_roles': ['os-single-controller'],
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-compute-worker', 'os-network'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller','os-compute-worker','os-network']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'dashboard_roles': ['os-single-controller'],
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-network', 'os-compute-worker']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
@ -320,8 +322,8 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host1.1',
'chef_node_name': u'openstack.host1.1'
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
},{
'profile': 'CentOS',
@ -352,8 +354,8 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100,host2.1,192.168.20.101',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host2.1',
'chef_node_name': u'openstack.host2.1'
'chef_client_name': 'host2.1',
'chef_node_name': u'host2.1'
},
},{
'profile': 'CentOS',
@ -384,8 +386,8 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.2,192.168.20.110,host2.2,192.168.20.111',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host1.2',
'chef_node_name': u'openstack.host1.2'
'chef_client_name': 'host1.2',
'chef_node_name': u'host1.2'
},
},{
'profile': 'CentOS',
@ -416,151 +418,181 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.2,192.168.20.110,host2.2,192.168.20.111',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host2.2',
'chef_node_name': u'openstack.host2.2'
'chef_client_name': 'host2.2',
'chef_node_name': u'host2.2'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'openstack_1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-single-controller'],
},
'cluster': '1',
'run_list': ['role[os-single-controller]']
},
'openstack_2': {
'credential': {
'identity': {
'users': {
'host2.1': {
'roles_per_target_system': {
'openstack': ['os-network', 'os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-network]', 'role[os-compute-worker]']
},
'host1.2': {
'roles_per_target_system': {
'openstack': ['os-single-controller'],
},
'cluster': '2',
'run_list': ['role[os-single-controller]']
},
'host2.2': {
'roles_per_target_system': {
'openstack': ['os-network', 'os-compute-worker'],
},
'cluster': '2',
'run_list': ['role[os-network]', 'role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.110'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.110'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.110'},
'xvpvnc': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'},
'metadata': {'host': '192.168.20.110'}
'2': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'network': {
'service': {'host': '192.168.20.110'}
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'image': {
'registry': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'}
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.110'
}
},
'metering': {
'service': {'host': '192.168.20.110'}
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.110'}
},
'volume': {
'service': {'host': '192.168.20.110'}
},
'ec2': {
'admin': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'}
},
'identity': {
'admin': {'host': u'192.168.20.110'},
'service': {'host': u'192.168.20.110'}
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.110'},
'xvpvnc': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'},
'metadata': {'host': '192.168.20.110'}
},
'network': {
'service': {'host': '192.168.20.110'}
},
'image': {
'registry': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'}
},
'metering': {
'service': {'host': '192.168.20.110'}
},
'volume': {
'service': {'host': '192.168.20.110'}
},
'ec2': {
'admin': {'host': '192.168.20.110'},
'service': {'host': '192.168.20.110'}
},
'identity': {
'admin': {'host': u'192.168.20.110'},
'service': {'host': u'192.168.20.110'}
},
},
},
},

View File

@ -104,82 +104,84 @@ cobbler_MOCK = {
}
chef_MOCK = {
'configs': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller', 'os-dashboard'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-compute-worker', 'os-network'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller','os-compute-worker','os-network']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller', 'os-dashboard'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-network', 'os-compute-worker']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
@ -212,45 +214,54 @@ cobbler_EXPECTED = {
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100',
'ntp_server': '192.168.20.254',
'chef_client_name': 'openstack.host1.1',
'chef_node_name': u'openstack.host1.1'
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'openstack_1': {
'credential': {
'identity': {
'users': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-dashboard'],
},
'cluster': '1',
'run_list': ['role[os-dashboard]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
},
},
}

View File

@ -0,0 +1,340 @@
import simplejson as json
ADAPTERS = [
{'name': 'CentOS_openstack', 'os': 'CentOS', 'target_system': 'openstack'},
]
ROLES = [
{'name': 'os-single-controller', 'target_system': 'openstack'},
{'name': 'os-network', 'target_system': 'openstack'},
{'name': 'os-compute-worker', 'target_system': 'openstack'},
]
SWITCHES = [
{'ip': '1.2.3.4', 'vendor_info': 'huawei', 'credential_data': json.dumps({'version': 'v2c', 'community': 'public'})},
]
MACHINES_BY_SWITCH = {
'1.2.3.4': [
{'mac': '00:00:01:02:03:04', 'port': 1, 'vlan': 1},
],
}
CLUSTERS = [
{
'name': 'cluster1',
'adapter': 'CentOS_openstack',
'mutable': False,
'security_config': json.dumps({
'server_credentials': {
'username': 'root', 'password': 'huawei'
},
'service_credentials': {
'username': 'service', 'password': 'huawei'
},
'console_credentials': {
'username': 'admin', 'password': 'huawei'
}
}),
'networking_config': json.dumps({
'interfaces': {
'management': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.255.0',
'ip_end': '192.168.20.200',
'gateway': '',
'ip_start': '192.168.20.100'
},
'storage': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.200',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'public': {
'nic': 'eth2',
'promisc': 1,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.255',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'tenant': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.120',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
}
},
'global': {
'nameservers': '192.168.20.254',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'search_path': 'ods.com',
'gateway': '10.145.88.1'
},
}),
'partition_config': json.dumps('/home 20%%;/tmp 10%%;/var 30%%;'),
},
]
HOSTS_BY_CLUSTER = {
'cluster1': [
{
'hostname': 'host1',
'mac': '00:00:01:02:03:04',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.100',
},
},
},
'roles': ["os-single-controller", "os-network", "os-compute-worker"],
}),
},
],
}
cobbler_MOCK = {
'host_configs': []
}
chef_MOCK = {
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'test_roles': {
'default': ['test-synclog']
},
'debugging': {
'debug': 'False',
'verbose': 'False'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker': -1},
'default_dependencies': [],
'dependencies': {'default': ['test-synclog']}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-network', 'os-compute-worker']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
'expected_host_configs': [{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host1.1',
'hostname': 'host1',
'modify_interface': {
'dnsname-eth2': 'floating-host1.1.ods.com',
'dnsname-eth0': u'host1.1.ods.com',
'ipaddress-eth2': '10.145.88.100',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.100',
'netmask-eth2': '255.255.254.0',
'macaddress-eth0': '00:00:01:02:03:04',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ignore_proxy': '127.0.0.1,localhost,host1.1,192.168.20.100',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['test-synclog', 'os-single-controller', 'os-network', 'os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[test-synclog]', 'role[os-single-controller]', 'role[os-network]', 'role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'debugging': {
'debug': 'True',
'verbose': 'True'
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1},
'default_dependencies': [],
'dependencies': {'default': ['test-synclog']}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-network', 'os-compute-worker']],
'exclusives':['os-single-controller']
},
},
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
},
},
}

View File

@ -0,0 +1,780 @@
import simplejson as json
ADAPTERS = [
{'name': 'CentOS_openstack', 'os': 'CentOS', 'target_system': 'openstack'},
]
ROLES = [
{'name': 'os-single-controller', 'target_system': 'openstack'},
{'name': 'os-network', 'target_system': 'openstack'},
{'name': 'os-compute-worker', 'target_system': 'openstack'},
]
SWITCHES = [
{'ip': '1.2.3.4', 'vendor_info': 'huawei', 'credential_data': json.dumps({'version': 'v2c', 'community': 'public'})},
]
MACHINES_BY_SWITCH = {
'1.2.3.4': [
{'mac': '00:00:01:02:03:04', 'port': 1, 'vlan': 1},
{'mac': '00:00:01:02:03:05', 'port': 2, 'vlan': 1},
{'mac': '00:00:01:02:03:06', 'port': 3, 'vlan': 1},
{'mac': '00:00:01:02:03:07', 'port': 4, 'vlan': 1},
{'mac': '00:00:01:02:03:08', 'port': 5, 'vlan': 1},
{'mac': '00:00:01:02:03:09', 'port': 6, 'vlan': 1},
{'mac': '00:00:01:02:03:10', 'port': 7, 'vlan': 1},
{'mac': '00:00:01:02:03:11', 'port': 8, 'vlan': 1},
{'mac': '00:00:01:02:03:12', 'port': 9, 'vlan': 1},
{'mac': '00:00:01:02:03:13', 'port': 10, 'vlan': 1},
],
}
CLUSTERS = [
{
'name': 'cluster1',
'adapter': 'CentOS_openstack',
'mutable': False,
'security_config': json.dumps({
'server_credentials': {
'username': 'root', 'password': 'huawei'
},
'service_credentials': {
'username': 'service', 'password': 'huawei'
},
'console_credentials': {
'username': 'admin', 'password': 'huawei'
}
}),
'networking_config': json.dumps({
'interfaces': {
'management': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.255.0',
'ip_end': '192.168.20.200',
'gateway': '',
'ip_start': '192.168.20.100'
},
'storage': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.200',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'public': {
'nic': 'eth2',
'promisc': 1,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.255',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
},
'tenant': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.120',
'gateway': '10.145.88.1',
'ip_start': '10.145.88.100'
}
},
'global': {
'nameservers': '192.168.20.254',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'search_path': 'ods.com',
'gateway': '10.145.88.1'
},
}),
'partition_config': json.dumps('/home 20%%;/tmp 10%%;/var 30%%;'),
},
]
HOSTS_BY_CLUSTER = {
'cluster1': [
{
'hostname': 'host1',
'mac': '00:00:01:02:03:04',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.100',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host2',
'mac': '00:00:01:02:03:05',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.101',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host3',
'mac': '00:00:01:02:03:06',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.102',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host4',
'mac': '00:00:01:02:03:07',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.103',
},
},
},
'roles': ["os-compute-worker"],
}),
},
{
'hostname': 'host5',
'mac': '00:00:01:02:03:08',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.104',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host6',
'mac': '00:00:01:02:03:09',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.105',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host7',
'mac': '00:00:01:02:03:10',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.106',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host8',
'mac': '00:00:01:02:03:11',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.107',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host9',
'mac': '00:00:01:02:03:12',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.108',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host10',
'mac': '00:00:01:02:03:13',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.109',
},
},
},
'roles': [],
}),
},
],
}
cobbler_MOCK = {
'host_configs': []
}
chef_MOCK = {
'configs': {
'openstack': {
'env_default': {
'all_roles': {
'os-single-controller': 'openstack controller node',
'os-network': 'openstack network node',
'os-compute-worker': 'openstack nova node'
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
},
'role_mapping': {
'os-single-controller': {
'/db/mysql/bind_address': '/networking/interfaces/management/ip',
'/mq/rabbitmq/bind_address': '/networking/interfaces/management/ip',
'/endpoints/compute/metadata/host': '/networking/interfaces/management/ip',
'/endpoints/compute/novnc/host': '/networking/interfaces/management/ip',
'/endpoints/compute/service/host': '/networking/interfaces/management/ip',
'/endpoints/compute/xvpvnc/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/admin/host': '/networking/interfaces/management/ip',
'/endpoints/ec2/service/host': '/networking/interfaces/management/ip',
'/endpoints/identity/admin/host': '/networking/interfaces/management/ip',
'/endpoints/identity/service/host': '/networking/interfaces/management/ip',
'/endpoints/image/registry/host': '/networking/interfaces/management/ip',
'/endpoints/image/service/host': '/networking/interfaces/management/ip',
'/endpoints/metering/service/host': '/networking/interfaces/management/ip',
'/endpoints/network/service/host': '/networking/interfaces/management/ip',
'/endpoints/volume/service/host': '/networking/interfaces/management/ip'
},
'os-network': {
},
'os-compute-worker': {
}
},
'dashboard_roles': ['os-single-controller'],
'role_assign_policy': {
'default':{
'bundles': [],
'exclusives': ['os-single-controller', 'os-network'],
'roles': ['os-single-controller', 'os-network', 'os-compute-worker'],
'default_min': 1,
'default_max': 1,
'maxs': {'os-compute-worker':-1}
},
'policy_by_host_numbers':{
'1': {
'bundles': [['os-single-controller', 'os-network', 'os-compute-worker']],
'exclusives':[]
},
'2': {
'bundles': [['os-compute-worker','os-network']],
'exclusives':['os-single-controller']
},
},
},
},
},
},
}
cobbler_EXPECTED = {
'expected_host_configs': [{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host1.1',
'hostname': 'host1',
'modify_interface': {
'dnsname-eth2': 'floating-host1.1.ods.com',
'dnsname-eth0': u'host1.1.ods.com',
'ipaddress-eth2': '10.145.88.100',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.100',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host2.1',
'hostname': 'host2',
'modify_interface': {
'dnsname-eth2': 'floating-host2.1.ods.com',
'dnsname-eth0': u'host2.1.ods.com',
'ipaddress-eth2': '10.145.88.101',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.101',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host2.1',
'chef_node_name': u'host2.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host3.1',
'hostname': 'host3',
'modify_interface': {
'dnsname-eth2': 'floating-host3.1.ods.com',
'dnsname-eth0': u'host3.1.ods.com',
'ipaddress-eth2': '10.145.88.102',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.102',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host3.1',
'chef_node_name': u'host3.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host4.1',
'hostname': 'host4',
'modify_interface': {
'dnsname-eth2': 'floating-host4.1.ods.com',
'dnsname-eth0': u'host4.1.ods.com',
'ipaddress-eth2': '10.145.88.103',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.103',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host4.1',
'chef_node_name': u'host4.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host5.1',
'hostname': 'host5',
'modify_interface': {
'dnsname-eth2': 'floating-host5.1.ods.com',
'dnsname-eth0': u'host5.1.ods.com',
'ipaddress-eth2': '10.145.88.104',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.104',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host5.1',
'chef_node_name': u'host5.1'
},
}, {
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host6.1',
'hostname': 'host6',
'modify_interface': {
'dnsname-eth2': 'floating-host6.1.ods.com',
'dnsname-eth0': u'host6.1.ods.com',
'ipaddress-eth2': '10.145.88.105',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.105',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host6.1',
'chef_node_name': u'host6.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host7.1',
'hostname': 'host7',
'modify_interface': {
'dnsname-eth2': 'floating-host7.1.ods.com',
'dnsname-eth0': u'host7.1.ods.com',
'ipaddress-eth2': '10.145.88.106',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.106',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host7.1',
'chef_node_name': u'host7.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host8.1',
'hostname': 'host8',
'modify_interface': {
'dnsname-eth2': 'floating-host8.1.ods.com',
'dnsname-eth0': u'host8.1.ods.com',
'ipaddress-eth2': '10.145.88.107',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.107',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host8.1',
'chef_node_name': u'host8.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host9.1',
'hostname': 'host9',
'modify_interface': {
'dnsname-eth2': 'floating-host9.1.ods.com',
'dnsname-eth0': u'host9.1.ods.com',
'ipaddress-eth2': '10.145.88.108',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.108',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host9.1',
'chef_node_name': u'host9.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host10.1',
'hostname': 'host10',
'modify_interface': {
'dnsname-eth2': 'floating-host10.1.ods.com',
'dnsname-eth0': u'host10.1.ods.com',
'ipaddress-eth2': '10.145.88.109',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.109',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host10.1',
'chef_node_name': u'host10.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-single-controller'],
},
'cluster': '1',
'run_list': ['role[os-single-controller]']
},
'host2.1': {
'roles_per_target_system': {
'openstack': ['os-network'],
},
'cluster': '1',
'run_list': ['role[os-network]']
},
'host3.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host4.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host5.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host6.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host7.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host8.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host9.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host10.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.100'
}
},
'dashboard_roles': ['os-single-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.100'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.100'},
'xvpvnc': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'},
'metadata': {'host': '192.168.20.100'}
},
'network': {
'service': {'host': '192.168.20.100'}
},
'image': {
'registry': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'metering': {
'service': {'host': '192.168.20.100'}
},
'volume': {
'service': {'host': '192.168.20.100'}
},
'ec2': {
'admin': {'host': '192.168.20.100'},
'service': {'host': '192.168.20.100'}
},
'identity': {
'admin': {'host': u'192.168.20.100'},
'service': {'host': u'192.168.20.100'}
},
},
},
},
},
}

View File

@ -0,0 +1,904 @@
import simplejson as json
ADAPTERS = [
{'name': 'CentOS_openstack', 'os': 'CentOS', 'target_system': 'openstack'},
]
ROLES = [
{'name': 'os-controller', 'target_system': 'openstack'},
{'name': 'os-network', 'target_system': 'openstack'},
{'name': 'os-compute-worker', 'target_system': 'openstack'},
{'name': 'os-ha', 'target_system': 'openstack'},
{'name': 'os-image', 'target_system': 'openstack'},
{'name': 'os-ops-database', 'target_system': 'openstack'},
{'name': 'os-ops-messaging', 'target_system': 'openstack'},
{'name': 'os-block-storage-worker', 'target_system': 'openstack'}
]
SWITCHES = [
{'ip': '1.2.3.4', 'vendor_info': 'huawei', 'credential_data': json.dumps({'version': 'v2c', 'community': 'public'})},
]
MACHINES_BY_SWITCH = {
'1.2.3.4': [
{'mac': '00:00:01:02:03:04', 'port': 1, 'vlan': 1},
{'mac': '00:00:01:02:03:05', 'port': 2, 'vlan': 1},
{'mac': '00:00:01:02:03:06', 'port': 3, 'vlan': 1},
{'mac': '00:00:01:02:03:07', 'port': 4, 'vlan': 1},
{'mac': '00:00:01:02:03:08', 'port': 5, 'vlan': 1},
{'mac': '00:00:01:02:03:09', 'port': 6, 'vlan': 1},
{'mac': '00:00:01:02:03:10', 'port': 7, 'vlan': 1},
{'mac': '00:00:01:02:03:11', 'port': 8, 'vlan': 1},
{'mac': '00:00:01:02:03:12', 'port': 9, 'vlan': 1},
{'mac': '00:00:01:02:03:13', 'port': 10, 'vlan': 1},
],
}
CLUSTERS = [
{
'name': 'cluster1',
'adapter': 'CentOS_openstack',
'mutable': False,
'security_config': json.dumps({
'server_credentials': {
'username': 'root', 'password': 'huawei'
},
'service_credentials': {
'username': 'service', 'password': 'huawei'
},
'console_credentials': {
'username': 'admin', 'password': 'huawei'
}
}),
'networking_config': json.dumps({
'interfaces': {
'management': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.255.0',
'ip_end': '192.168.20.200',
'gateway': '',
'ip_start': '192.168.20.100'
},
'storage': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.200',
'gateway': '',
'ip_start': '10.145.88.100'
},
'public': {
'nic': 'eth2',
'promisc': 1,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.255',
'gateway': '',
'ip_start': '10.145.88.100'
},
'tenant': {
'nic': 'eth0',
'promisc': 0,
'netmask': '255.255.254.0',
'ip_end': '10.145.88.120',
'gateway': '',
'ip_start': '10.145.88.100'
}
},
'global': {
'nameservers': '192.168.20.254',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'search_path': 'ods.com',
'gateway': '10.145.88.1',
'ha_vip': '192.168.20.253'
},
}),
'partition_config': json.dumps('/home 20%%;/tmp 10%%;/var 30%%;'),
},
]
HOSTS_BY_CLUSTER = {
'cluster1': [
{
'hostname': 'host1',
'mac': '00:00:01:02:03:04',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.100',
},
},
},
'roles': ["os-ha"],
}),
},
{
'hostname': 'host2',
'mac': '00:00:01:02:03:05',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.101',
},
},
},
'roles': ["os-ha"],
}),
},
{
'hostname': 'host3',
'mac': '00:00:01:02:03:06',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.102',
},
},
},
'roles': ["os-controller", "os-image"],
}),
},
{
'hostname': 'host4',
'mac': '00:00:01:02:03:07',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.103',
},
},
},
'roles': ["os-controller", "os-compute-vncproxy"],
}),
},
{
'hostname': 'host5',
'mac': '00:00:01:02:03:08',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.104',
},
},
},
'roles': ["os-controller", "os-block-storage-worker"],
}),
},
{
'hostname': 'host6',
'mac': '00:00:01:02:03:09',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.105',
},
},
},
'roles': ["os-ops-database", "os-ops-messaging"],
}),
},
{
'hostname': 'host7',
'mac': '00:00:01:02:03:10',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.106',
},
},
},
'roles': ["os-network"],
}),
},
{
'hostname': 'host8',
'mac': '00:00:01:02:03:11',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.107',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host9',
'mac': '00:00:01:02:03:12',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.108',
},
},
},
'roles': [],
}),
},
{
'hostname': 'host10',
'mac': '00:00:01:02:03:13',
'mutable': False,
'config_data': json.dumps({
'networking': {
'interfaces': {
'management': {
'ip': '192.168.20.109',
},
},
},
'roles': [],
}),
},
],
}
cobbler_MOCK = {
'host_configs': []
}
chef_MOCK = {
'configs': {
'openstack': {
'env_default': {
'all_roles': {
"os-block-storage-worker": "openstack block storage node",
"os-controller": "openstack controller node",
"os-network": "openstack network node",
"os-ops-messaging": "openstack message queue node",
"os-image": "openstack image node",
"os-ops-database": "openstack database node",
"os-compute-worker":"openstack nova node",
"os-ha":"Software load balance node",
"os-compute-vncproxy": "vnc proxy"
},
'config_mapping': {
'/credential/identity/users/admin': '/security/console_credentials',
'/credential/identity/users/compute': '/security/service_credentials',
'/credential/identity/users/image': '/security/service_credentials',
'/credential/identity/users/metering': '/security/service_credentials',
'/credential/identity/users/network': '/security/service_credentials',
'/credential/identity/users/object-store': '/security/service_credentials',
'/credential/identity/users/volume': '/security/service_credentials',
'/credential/mysql/compute': '/security/service_credentials',
'/credential/mysql/dashboard': '/security/service_credentials',
'/credential/mysql/identity': '/security/service_credentials',
'/credential/mysql/image': '/security/service_credentials',
'/credential/mysql/metering': '/security/service_credentials',
'/credential/mysql/network': '/security/service_credentials',
'/credential/mysql/volume': '/security/service_credentials',
'/credential/mysql/super/password': '/security/service_credentials/password',
'/networking/control/interface': '/networking/interfaces/management/nic',
'/ntp/ntpserver': '/networking/global/ntp_server',
'/networking/storage/interface': '/networking/interfaces/storage/nic',
'/networking/public/interface': '/networking/interfaces/public/nic',
'/networking/tenant/interface': '/networking/interfaces/tenant/nic',
'/networking/plugins/ovs/gre/local_ip_interface': '/networking/interfaces/tenant/nic',
"/ha/haproxy/vip": "/networking/global/ha_vip",
"/ha/keepalived/instance_name/vip": "/networking/global/ha_vip"
},
'read_config_mapping': {
"/dashboard_roles": "/dashboard_roles",
"/haproxy_roles": "/haproxy_roles",
"/test_roles": "/test_roles",
"/haproxy/router_id_prefix": "/ha/keepalived/router_id_prefix",
"/haproxy/default_priority": "/ha/keepalived/default_priority",
"/haproxy/default_state": "/ha/keepalived/default_state",
"/haproxy/states_to_assign": "/ha/keepalived/states_to_assign"
},
'role_mapping': {
"os-controller": {
"/endpoints/compute/metadata/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/compute/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/compute/xvpvnc/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/ec2/admin/host":[
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/ec2/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/identity/admin/host":[
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/identity/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/metering/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/network/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/volume/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
]
},
"os-compute-vncproxy": {
"/endpoints/compute/novnc/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
]
},
"os-ops-database": {
"/db/mysql/bind_address": "/networking/interfaces/management/ip"
},
"os-ops-messaging": {
"/mq/rabbitmq/bind_address": "/networking/interfaces/management/ip"
},
"os-image": {
"/endpoints/image/registry/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
],
"/endpoints/image/service/host": [
"/networking/global/ha_vip",
"/networking/interfaces/management/ip"
]
}
},
'ha': {
"status": "disable",
"haproxy":{
"vip": "",
"roles":{
"os-controller": [
"dashboard_http", "dashboard_https", "keystone_admin",
"keystone_public_internal", "nova_ec2_api", "nova_compute_api",
"cinder_api", "neutron_api", "novncproxy"
],
"os-image": [
"glance_api", "glance_registry_cluster"
]
}
},
"keepalived": {
"router_id_prefix": "lsb",
"default_priority": 100,
"default_state": "SLAVE",
"states_to_assign": ["MASTER"],
"router_ids":{},
"instance_name":{
"vip": "",
"priorities": {},
"states":{}
}
}
},
"test_roles": {
"default":["test-synclog"]
},
'haproxy_roles': ["os-ha"],
'dashboard_roles': ['os-controller'],
'role_assign_policy': {
'default': {
"bundles":[],
"exclusives":["os-controller"],
"roles":[
"os-ha",
"os-ops-database",
"os-ops-messaging",
"os-controller",
"os-compute-vncproxy",
"os-image",
"os-block-storage-worker",
"os-network",
"os-compute-worker"
],
"default_min": 1,
"default_max": 1,
"maxs":{
"os-compute-worker":-1,
"os-ha":0
},
"mins":{
"os-ha":0
},
"default_dependencies":[],
"dependencies":{},
"default_post_roles":[],
"post_roles":{}
},
'policy_by_host_numbers': {
"1": {
"bundles": [
[
"os-ops-database",
"os-ops-messaging",
"os-controller",
"os-compute-vncproxy",
"os-image",
"os-block-storage-worker",
"os-network",
"os-compute-worker"
]
]
}
},
},
},
},
},
}
cobbler_EXPECTED = {
'expected_host_configs': [{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host1.1',
'hostname': 'host1',
'modify_interface': {
'dnsname-eth2': 'floating-host1.1.ods.com',
'dnsname-eth0': u'host1.1.ods.com',
'ipaddress-eth2': '10.145.88.100',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.100',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host1.1',
'chef_node_name': u'host1.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host2.1',
'hostname': 'host2',
'modify_interface': {
'dnsname-eth2': 'floating-host2.1.ods.com',
'dnsname-eth0': u'host2.1.ods.com',
'ipaddress-eth2': '10.145.88.101',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.101',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host2.1',
'chef_node_name': u'host2.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host3.1',
'hostname': 'host3',
'modify_interface': {
'dnsname-eth2': 'floating-host3.1.ods.com',
'dnsname-eth0': u'host3.1.ods.com',
'ipaddress-eth2': '10.145.88.102',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.102',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host3.1',
'chef_node_name': u'host3.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host4.1',
'hostname': 'host4',
'modify_interface': {
'dnsname-eth2': 'floating-host4.1.ods.com',
'dnsname-eth0': u'host4.1.ods.com',
'ipaddress-eth2': '10.145.88.103',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.103',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host4.1',
'chef_node_name': u'host4.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host5.1',
'hostname': 'host5',
'modify_interface': {
'dnsname-eth2': 'floating-host5.1.ods.com',
'dnsname-eth0': u'host5.1.ods.com',
'ipaddress-eth2': '10.145.88.104',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.104',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host5.1',
'chef_node_name': u'host5.1'
},
}, {
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host6.1',
'hostname': 'host6',
'modify_interface': {
'dnsname-eth2': 'floating-host6.1.ods.com',
'dnsname-eth0': u'host6.1.ods.com',
'ipaddress-eth2': '10.145.88.105',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.105',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host6.1',
'chef_node_name': u'host6.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host7.1',
'hostname': 'host7',
'modify_interface': {
'dnsname-eth2': 'floating-host7.1.ods.com',
'dnsname-eth0': u'host7.1.ods.com',
'ipaddress-eth2': '10.145.88.106',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.106',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host7.1',
'chef_node_name': u'host7.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host8.1',
'hostname': 'host8',
'modify_interface': {
'dnsname-eth2': 'floating-host8.1.ods.com',
'dnsname-eth0': u'host8.1.ods.com',
'ipaddress-eth2': '10.145.88.107',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.107',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host8.1',
'chef_node_name': u'host8.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host9.1',
'hostname': 'host9',
'modify_interface': {
'dnsname-eth2': 'floating-host9.1.ods.com',
'dnsname-eth0': u'host9.1.ods.com',
'ipaddress-eth2': '10.145.88.108',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.108',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host9.1',
'chef_node_name': u'host9.1'
},
},{
'profile': 'CentOS',
'name_servers_search': '1.ods.com ods.com',
'name': 'host10.1',
'hostname': 'host10',
'modify_interface': {
'dnsname-eth2': 'floating-host10.1.ods.com',
'dnsname-eth0': u'host10.1.ods.com',
'ipaddress-eth2': '10.145.88.109',
'static-eth2': True,
'static-eth0': True,
'netmask-eth0': '255.255.255.0',
'ipaddress-eth0': u'192.168.20.109',
'netmask-eth2': '255.255.254.0',
'management-eth2': False,
'management-eth0': True
},
'name_servers': '192.168.20.254',
'gateway': '10.145.88.1',
'ksmeta': {
'username': u'root',
'promisc_nics': 'eth2',
'chef_url': 'https://localhost/',
'tool': 'chef',
'partition': '/home 20%%;/tmp 10%%;/var 30%%;',
'proxy': 'http://192.168.20.254:3128',
'ntp_server': '192.168.20.254',
'chef_client_name': 'host10.1',
'chef_node_name': u'host10.1'
},
}],
}
chef_EXPECTED = {
'expected_configs': {
'host1.1': {
'roles_per_target_system': {
'openstack': ['os-ha'],
},
'cluster': '1',
'run_list': ['role[os-ha]']
},
'host2.1': {
'roles_per_target_system': {
'openstack': ['os-ha'],
},
'cluster': '1',
'run_list': ['role[os-ha]']
},
'host3.1': {
'roles_per_target_system': {
'openstack': ['os-controller', 'os-image'],
},
'cluster': '1',
'run_list': ['role[os-controller]', 'role[os-image]']
},
'host4.1': {
'roles_per_target_system': {
'openstack': ['os-controller', 'os-compute-vncproxy'],
},
'cluster': '1',
'run_list': ['role[os-controller]', 'role[os-compute-vncproxy]']
},
'host5.1': {
'roles_per_target_system': {
'openstack': ['os-controller', 'os-block-storage-worker'],
},
'cluster': '1',
'run_list': ['role[os-controller]', 'role[os-block-storage-worker]']
},
'host6.1': {
'roles_per_target_system': {
'openstack': ['os-ops-database', 'os-ops-messaging'],
},
'cluster': '1',
'run_list': ['role[os-ops-database]', 'role[os-ops-messaging]']
},
'host7.1': {
'roles_per_target_system': {
'openstack': ['os-network'],
},
'cluster': '1',
'run_list': ['role[os-network]']
},
'host8.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host9.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'host10.1': {
'roles_per_target_system': {
'openstack': ['os-compute-worker'],
},
'cluster': '1',
'run_list': ['role[os-compute-worker]']
},
'openstack': {
'1': {
'credential': {
'identity': {
'users': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'admin': {'username': 'admin', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'object-store': {'username': 'service', 'password': 'huawei'}
}
},
'mysql': {
'compute': {'username': 'service', 'password': 'huawei'},
'network': {'username': 'service', 'password': 'huawei'},
'image': {'username': 'service', 'password': 'huawei'},
'metering': {'username': 'service', 'password': 'huawei'},
'volume': {'username': 'service', 'password': 'huawei'},
'dashboard': {'username': 'service', 'password': 'huawei'},
'super': {'password': 'huawei'},
'identity': {'username': 'service', 'password': 'huawei'}
}
},
'networking': {
'control': {'interface': 'eth0'},
'storage': {'interface': 'eth0'},
'public': {'interface': 'eth2'},
'tenant': {'interface': 'eth0'}
},
'ntp': {'ntpserver': '192.168.20.254'},
'db': {
'mysql': {
'bind_address': '192.168.20.105'
}
},
'dashboard_roles': ['os-controller'],
'mq': {
'rabbitmq': {'bind_address': '192.168.20.105'}
},
'endpoints': {
'compute': {
'novnc': {'host': '192.168.20.253'},
'xvpvnc': {'host': '192.168.20.253'},
'service': {'host': '192.168.20.253'},
'metadata': {'host': '192.168.20.253'}
},
'network': {
'service': {'host': '192.168.20.253'}
},
'image': {
'registry': {'host': '192.168.20.253'},
'service': {'host': '192.168.20.253'}
},
'metering': {
'service': {'host': '192.168.20.253'}
},
'volume': {
'service': {'host': '192.168.20.253'}
},
'ec2': {
'admin': {'host': '192.168.20.253'},
'service': {'host': '192.168.20.253'}
},
'identity': {
'admin': {'host': u'192.168.20.253'},
'service': {'host': u'192.168.20.253'}
},
},
},
},
},
}

View File

@ -167,19 +167,25 @@ class TestEndToEnd(unittest2.TestCase):
def _mock_chef(self, configs):
"""mock chef."""
self.chef_autoconfigure_backup_ = chef.autoconfigure
chef.chef_databag_backup_ = chef.DataBag
chef.autoconfigure = mock.Mock()
chef.DataBag = mock.Mock()
import collections
class _mockDataBag(object):
"""mock databag class."""
def __init__(in_self, bag_name, api):
in_self.name = bag_name
class _mockDataBagItem(collections.Mapping):
"""mock databag item class."""
def __init__(in_self, bag, bag_item_name, api):
in_self.bag_name_ = bag.name
in_self.bag_item_name_ = bag_item_name
in_self.config_ = configs.get(bag_item_name, {})
in_self.run_list = mock.Mock(side_effect=_mockRunList)
in_self.config_ = configs.get(
in_self.bag_name_, {}
).get(
bag_item_name, {}
)
def __len__(in_self):
return len(in_self.config_)
@ -202,24 +208,18 @@ class TestEndToEnd(unittest2.TestCase):
def save(in_self):
"""mock save."""
configs[in_self.bag_item_name_] = in_self.config_
configs.setdefault(
in_self.bag_name_, {}
)[
in_self.bag_item_name_
] = in_self.config_
class _mockRunList(collections.Set):
def __init__(in_self, node_name, api):
in_self.node_name = node_name
in_self.config_ = []
class _mockClient(object):
def __init__(in_self, client_name, api):
pass
def __len__(in_self, api):
return len(in_self.config_)
def __iter__(in_self):
return iter(in_self.config_)
def __getitem__(in_self):
return in_self.config_
def append(in_self, role):
in_self.config_.append(role)
def delete(in_self):
pass
class _mockNode(collections.Mapping):
"""mock node class."""
@ -227,7 +227,7 @@ class TestEndToEnd(unittest2.TestCase):
def __init__(in_self, node_name, api):
in_self.node_name_ = node_name
in_self.config_ = configs.get(node_name, {})
in_self.run_list = mock.Mock(side_effect=_mockRunList)
in_self.run_list = []
def __len__(in_self):
return len(in_self.config_)
@ -241,18 +241,28 @@ class TestEndToEnd(unittest2.TestCase):
def __setitem__(in_self, name, value):
in_self.config_[name] = value
def delete(in_self):
del configs[in_self.node_name_]
def to_dict(in_self):
return in_self.config_
def get(in_self, key, default=None):
return in_self.config_.get(key, default)
def save(in_self):
"""mock save."""
configs[in_self.node_name_] = in_self.config_
configs[in_self.node_name_]['run_list'] = in_self.run_list
chef.chef_databag_backup_ = chef.DataBag
chef.DataBag = mock.Mock(side_effect=_mockDataBag)
self.chef_databagitem_backup_ = chef.DataBagItem
chef.DataBagItem = mock.Mock(side_effect=_mockDataBagItem)
self.chef_client_backup_ = chef.Client
chef.Client = mock.Mock()
chef.Client.return_value.delete = mock.Mock()
chef.Client = mock.Mock(side_effect=_mockClient)
self.chef_node_backup_ = chef.Node
chef.Node = mock.Mock(side_effect=_mockNode)
chef.Node.return_value.delete = mock.Mock()
def _check_chef(self, configs, expected_configs):
"""check chef config is generated correctly."""
@ -377,7 +387,7 @@ class TestEndToEnd(unittest2.TestCase):
host.cluster = clusters[cluster_name]
session.add(host)
def _mock_setting(self):
def _mock_setting(self, mock_global_config_filename='global_config'):
self.backup_os_installer_ = setting.OS_INSTALLER
self.backup_package_installer_ = setting.PACKAGE_INSTALLER
self.backup_cobbler_url_ = setting.COBBLER_INSTALLER_URL
@ -392,7 +402,7 @@ class TestEndToEnd(unittest2.TestCase):
setting.CONFIG_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'data')
setting.GLOBAL_CONFIG_FILENAME = 'global_config'
setting.GLOBAL_CONFIG_FILENAME = mock_global_config_filename
setting.CONFIG_FILE_FORMAT = 'python'
def _unmock_setting(self):
@ -453,6 +463,20 @@ class TestEndToEnd(unittest2.TestCase):
"""test deploy unexist roles."""
self._test('test4')
def test_5(self):
"""test deploy roles with testmode disabled."""
self._unmock_setting()
self._mock_setting('global_config2')
self._test('test5')
def test_6(self):
"""test deploy on 10 host."""
self._test('test6')
def test_7(self):
"""test deploy on 10 host with ha support."""
self._test('test7')
if __name__ == '__main__':
flags.init()

View File

@ -57,52 +57,76 @@ class TestConfigFilter(unittest2.TestCase):
def test_init(self):
config_filter.ConfigFilter(
allows=['abc', 'def'], denies=['def', 'ghi'])
allows={
'abc': config_filter.AllowRule(),
'def': config_filter.AllowRule()
},
denies={
'def': config_filter.DenyRule(),
'ghi': config_filter.DenyRule()
})
config_filter.ConfigFilter(
allows=[u'abc', u'def'], denies=[u'def', u'ghi'])
allows={
u'abc': config_filter.AllowRule(),
u'def': config_filter.AllowRule()
},
denies={
u'def': config_filter.DenyRule(),
u'ghi': config_filter.DenyRule()
})
def test_init_allows(self):
# allows type should be a list of string.
# allows type should be a dict of string to AllowRule.
self.assertRaises(
TypeError, config_filter.ConfigFilter,
allows={'abd': 'abc'})
allows=['abd', 'abc'])
self.assertRaises(
TypeError, config_filter.ConfigFilter,
allows='abc')
self.assertRaises(
TypeError, config_filter.ConfigFilter,
allows=[{'abc': 'bdc'}])
allows={'abc': 'bdc'})
def test_init_denies(self):
# denies type should be a list of string.
# denies type should be dict of string to DenyRule.
self.assertRaises(
TypeError, config_filter.ConfigFilter,
denies={'abd': 'abc'})
denies=['abd', 'abc'])
self.assertRaises(
TypeError, config_filter.ConfigFilter,
denies='abc')
self.assertRaises(
TypeError, config_filter.ConfigFilter,
denies=[{'abc': 'bdc'}])
denies={'abc': 'bdc'})
def test_allows_asterisks(self):
"""test allows rules."""
# keys in allows will be copied to dest.
# if '*' in allows, all keys will be copied to dest.
allows = ['*', '3', '5']
allows = {
'*': config_filter.AllowRule(),
'3': config_filter.AllowRule(),
'5': config_filter.AllowRule()
}
configfilter = config_filter.ConfigFilter(allows)
filtered_config = configfilter.filter(self.config_)
self.assertEqual(filtered_config, self.config_)
def test_allows_path(self):
allows = ['/1', '2/22', '5']
allows = {
'/1': config_filter.AllowRule(),
'2/22': config_filter.AllowRule(),
'5': config_filter.AllowRule()
}
expected_config = {'1': '1', '2': {'22': '22'}}
configfilter = config_filter.ConfigFilter(allows)
filtered_config = configfilter.filter(self.config_)
self.assertEqual(filtered_config, expected_config)
def test_allows_asterrisks_in_path(self):
allows = ['*/33']
allows = {
'*/33': config_filter.AllowRule()
}
expected_config = {'2': {'33': {'333': '333',
'44': '444'}},
'3': {'33': '44'}}
@ -113,20 +137,25 @@ class TestConfigFilter(unittest2.TestCase):
def test_denies(self):
"""test denies rules."""
# keys in denies list will be removed from filtered config.
denies = ['/1', '2/22', '2/33/333', '5']
denies = {
'/1': config_filter.DenyRule(),
'2/22': config_filter.DenyRule(),
'2/33/333': config_filter.DenyRule(),
'5': config_filter.DenyRule()
}
expected_config = {'2': {'33': {'44': '444'}}, '3': {'33': '44'}}
configfilter = config_filter.ConfigFilter(denies=denies)
filtered_config = configfilter.filter(self.config_)
self.assertEqual(filtered_config, expected_config)
def test_denies_asterisks(self):
denies = ['*']
denies = {'*': config_filter.DenyRule()}
configfilter = config_filter.ConfigFilter(denies=denies)
filtered_config = configfilter.filter(self.config_)
self.assertIsNone(filtered_config)
def tet_deneis_asterisks_in_path(self):
denies = ['*/33']
denies = {'*/33': config_filter.DenyRule()}
expected_config = {'1': '1', '2': {'22': '22'}}
configfilter = config_filter.ConfigFilter(denies=denies)
filtered_config = configfilter.filter(self.config_)

View File

@ -72,29 +72,29 @@ class TestAddValue(unittest2.TestCase):
def test_add_value_if_not_exist(self):
config = 'hello'
ref = config_reference.ConfigReference(config)
translated_config = ''
translated_config = None
translated_ref = config_reference.ConfigReference(translated_config)
new_value = config_translator_callbacks.add_value(
ref, None, translated_ref, None, condition=True)
self.assertEqual(new_value, 'hello')
ref, None, translated_ref, None)
self.assertEqual(new_value, ['hello'])
def test_add_value(self):
config = 'hello'
ref = config_reference.ConfigReference(config)
translated_config = 'hi'
translated_config = ['hi']
translated_ref = config_reference.ConfigReference(translated_config)
new_value = config_translator_callbacks.add_value(
ref, None, translated_ref, None, condition=True)
self.assertEqual(new_value, 'hi,hello')
ref, None, translated_ref, None)
self.assertEqual(new_value, ['hi', 'hello'])
def test_ignore_add_value(self):
config = 'hello'
ref = config_reference.ConfigReference(config)
translated_config = 'hi'
translated_config = ['hi']
translated_ref = config_reference.ConfigReference(translated_config)
new_value = config_translator_callbacks.add_value(
ref, None, translated_ref, None, condition=False)
self.assertEqual(new_value, 'hi')
self.assertEqual(new_value, ['hi'])
if __name__ == '__main__':

View File

@ -60,3 +60,5 @@ role_assign_policy = {
'bundles': [],
},
}
testmode = $compass_testmode

View File

@ -44,23 +44,24 @@ sudo sed -i "/COBBLER_INSTALLER_URL/c\COBBLER_INSTALLER_URL = 'http:\/\/$ipaddr/
sudo sed -i "/CHEF_INSTALLER_URL/c\CHEF_INSTALLER_URL = 'https:\/\/$ipaddr/'" /etc/compass/setting
sudo sed -i "s/\$compass_ip/$ipaddr/g" /etc/compass/global_config
sudo sed -i "s/\$compass_hostname/$HOSTNAME/g" /etc/compass/global_config
sudo sed -i "s/\$compass_testmode/$TESTMODE/g" /etc/compass/global_config
# add cookbooks, databags and roles
sudo chmod +x /opt/compass/bin/addcookbooks.py
sudo chmod +x /opt/compass/bin/adddatabags.py
sudo chmod +x /opt/compass/bin/addroles.py
sudo /opt/compass/bin/addcookbooks.py --cookbooks_dir=/var/chef/cookbooks
sudo /opt/compass/bin/addcookbooks.py
if [[ "$?" != "0" ]]; then
echo "failed to add cookbooks"
exit 1
fi
sudo /opt/compass/bin/adddatabags.py --databags_dir=/var/chef/databags
sudo /opt/compass/bin/adddatabags.py
if [[ "$?" != "0" ]]; then
echo "failed to add databags"
exit 1
fi
sudo /opt/compass/bin/addroles.py --roles_dir=/var/chef/roles
sudo /opt/compass/bin/addroles.py
if [[ "$?" != "0" ]]; then
echo "failed to add roles"
exit 1
@ -68,8 +69,15 @@ fi
# copy the chef validatation keys to cobbler snippets
sudo cp -rf /etc/chef-server/chef-validator.pem /var/lib/cobbler/snippets/chef-validator.pem
if [[ "$?" != "0" ]]; then
echo "failed to copy chef validation keys to cobbler snippets"
exit 1
fi
sudo sh /opt/compass/bin/refresh.sh
sudo /opt/compass/bin/refresh.sh
if [[ "$?" != "0" ]]; then
echo "failed to refresh compassd service
fi
sudo service httpd status
if [[ "$?" != "0" ]]; then

View File

@ -54,5 +54,8 @@ export WEB_SOURCE=${WEB_SOURCE:-}
export ADAPTERS_SOURCE=${ADAPTERS_SOURCE:-}
export WEB_GERRIT_URL=${WEB_GERRIT_URL:-}
export ADAPTERS_GERRIT_URL=${ADAPTERS_GERRIT_URL:-}
# Set compass environment
export SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export COMPASSDIR=${SCRIPT_DIR}/..
export TESTMODE=${TESTMODE:-"False"}

View File

@ -67,4 +67,4 @@ export NAMESERVERS=$ipaddr
export NTP_SERVER=$ipaddr
export GATEWAY=$ipaddr
export PROXY=http://$ipaddr:3128
export TESTMODE=${TESTMODE:-"True"}

View File

@ -66,7 +66,7 @@ if [[ ! -e /etc/tempest ]]; then
fi
#Initialize cloud environment for test and Tempest config file
cp etc/tempest.conf.sample /etc/tempest/tempest.conf
nova_api_host=`knife data bag show openstack openstack_1|grep management_ip |head -1 |awk '{print$2}'`
nova_api_host=$(knife search node 'roles:os-compute-api' | grep 'IP:' | awk '{print $2}' | head -1)
sshpass -p 'root' scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r root@$nova_api_host:/root/openrc /root/.
source /root/openrc
demo_tenant_id=`keystone tenant-create --name demo |grep " id " |awk '{print $4}'`