Add --disable-container-prepare flag
Users may want to skip the container prepare process to ensure they don't update their containers. This change adds a --disable-container-prepare flag to the following actions which should skip the preparation actions. - overcloud deploy (and updates) - overcloud plan actions - undercloud deploy (and upgrades) - tripleo deploy (and standalone deploy) Closes-Bug: #1896757 Depends-On: https://review.opendev.org/#/c/737522/ Change-Id: I30b448930f53aef108d9bdb544a6d02b18658b0d
This commit is contained in:
parent
5face64ed5
commit
0d84ac9234
|
@ -132,6 +132,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
"container": "overcast",
|
||||
"generate_passwords": True,
|
||||
"use_default_templates": True,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
@ -164,6 +165,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
"container": "overcast",
|
||||
"generate_passwords": True,
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
@ -205,6 +207,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
"generate_passwords": True,
|
||||
"plan_environment": "the_plan_environment.yaml",
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
@ -217,11 +220,13 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
self, mock_tmp, mock_cd, mock_run_playbook):
|
||||
|
||||
# Setup
|
||||
arglist = ['overcast', '--disable-password-generation']
|
||||
arglist = ['overcast', '--disable-password-generation',
|
||||
'--disable-container-prepare']
|
||||
verifylist = [
|
||||
('name', 'overcast'),
|
||||
('templates', None),
|
||||
('disable_password_generation', True)
|
||||
('disable_password_generation', True),
|
||||
('disable_container_prepare', True)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -238,6 +243,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
"container": "overcast",
|
||||
"generate_passwords": False,
|
||||
"use_default_templates": True,
|
||||
"disable_image_params_prepare": True,
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
@ -271,6 +277,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
|
|||
"generate_passwords": True,
|
||||
"use_default_templates": False,
|
||||
"source_url": "http://tripleo.org/templates",
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=3,
|
||||
)
|
||||
|
|
|
@ -51,6 +51,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=0,
|
||||
)
|
||||
|
@ -82,6 +83,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=0,
|
||||
)
|
||||
|
@ -118,6 +120,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
"generate_passwords": True,
|
||||
"plan_environment": "the-plan-environment.yaml",
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=0,
|
||||
)
|
||||
|
@ -152,6 +155,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=0,
|
||||
)
|
||||
|
@ -173,7 +177,8 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
self.app.client_manager,
|
||||
'test-overcloud',
|
||||
'/tht-root/',
|
||||
generate_passwords=False)
|
||||
generate_passwords=False,
|
||||
disable_image_params_prepare=True)
|
||||
|
||||
mock_run_playbook.assert_called_once_with(
|
||||
'cli-create-deployment-plan.yaml',
|
||||
|
@ -184,6 +189,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
|
|||
"container": "test-overcloud",
|
||||
"generate_passwords": False,
|
||||
"use_default_templates": False,
|
||||
"disable_image_params_prepare": True,
|
||||
},
|
||||
verbosity=0,
|
||||
)
|
||||
|
@ -268,6 +274,7 @@ class TestPlanUpdateWorkflows(base.TestCommand):
|
|||
extra_vars={
|
||||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=1,
|
||||
)
|
||||
|
@ -303,6 +310,7 @@ class TestPlanUpdateWorkflows(base.TestCommand):
|
|||
extra_vars={
|
||||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"disable_image_params_prepare": False,
|
||||
},
|
||||
verbosity=1,
|
||||
)
|
||||
|
@ -324,7 +332,8 @@ class TestPlanUpdateWorkflows(base.TestCommand):
|
|||
plan_management.update_plan_from_templates(
|
||||
self.app.client_manager,
|
||||
'test-overcloud',
|
||||
'/tht-root/')
|
||||
'/tht-root/',
|
||||
disable_image_params_prepare=True)
|
||||
# A dictionary without the "passwords" key is provided in
|
||||
# the _load_passwords method.
|
||||
mock_yaml_safe_load.return_value = {}
|
||||
|
@ -339,6 +348,7 @@ class TestPlanUpdateWorkflows(base.TestCommand):
|
|||
extra_vars={
|
||||
"container": "test-overcloud",
|
||||
"generate_passwords": True,
|
||||
"disable_image_params_prepare": True,
|
||||
},
|
||||
verbosity=1,
|
||||
)
|
||||
|
|
|
@ -451,7 +451,8 @@ class DeployOvercloud(command.Command):
|
|||
parsed_args.plan_environment_file,
|
||||
parsed_args.networks_file,
|
||||
type(self)._keep_env_on_update,
|
||||
verbosity_level=utils.playbook_verbosity(self=self)
|
||||
utils.playbook_verbosity(self=self),
|
||||
parsed_args.disable_container_prepare
|
||||
)
|
||||
else:
|
||||
plan_management.create_plan_from_templates(
|
||||
|
@ -459,7 +460,8 @@ class DeployOvercloud(command.Command):
|
|||
parsed_args.roles_file, generate_passwords,
|
||||
parsed_args.plan_environment_file,
|
||||
parsed_args.networks_file,
|
||||
verbosity_level=utils.playbook_verbosity(self=self)
|
||||
utils.playbook_verbosity(self=self),
|
||||
parsed_args.disable_container_prepare
|
||||
)
|
||||
|
||||
# Get any missing (e.g j2 rendered) files from the plan to tht_root
|
||||
|
@ -717,7 +719,7 @@ class DeployOvercloud(command.Command):
|
|||
"baremetal_deployment": roles,
|
||||
"baremetal_deployed_path": output_path,
|
||||
"ssh_public_keys": ssh_key,
|
||||
"ssh_user_name": parsed_args.overcloud_ssh_user,
|
||||
"ssh_user_name": parsed_args.overcloud_ssh_user
|
||||
}
|
||||
|
||||
with utils.TempDirs() as tmp:
|
||||
|
@ -1048,6 +1050,16 @@ class DeployOvercloud(command.Command):
|
|||
help=_('The number of Ansible forks to use for the'
|
||||
' config-download ansible-playbook command.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-container-prepare',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable the container preparation actions to prevent '
|
||||
'container tags from being updated and new containers '
|
||||
'from being fetched. If you skip this but do not have '
|
||||
'the container parameters configured, the deployment '
|
||||
'action may fail.')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
|
|
@ -104,7 +104,16 @@ class CreatePlan(command.Command):
|
|||
'to deploy. If this or --templates isn\'t provided, the '
|
||||
'templates packaged on the Undercloud will be used.')
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--disable-container-prepare',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable the container preparation actions to prevent '
|
||||
'container tags from being updated and new containers '
|
||||
'from being fetched. If you skip this but do not have '
|
||||
'the container parameters configured, the deployment '
|
||||
'action may fail.')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -120,12 +129,16 @@ class CreatePlan(command.Command):
|
|||
if not parsed_args.templates and not parsed_args.source_url:
|
||||
use_default_templates = True
|
||||
|
||||
# Needs this to avoid too long lines
|
||||
disable_container_prepare = parsed_args.disable_container_prepare
|
||||
|
||||
if parsed_args.templates:
|
||||
plan_management.create_plan_from_templates(
|
||||
clients, name, parsed_args.templates,
|
||||
generate_passwords=generate_passwords,
|
||||
plan_env_file=parsed_args.plan_environment_file,
|
||||
verbosity_level=utils.playbook_verbosity(self=self)
|
||||
verbosity_level=utils.playbook_verbosity(self=self),
|
||||
disable_image_params_prepare=disable_container_prepare
|
||||
)
|
||||
else:
|
||||
plan_management.create_deployment_plan(
|
||||
|
@ -133,7 +146,8 @@ class CreatePlan(command.Command):
|
|||
generate_passwords=generate_passwords,
|
||||
source_url=source_url,
|
||||
use_default_templates=use_default_templates,
|
||||
verbosity_level=utils.playbook_verbosity(self=self)
|
||||
verbosity_level=utils.playbook_verbosity(self=self),
|
||||
disable_image_params_prepare=disable_container_prepare
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -802,7 +802,8 @@ class Deploy(command.Command):
|
|||
environments, self.tht_render, parsed_args.templates,
|
||||
cleanup=parsed_args.cleanup)
|
||||
|
||||
self._prepare_container_images(env, roles_data)
|
||||
if not parsed_args.disable_container_prepare:
|
||||
self._prepare_container_images(env, roles_data)
|
||||
parameters.convert_docker_params(env)
|
||||
|
||||
self.log.debug(_("Getting template contents"))
|
||||
|
@ -1114,6 +1115,16 @@ class Deploy(command.Command):
|
|||
help=_('The number of Ansible forks to use for the'
|
||||
' config-download ansible-playbook command.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--disable-container-prepare',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable the container preparation actions to prevent '
|
||||
'container tags from being updated and new containers '
|
||||
'from being fetched. If you skip this but do not have '
|
||||
'the container parameters configured, the deployment '
|
||||
'action may fail.')
|
||||
)
|
||||
|
||||
stack_action_group = parser.add_mutually_exclusive_group()
|
||||
|
||||
|
|
|
@ -122,6 +122,16 @@ class InstallUndercloud(command.Command):
|
|||
parser.add_argument('-y', '--yes', default=False,
|
||||
action='store_true',
|
||||
help=_("Skip yes/no prompt (assume yes)."))
|
||||
parser.add_argument(
|
||||
'--disable-container-prepare',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Disable the container preparation actions to prevent '
|
||||
'container tags from being updated and new containers '
|
||||
'from being fetched. If you skip this but do not have '
|
||||
'the container parameters configured, the deployment '
|
||||
'action may fail.')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -140,7 +150,8 @@ class InstallUndercloud(command.Command):
|
|||
verbose_level=self.app_args.verbose_level,
|
||||
force_stack_update=parsed_args.force_stack_update,
|
||||
dry_run=parsed_args.dry_run,
|
||||
inflight=inflight)
|
||||
inflight=inflight,
|
||||
disable_container_prepare=parsed_args.disable_container_prepare)
|
||||
|
||||
self.log.warning("Running: %s" % ' '.join(cmd))
|
||||
if not parsed_args.dry_run:
|
||||
|
|
|
@ -437,7 +437,8 @@ def _process_chrony_acls(env):
|
|||
def prepare_undercloud_deploy(upgrade=False, no_validations=True,
|
||||
verbose_level=1, yes=False,
|
||||
force_stack_update=False, dry_run=False,
|
||||
inflight=False):
|
||||
inflight=False,
|
||||
disable_container_prepare=False):
|
||||
"""Prepare Undercloud deploy command based on undercloud.conf"""
|
||||
|
||||
if CONF.get('undercloud_hostname'):
|
||||
|
@ -836,6 +837,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=True,
|
|||
if inflight:
|
||||
deploy_args.append('--inflight-validations')
|
||||
|
||||
if disable_container_prepare:
|
||||
deploy_args.append('--disable-container-prepare')
|
||||
|
||||
if CONF.get('custom_env_files'):
|
||||
for custom_file in CONF['custom_env_files']:
|
||||
deploy_args += ['-e', custom_file]
|
||||
|
|
|
@ -66,7 +66,8 @@ def _upload_templates(swift_client, container_name, tht_root, roles_file=None,
|
|||
|
||||
def create_deployment_plan(container, generate_passwords,
|
||||
use_default_templates=False, source_url=None,
|
||||
verbosity_level=0, plan_env_file=None):
|
||||
verbosity_level=0, plan_env_file=None,
|
||||
disable_image_params_prepare=False):
|
||||
"""Create a deployment plan.
|
||||
|
||||
:param container: Container name to push to.
|
||||
|
@ -87,12 +88,16 @@ def create_deployment_plan(container, generate_passwords,
|
|||
|
||||
:param plan_env_file: Path to plan environment file
|
||||
:type plan_env_file: String
|
||||
|
||||
:param disable_image_params_prepare: Disable container params prepare task
|
||||
:type disable_image_params_prepare: Boolean
|
||||
"""
|
||||
|
||||
extra_vars = {
|
||||
"container": container,
|
||||
"generate_passwords": generate_passwords,
|
||||
"use_default_templates": use_default_templates,
|
||||
"disable_image_params_prepare": disable_image_params_prepare
|
||||
}
|
||||
|
||||
if source_url:
|
||||
|
@ -132,7 +137,8 @@ def delete_deployment_plan(clients, container):
|
|||
|
||||
|
||||
def update_deployment_plan(clients, container, generate_passwords,
|
||||
verbosity_level=0):
|
||||
verbosity_level=0,
|
||||
disable_image_params_prepare=False):
|
||||
"""Update a deployment plan.
|
||||
|
||||
:param clients: Application client object.
|
||||
|
@ -146,6 +152,9 @@ def update_deployment_plan(clients, container, generate_passwords,
|
|||
|
||||
:param verbosity_level: Verbosity level used in playbook execution
|
||||
:type verbosity_level: Integer
|
||||
|
||||
:param disable_image_params_prepare: Disable container params prepare task
|
||||
:type disable_image_params_prepare: Boolean
|
||||
"""
|
||||
|
||||
with utils.TempDirs() as tmp:
|
||||
|
@ -157,6 +166,7 @@ def update_deployment_plan(clients, container, generate_passwords,
|
|||
extra_vars={
|
||||
"container": container,
|
||||
"generate_passwords": generate_passwords,
|
||||
"disable_image_params_prepare": disable_image_params_prepare
|
||||
},
|
||||
verbosity=verbosity_level
|
||||
)
|
||||
|
@ -171,7 +181,8 @@ def list_deployment_plans(clients):
|
|||
|
||||
def create_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
generate_passwords=True, plan_env_file=None,
|
||||
networks_file=None, verbosity_level=0):
|
||||
networks_file=None, verbosity_level=0,
|
||||
disable_image_params_prepare=False):
|
||||
swift_client = clients.tripleoclient.object_store
|
||||
|
||||
print("Creating Swift container to store the plan")
|
||||
|
@ -183,10 +194,12 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None,
|
|||
plan_env_file, networks_file)
|
||||
|
||||
try:
|
||||
create_deployment_plan(container=name,
|
||||
generate_passwords=generate_passwords,
|
||||
plan_env_file=plan_env_file,
|
||||
verbosity_level=verbosity_level)
|
||||
create_deployment_plan(
|
||||
container=name,
|
||||
generate_passwords=generate_passwords,
|
||||
plan_env_file=plan_env_file,
|
||||
verbosity_level=verbosity_level,
|
||||
disable_image_params_prepare=disable_image_params_prepare)
|
||||
except exceptions.WorkflowServiceError:
|
||||
swiftutils.delete_container(swift_client, name)
|
||||
raise
|
||||
|
@ -195,7 +208,8 @@ def create_plan_from_templates(clients, name, tht_root, roles_file=None,
|
|||
def update_plan_from_templates(clients, name, tht_root, roles_file=None,
|
||||
generate_passwords=True, plan_env_file=None,
|
||||
networks_file=None, keep_env=False,
|
||||
verbosity_level=1):
|
||||
verbosity_level=1,
|
||||
disable_image_params_prepare=False):
|
||||
swift_client = clients.tripleoclient.object_store
|
||||
passwords = None
|
||||
keep_file_contents = {}
|
||||
|
@ -247,9 +261,11 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None,
|
|||
plan_env_file, networks_file)
|
||||
_update_passwords(swift_client, name, passwords)
|
||||
|
||||
update_deployment_plan(clients, container=name,
|
||||
generate_passwords=generate_passwords,
|
||||
verbosity_level=verbosity_level)
|
||||
update_deployment_plan(
|
||||
clients, container=name,
|
||||
generate_passwords=generate_passwords,
|
||||
verbosity_level=verbosity_level,
|
||||
disable_image_params_prepare=disable_image_params_prepare)
|
||||
|
||||
|
||||
def _load_content_or_file(swift_client, container, remote_and_local_map):
|
||||
|
|
Loading…
Reference in New Issue