Add --dry-run option to undercloud install

This will help greatly with the development of the --use-heat path by
printing the underlying "undercloud deploy" command instead of
executing it. This may also help debug undercloud install issues in
the field.

Change-Id: I42ce297e5663ff782cfb6afa9058daf8abdf389b
Blueprint: containerized-undercloud
This commit is contained in:
Steve Baker 2018-02-14 09:53:57 +13:00
parent fedd1b26f8
commit 068ebe0306
3 changed files with 20 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
features:
- The ``openstack undercloud install`` command now has a ``--dry-run``
argument which will print the resulting install command instead of
executing it.

View File

@ -44,7 +44,7 @@ class TestUndercloudInstall(TestPluginV1):
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
mock_subprocess.assert_called_with('instack-install-undercloud')
mock_subprocess.assert_called_with(['instack-install-undercloud'])
@mock.patch('subprocess.check_call', autospec=True)
def test_undercloud_install_with_heat(self, mock_subprocess):

View File

@ -52,6 +52,13 @@ class InstallUndercloud(command.Command):
default=False,
help=_("Do not perform undercloud configuration validations"),
)
parser.add_argument(
'--dry-run',
dest='dry_run',
action='store_true',
default=False,
help=_("Print the install command instead of running it"),
)
return parser
def take_action(self, parsed_args):
@ -59,13 +66,15 @@ class InstallUndercloud(command.Command):
utils.ensure_run_as_normal_user()
if parsed_args.use_heat:
no_validations = parsed_args.dry_run or parsed_args.no_validations
cmd = undercloud_config.\
prepare_undercloud_deploy(no_validations=parsed_args.
no_validations)
print("Running: %s" % ' '.join(cmd))
subprocess.check_call(cmd)
prepare_undercloud_deploy(no_validations=no_validations)
else:
subprocess.check_call("instack-install-undercloud")
cmd = ["instack-install-undercloud"]
if parsed_args.dry_run:
print(' '.join(cmd))
else:
subprocess.check_call(cmd)
class UpgradeUndercloud(InstallUndercloud):