Add commands to extract|provision net vips
Add command to extract Virtual IPs information from a deployed overcloud. This writes a 'vip_data' file that should be used when managing neutron Virtual IP resources "outside" the overcloud Heat stack. Add command to provision Virtual IPs using 'vip_data' file as input. This command will output a 'vip_environment' file with the resource_registry and paramters to replace the neutron resources in the overcloud Heat stack. Depends-On: https://review.opendev.org/774857 Partial-Implements: blueprint network-data-v2-ports Change-Id: Id9b5c621c25158bb72559c3d3c52a62c840b3a6a
This commit is contained in:
parent
4139b75157
commit
d24b41c62b
@ -57,6 +57,8 @@ openstack.tripleoclient.v2 =
|
||||
overcloud_image_upload = tripleoclient.v1.overcloud_image:UploadOvercloudImage
|
||||
overcloud_network_extract = tripleoclient.v2.overcloud_network:OvercloudNetworkExtract
|
||||
overcloud_network_provision = tripleoclient.v2.overcloud_network:OvercloudNetworkProvision
|
||||
overcloud_network_vip_extract = tripleoclient.v2.overcloud_network:OvercloudVirtualIPsExtract
|
||||
overcloud_network_vip_provision = tripleoclient.v2.overcloud_network:OvercloudVirtualIPsProvision
|
||||
overcloud_node_configure = tripleoclient.v1.overcloud_node:ConfigureNode
|
||||
overcloud_node_delete = tripleoclient.v1.overcloud_node:DeleteNode
|
||||
overcloud_node_import = tripleoclient.v2.overcloud_node:ImportNode
|
||||
|
@ -135,3 +135,122 @@ class OvercloudNetworkProvision(command.Command):
|
||||
verbosity=oooutils.playbook_verbosity(self=self),
|
||||
extra_vars=extra_vars,
|
||||
)
|
||||
|
||||
|
||||
class OvercloudVirtualIPsExtract(command.Command):
|
||||
|
||||
log = logging.getLogger(__name__ + ".OvercloudVirtualIPsExtract")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(OvercloudVirtualIPsExtract, self).get_parser(prog_name)
|
||||
parser.add_argument('--stack', dest='stack', required=True,
|
||||
help=_('Name of heat stack '
|
||||
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||
default=utils.env('OVERCLOUD_STACK_NAME',
|
||||
default='overcloud'))
|
||||
parser.add_argument('-o', '--output', required=True,
|
||||
metavar='<vip_data.yaml>',
|
||||
help=_('The output file path describing the '
|
||||
'Virtual IP deployment'))
|
||||
parser.add_argument('-y', '--yes', default=False, action='store_true',
|
||||
help=_('Skip yes/no prompt for existing files '
|
||||
'(assume yes).'))
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
output_path = os.path.abspath(parsed_args.output)
|
||||
|
||||
overwrite = parsed_args.yes
|
||||
if (os.path.exists(output_path) and not overwrite
|
||||
and not oooutils.prompt_user_for_confirmation(
|
||||
'Overwrite existing file %s [y/N]?' % parsed_args.output,
|
||||
self.log)):
|
||||
raise oscexc.CommandError("Will not overwrite existing file:"
|
||||
" %s" % parsed_args.output)
|
||||
else:
|
||||
overwrite = True
|
||||
|
||||
extra_vars = {
|
||||
"stack_name": parsed_args.stack,
|
||||
"output": output_path,
|
||||
"overwrite": overwrite
|
||||
}
|
||||
|
||||
with oooutils.TempDirs() as tmp:
|
||||
oooutils.run_ansible_playbook(
|
||||
playbook='cli-overcloud-network-vip-extract.yaml',
|
||||
inventory='localhost,',
|
||||
workdir=tmp,
|
||||
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
verbosity=oooutils.playbook_verbosity(self=self),
|
||||
extra_vars=extra_vars,
|
||||
)
|
||||
|
||||
|
||||
class OvercloudVirtualIPsProvision(command.Command):
|
||||
|
||||
log = logging.getLogger(__name__ + ".OvercloudVirtualIPsProvision")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(OvercloudVirtualIPsProvision, self).get_parser(
|
||||
prog_name)
|
||||
|
||||
parser.add_argument('vip_file',
|
||||
metavar='<vip_data.yaml>',
|
||||
help=_('Configuration file describing the network '
|
||||
'deployment.'))
|
||||
parser.add_argument('--stack', dest='stack', required=True,
|
||||
help=_('Name of heat stack '
|
||||
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||
default=utils.env('OVERCLOUD_STACK_NAME',
|
||||
default='overcloud'))
|
||||
parser.add_argument('-o', '--output', required=True,
|
||||
metavar='<vip_environment.yaml>',
|
||||
help=_('The output Virtual IP environment file '
|
||||
'path.'))
|
||||
parser.add_argument('-y', '--yes', default=False, action='store_true',
|
||||
help=_('Skip yes/no prompt for existing files '
|
||||
'(assume yes).'))
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
vip_file_path = os.path.abspath(parsed_args.vip_file)
|
||||
output_path = os.path.abspath(parsed_args.output)
|
||||
|
||||
if not os.path.exists(vip_file_path):
|
||||
raise oscexc.CommandError(
|
||||
"Virtual IPs configuration file does not exist:"
|
||||
" %s" % parsed_args.networks_file)
|
||||
|
||||
overwrite = parsed_args.yes
|
||||
if (os.path.exists(output_path) and not overwrite
|
||||
and not oooutils.prompt_user_for_confirmation(
|
||||
'Overwrite existing file %s [y/N]?' % parsed_args.output,
|
||||
self.log)):
|
||||
raise oscexc.CommandError("Will not overwrite existing file:"
|
||||
" %s" % parsed_args.output)
|
||||
else:
|
||||
overwrite = True
|
||||
|
||||
extra_vars = {
|
||||
"stack_name": parsed_args.stack,
|
||||
"vip_data_path": vip_file_path,
|
||||
"vip_deployed_path": output_path,
|
||||
"overwrite": overwrite
|
||||
}
|
||||
|
||||
with oooutils.TempDirs() as tmp:
|
||||
oooutils.run_ansible_playbook(
|
||||
playbook='cli-overcloud-network-vip-provision.yaml',
|
||||
inventory='localhost,',
|
||||
workdir=tmp,
|
||||
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
verbosity=oooutils.playbook_verbosity(self=self),
|
||||
extra_vars=extra_vars,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user