Handle port unprovision for pre-provisioned nodes
Previously, if all instances in the input file were pre-provisioned
(managed:False), then the unprovision step was skipped, with no way to
unprovision network ports for pre-provisioned nodes.
This patch adds confirmation that network ports for pre-provisioned
nodes will also be unprovisioned, so that the user can confirm the set
of nodes and network ports that will be unprovisioned. Unprovisioning is
then executed so that network ports for pre-provisioned nodes are
deleted.
The related tripleo-ansible patch[1] adds the needed pre-provisioned
nodes data to the confirmation file so that it can be displayed by
tripleoclient.
[1] Id377b2c7ed973a7e2365b33dba2c1d59a59e26b9
Change-Id: Id7ebc59948cc6ad6c2270304c35ab0475259a6c0
Signed-off-by: James Slagle <jslagle@redhat.com>
(cherry picked from commit 5a3b62ceb6)
This commit is contained in:
@@ -408,14 +408,36 @@ class UnprovisionNode(command.Command):
|
||||
)
|
||||
with open(unprovision_confirm) as f:
|
||||
to_unprovision = json.load(f)
|
||||
if not to_unprovision:
|
||||
|
||||
# (TODO: slagle) unprovision_confirm was previously a list,
|
||||
# but was switched to a dict so that network ports for
|
||||
# pre_provisioned nodes can also be confirmed for
|
||||
# unprovisioning. Check the data structure for backwards
|
||||
# compatibility, When the tripleo-ansible patch is merged,
|
||||
# this check can be removed.
|
||||
if isinstance(to_unprovision, dict):
|
||||
instances = to_unprovision.get('instances')
|
||||
pre_provisioned = to_unprovision.get('pre_provisioned')
|
||||
else:
|
||||
instances = to_unprovision
|
||||
pre_provisioned = None
|
||||
|
||||
print()
|
||||
if not (instances or pre_provisioned):
|
||||
print('Nothing to unprovision, exiting')
|
||||
return
|
||||
self._print_nodes(to_unprovision)
|
||||
print("The following nodes will be unprovisioned:")
|
||||
self._print_nodes(instances)
|
||||
print()
|
||||
if pre_provisioned:
|
||||
print("The following pre-provisioned nodes will "
|
||||
"have network ports unprovisioned:")
|
||||
self._print_nodes(pre_provisioned)
|
||||
print()
|
||||
|
||||
confirm = oooutils.prompt_user_for_confirmation(
|
||||
message=_("Are you sure you want to unprovision these %s "
|
||||
"nodes [y/N]? ") % parsed_args.stack,
|
||||
"nodes and ports [y/N]? ") % parsed_args.stack,
|
||||
logger=self.log)
|
||||
if not confirm:
|
||||
raise oscexc.CommandError("Action not confirmed, exiting.")
|
||||
|
||||
Reference in New Issue
Block a user