Merge "Revert "task-core file generation""
This commit is contained in:
commit
83eaf53e4b
@ -838,60 +838,3 @@ def generate_tripleo_ansible_inventory(heat=None,
|
||||
|
||||
inv.write_static_inventory(inventory_path)
|
||||
return inventory_path
|
||||
|
||||
|
||||
def task_core_inventory(stack_outputs, host_network=HOST_NETWORK):
|
||||
inv = {
|
||||
'hosts': {}
|
||||
}
|
||||
task_core_data = stack_outputs.get('RoleConfig',
|
||||
{}).get('task_core_data', {})
|
||||
deploy_data = task_core_data.get('deployment_host', {})
|
||||
if deploy_data.get('hostname'):
|
||||
inv['hosts'][deploy_data.get('hostname')] = {'role': 'deployer'}
|
||||
|
||||
# overcloud nodes
|
||||
role_net_hostname_map = stack_outputs.get(
|
||||
'RoleNetHostnameMap', {})
|
||||
for role_name, hostnames in role_net_hostname_map.items():
|
||||
if not hostnames:
|
||||
continue
|
||||
names = hostnames.get(host_network) or []
|
||||
shortnames = [n.split(".%s." % host_network)[0].lower()
|
||||
for n in names]
|
||||
for name in shortnames:
|
||||
if inv['hosts'].get(name):
|
||||
LOG.warning("task-core inventory already contains %s, "
|
||||
"overriding it", inv['hosts'].get(name))
|
||||
inv['hosts'][name] = {'role': role_name.lower()}
|
||||
return inv
|
||||
|
||||
|
||||
def directord_inventory(stack_outputs, host_network=HOST_NETWORK):
|
||||
inv = {
|
||||
'directord_server': {
|
||||
'args': {},
|
||||
'targets': []
|
||||
},
|
||||
'directord_clients': {
|
||||
'args': {},
|
||||
'targets': []
|
||||
}
|
||||
}
|
||||
task_core_data = stack_outputs.get(
|
||||
'RoleConfig', {}).get('task_core_data', {})
|
||||
deploy_data = task_core_data.get('deployment_host', {})
|
||||
server_targets = inv['directord_server']['targets']
|
||||
if deploy_data.get('hostname'):
|
||||
server_targets.append({'host': deploy_data.get('ip')})
|
||||
|
||||
client_targets = inv['directord_clients']['targets']
|
||||
role_net_ip = stack_outputs.get('RoleNetIpMap', {})
|
||||
for role_name in role_net_ip.keys():
|
||||
# get the host network ips (default is ctlplane)
|
||||
ips = role_net_ip[role_name].get(host_network) or []
|
||||
if not ips:
|
||||
continue
|
||||
for ip in ips:
|
||||
client_targets.append({'host': ip})
|
||||
return inv
|
||||
|
@ -42,7 +42,6 @@ class TestConfig(base.TestCase):
|
||||
def setUp(self):
|
||||
super(TestConfig, self).setUp()
|
||||
|
||||
@patch.object(ooo_config.Config, 'render_task_core')
|
||||
@patch.object(ooo_config.Config, 'initialize_git_repo')
|
||||
@patch.object(ooo_config.shutil, 'copyfile')
|
||||
@patch.object(ooo_config.Config, '_mkdir')
|
||||
@ -53,8 +52,7 @@ class TestConfig(base.TestCase):
|
||||
mock_open,
|
||||
mock_mkdir,
|
||||
mock_copyfile,
|
||||
mock_git_init,
|
||||
mock_task_core):
|
||||
mock_git_init):
|
||||
config_type_list = ['config_settings', 'global_config_settings',
|
||||
'logging_sources', 'monitoring_subscriptions',
|
||||
'service_config_settings',
|
||||
@ -95,7 +93,6 @@ class TestConfig(base.TestCase):
|
||||
(role, config))]
|
||||
mock_open.assert_has_calls(expected_calls, any_order=True)
|
||||
|
||||
@patch.object(ooo_config.Config, 'render_task_core')
|
||||
@patch.object(ooo_config.Config, 'initialize_git_repo')
|
||||
@patch.object(ooo_config.shutil, 'copyfile')
|
||||
@patch.object(ooo_config.Config, '_mkdir')
|
||||
@ -106,8 +103,7 @@ class TestConfig(base.TestCase):
|
||||
mock_open,
|
||||
mock_mkdir,
|
||||
mock_copyfile,
|
||||
mock_git_init,
|
||||
mock_task_core):
|
||||
mock_git_init):
|
||||
|
||||
expected_config_type = 'config_settings'
|
||||
|
||||
@ -641,7 +637,6 @@ class TestConfig(base.TestCase):
|
||||
assert "Skipping deployment" in str(w[-1].message)
|
||||
assert "Skipping deployment" in str(w[-2].message)
|
||||
|
||||
@patch.object(ooo_config.Config, 'render_task_core')
|
||||
@patch.object(ooo_config.Config, 'initialize_git_repo')
|
||||
@patch.object(ooo_config.git, 'Repo')
|
||||
@patch.object(ooo_config.shutil, 'copyfile')
|
||||
@ -656,8 +651,7 @@ class TestConfig(base.TestCase):
|
||||
mock_mkdir,
|
||||
mock_copyfile,
|
||||
mock_repo,
|
||||
mock_git_init,
|
||||
mock_task_core):
|
||||
mock_git_init):
|
||||
config_type_list = ['config_settings', 'global_config_settings',
|
||||
'logging_sources', 'monitoring_subscriptions',
|
||||
'service_config_settings',
|
||||
|
@ -26,7 +26,7 @@ import yaml
|
||||
import jinja2
|
||||
|
||||
from tripleo_common import constants
|
||||
from tripleo_common import inventory
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -220,9 +220,6 @@ class Config(object):
|
||||
os.makedirs(os.path.join(config_dir, d), mode=0o700,
|
||||
exist_ok=True)
|
||||
|
||||
os.makedirs(os.path.join(config_dir, 'task_core'), mode=0o700,
|
||||
exist_ok=True)
|
||||
|
||||
def fetch_config(self, name):
|
||||
# Get the stack object
|
||||
stack = self.client.stacks.get(name)
|
||||
@ -260,85 +257,6 @@ class Config(object):
|
||||
with self._open_file(config_path) as f:
|
||||
f.write(str_config)
|
||||
|
||||
def render_task_core(self, name, config_dir, role_data, server_roles,
|
||||
role_group_vars, role_config):
|
||||
task_core_data = role_config.get('task_core_data', {})
|
||||
|
||||
# create task core data directories
|
||||
task_core_dir = os.path.join(config_dir, 'task_core')
|
||||
self._mkdir(task_core_dir)
|
||||
|
||||
task_core_services = []
|
||||
task_core_service_path = os.path.join(task_core_dir, 'services')
|
||||
self._mkdir(task_core_service_path)
|
||||
|
||||
task_core_roles_path = os.path.join(task_core_dir, 'roles')
|
||||
self._mkdir(task_core_roles_path)
|
||||
|
||||
# Render task-core deployment services from RoleConfig
|
||||
deploy_svcs = task_core_data.get('deployment_services', {})
|
||||
for svc, svc_data in deploy_svcs.items():
|
||||
svc_path = os.path.join(task_core_service_path, f"{svc}.yaml")
|
||||
with self._open_file(svc_path) as svc_file:
|
||||
if isinstance(svc_data, dict):
|
||||
yaml.safe_dump(svc_data, svc_file,
|
||||
default_flow_style=False)
|
||||
else:
|
||||
svc_file.write(svc_data)
|
||||
|
||||
# Render task core services from roles
|
||||
for role_name, role in role_data.items():
|
||||
for svc, svc_data in role.get('core_services', {}).items():
|
||||
# add service name for filtering the roles later to aide in
|
||||
# migration
|
||||
task_core_services.append(svc)
|
||||
svc_path = os.path.join(task_core_service_path, f"{svc}.yaml")
|
||||
if os.path.exists(svc_path):
|
||||
# already processed, just skip
|
||||
continue
|
||||
svc_data.update({'id': svc, 'type': 'service'})
|
||||
with self._open_file(svc_path) as svc_file:
|
||||
yaml.safe_dump(svc_data, svc_file,
|
||||
default_flow_style=False)
|
||||
|
||||
# Render task-core role for deployer from RoleConfig
|
||||
task_core_deployer_role_file = os.path.join(task_core_roles_path,
|
||||
"deployer.yaml")
|
||||
with self._open_file(task_core_deployer_role_file) as roles_file:
|
||||
deployment_roles = task_core_data.get('deployment_roles', {})
|
||||
yaml.safe_dump(deployment_roles, roles_file,
|
||||
default_flow_style=False)
|
||||
|
||||
# Render task-core roles file from RoleGroupVars, always include
|
||||
# deployment roles in overcloud role
|
||||
task_core_roles = deployment_roles
|
||||
for role in set(server_roles.values()):
|
||||
# RoleGroupVars has [role]ConfigData merged into it which
|
||||
# contains the enabled services for a role. Only add the services
|
||||
# that have core_services definitions
|
||||
enabled_svcs = role_group_vars[role].get('service_names', [])
|
||||
task_core_roles[role.lower()] = {
|
||||
'services': [svc for svc in enabled_svcs
|
||||
if svc in task_core_services]
|
||||
}
|
||||
task_core_overcloud_role_file = os.path.join(task_core_roles_path,
|
||||
f"{name}.yaml")
|
||||
with self._open_file(task_core_overcloud_role_file) as roles_file:
|
||||
yaml.safe_dump(task_core_roles, roles_file,
|
||||
default_flow_style=False)
|
||||
|
||||
task_core_inv_file = os.path.join(task_core_dir,
|
||||
"task-core-inventory.yaml")
|
||||
with self._open_file(task_core_inv_file) as inv_file:
|
||||
inv = inventory.task_core_inventory(self.stack_outputs)
|
||||
yaml.safe_dump(inv, inv_file, default_flow_style=False)
|
||||
|
||||
directord_inv_file = os.path.join(task_core_dir,
|
||||
"directord-inventory.yaml")
|
||||
with self._open_file(directord_inv_file) as inv_file:
|
||||
inv = inventory.directord_inventory(self.stack_outputs)
|
||||
yaml.safe_dump(inv, inv_file, default_flow_style=False)
|
||||
|
||||
def write_config(self, stack, name, config_dir, config_type=None):
|
||||
# Get role data:
|
||||
role_data = self.stack_outputs.get('RoleData', {})
|
||||
@ -554,9 +472,9 @@ class Config(object):
|
||||
|
||||
# Make sure server_roles is populated b/c it won't be if there are no
|
||||
# server deployments.
|
||||
for server_name, server_id in server_ids.items():
|
||||
for name, server_id in server_ids.items():
|
||||
server_roles.setdefault(
|
||||
server_name,
|
||||
name,
|
||||
self.get_role_from_server_id(stack, server_id))
|
||||
|
||||
env, templates_path = self.get_jinja_env(config_dir)
|
||||
@ -630,9 +548,6 @@ class Config(object):
|
||||
yaml.safe_dump(role_group_vars[role], group_vars_file,
|
||||
default_flow_style=False)
|
||||
|
||||
self.render_task_core(name, config_dir, role_data, server_roles,
|
||||
role_group_vars, role_config)
|
||||
|
||||
# Render host_vars
|
||||
for server in server_names.values():
|
||||
host_var_server_path = os.path.join(host_vars_dir, server)
|
||||
|
Loading…
x
Reference in New Issue
Block a user