BM Provisioning - Apply node network config

Update the node provision command to run the
playbook to apply network configurtion on
overcloud nodes.

Option --network-config must be used to enable.
When --network-config is enabled, --network-ports
is implied.

Partial-Implements: blueprint network-data-v2-ports
Depends-On: https://review.opendev.org/772976
Change-Id: I8f8a88ac5e872d96757b6f56f1caae323fe37338
This commit is contained in:
Harald Jensås 2021-01-29 07:25:01 +01:00
parent 3fc20a82b8
commit 05168008ff
1 changed files with 23 additions and 1 deletions

View File

@ -256,6 +256,11 @@ class ProvisionNode(command.Command):
help=_('Enable provisioning of network ports'),
default=False,
action="store_true")
parser.add_argument('--network-config',
help=_('Apply network config to provisioned '
'nodes. (Implies "--network-ports")'),
default=False,
action="store_true")
parser.add_argument(
'--working-dir', action='store',
help=_('The working directory for the deployment where all '
@ -293,7 +298,8 @@ class ProvisionNode(command.Command):
"ssh_user_name": parsed_args.overcloud_ssh_user,
"node_timeout": parsed_args.timeout,
"concurrency": parsed_args.concurrency,
"manage_network_ports": parsed_args.network_ports,
"manage_network_ports": (parsed_args.network_ports
or parsed_args.network_config),
"working_dir": working_dir
}
@ -307,6 +313,22 @@ class ProvisionNode(command.Command):
extra_vars=extra_vars,
)
if parsed_args.network_config:
inventory_file = os.path.join(working_dir,
'tripleo-ansible-inventory.yaml')
with open(inventory_file, 'r') as f:
inventory = yaml.safe_load(f.read())
with oooutils.TempDirs() as tmp:
oooutils.run_ansible_playbook(
playbook='cli-overcloud-node-network-config.yaml',
inventory=inventory,
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=oooutils.playbook_verbosity(self=self),
)
print('Nodes deployed successfully, add %s to your deployment '
'environment' % parsed_args.output)