Merge "Automatically run overcloud export when using ephemeral heat"

This commit is contained in:
Zuul 2021-04-29 22:19:27 +00:00 committed by Gerrit Code Review
commit ddef2fb6f2
4 changed files with 42 additions and 13 deletions

View File

@ -91,6 +91,9 @@ def export_stack(heat, stack, should_filter=False,
file = os.path.join(config_download_dir, file = os.path.join(config_download_dir,
stack, stack,
export_param["file"]) export_param["file"])
if not os.path.exists(file):
LOG.warning('File %s was not found during export' %
file)
with open(file, 'r') as ff: with open(file, 'r') as ff:
try: try:
export_data = json.load(ff) export_data = json.load(ff)

View File

@ -68,6 +68,7 @@ from tripleo_common.utils import stack as stack_utils
from tripleo_common import update from tripleo_common import update
from tripleoclient import constants from tripleoclient import constants
from tripleoclient import exceptions from tripleoclient import exceptions
from tripleoclient import export
from tripleoclient import heat_launcher from tripleoclient import heat_launcher
try: try:
@ -2636,3 +2637,15 @@ def get_default_working_dir(stack):
return os.path.join( return os.path.join(
os.path.expanduser('~'), os.path.expanduser('~'),
"overcloud-deploy", stack) "overcloud-deploy", stack)
def export_overcloud(heat, stack, excludes, should_filter,
config_download_dir):
data = export.export_passwords(heat, stack, excludes)
data.update(export.export_stack(
heat, stack, should_filter, config_download_dir))
# do not add extra host entries for VIPs for stacks deployed off that
# exported data, since it already contains those entries
data.update({'AddVipsToEtcHosts': False})
data = dict(parameter_defaults=data)
return data

View File

@ -1200,6 +1200,24 @@ class DeployOvercloud(command.Command):
utils.copy_clouds_yaml(user) utils.copy_clouds_yaml(user)
utils.create_tempest_deployer_input(output_dir=self.working_dir) utils.create_tempest_deployer_input(output_dir=self.working_dir)
try:
if (parsed_args.heat_type != 'installed' and
parsed_args.config_download):
# Create overcloud export
data = utils.export_overcloud(
self.orchestration_client,
parsed_args.stack, True, False,
config_download_dir)
export_file = os.path.join(
self.working_dir, "%s-export.yaml" % parsed_args.stack)
# write the exported data
with open(export_file, 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False)
os.chmod(export_file, 0o600)
except Exception as e:
self.log.error('Exception creating overcloud export.')
self.log.error(e)
print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Endpoint: {0}".format(overcloud_endpoint))
print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url)) print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url))
print("Overcloud rc file: {} and {}".format( print("Overcloud rc file: {} and {}".format(

View File

@ -16,10 +16,10 @@ import os.path
import yaml import yaml
from osc_lib.i18n import _ from osc_lib.i18n import _
from osc_lib import utils from osc_lib import utils as osc_utils
from tripleoclient import command from tripleoclient import command
from tripleoclient import export from tripleoclient import utils
class ExportOvercloud(command.Command): class ExportOvercloud(command.Command):
@ -36,8 +36,9 @@ class ExportOvercloud(command.Command):
help=_('Name of the environment main Heat stack ' help=_('Name of the environment main Heat stack '
'to export information from. ' 'to export information from. '
'(default=Env: OVERCLOUD_STACK_NAME)'), '(default=Env: OVERCLOUD_STACK_NAME)'),
default=utils.env('OVERCLOUD_STACK_NAME', default=osc_utils.env(
default='overcloud')) 'OVERCLOUD_STACK_NAME',
default='overcloud'))
parser.add_argument('--output-file', '-o', metavar='<output file>', parser.add_argument('--output-file', '-o', metavar='<output file>',
help=_('Name of the output file for the stack ' help=_('Name of the output file for the stack '
'data export. It will default to ' 'data export. It will default to '
@ -86,15 +87,9 @@ class ExportOvercloud(command.Command):
# prepare clients to access the environment # prepare clients to access the environment
clients = self.app.client_manager clients = self.app.client_manager
heat = clients.orchestration heat = clients.orchestration
data = export.export_passwords(heat, stack, data = utils.export_overcloud(
not parsed_args.no_password_excludes) heat, stack, excludes=not parsed_args.no_password_excludes,
data.update(export.export_stack( should_filter=False, config_download_dir=config_download_dir)
heat, stack, False, config_download_dir))
# do not add extra host entries for VIPs for stacks deployed off that
# exported data, since it already contains those entries
data.update({'AddVipsToEtcHosts': False})
data = dict(parameter_defaults=data)
# write the exported data # write the exported data
with open(output_file, 'w') as f: with open(output_file, 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False) yaml.safe_dump(data, f, default_flow_style=False)