Merge "Modifying Openstack client for undercloud and overcloud backup"

changes/67/775067/1
Zuul 2 years ago committed by Gerrit Code Review
commit f20fa8aaea
  1. 142
      tripleoclient/tests/v1/overcloud_backup/test_backup.py
  2. 150
      tripleoclient/tests/v1/undercloud/test_backup.py
  3. 157
      tripleoclient/v1/overcloud_backup.py
  4. 129
      tripleoclient/v1/undercloud_backup.py

@ -20,6 +20,7 @@ from osc_lib.tests import utils
from tripleoclient import constants
from tripleoclient.tests import fakes
from tripleoclient.v1 import overcloud_backup
from unittest.mock import call
class TestOvercloudBackup(utils.TestCommand):
@ -48,10 +49,11 @@ class TestOvercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='cli-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
extra_vars={}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
@ -69,43 +71,86 @@ class TestOvercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
skip_tags='bar_create_recover_image, bar_setup_nfs_server',
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
extra_vars={}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_backup_storage_ip(self, mock_playbook):
def test_overcloud_backup_init_nfs(self, mock_playbook):
arglist = [
'--init',
'--storage-ip',
'192.168.0.100'
'nfs'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
extra_vars = {
"tripleo_backup_and_restore_nfs_server": parsed_args.storage_ip
}
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
skip_tags='bar_create_recover_image, bar_setup_nfs_server',
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=extra_vars
extra_vars={}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_backup_init_with_inventory(self, mock_playbook):
def test_overcloud_backup_setup_nfs(self, mock_playbook):
arglist = [
'--init',
'--setup-nfs'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars={}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_backup_setup_rear(self, mock_playbook):
arglist = [
'--setup-rear',
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars={}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True)
def test_overcloud_backup_setup_nfs_rear_with_inventory(self,
mock_playbook):
arglist = [
'--setup-nfs',
'--setup-rear',
'--inventory',
'/tmp/test_inventory.yaml'
]
@ -113,15 +158,77 @@ class TestOvercloudBackup(utils.TestCommand):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
calls = [call(workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars={}),
call(workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars={})]
mock_playbook.assert_has_calls(calls)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_backup_setup_rear_extra_vars_inline(self,
mock_playbook):
arglist = [
'--setup-rear',
'--extra-vars',
'{"tripleo_backup_and_restore_nfs_server": "192.168.24.1"}'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
extra_vars_dict = {
'tripleo_backup_and_restore_nfs_server': '192.168.24.1'
}
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
skip_tags='bar_create_recover_image, bar_setup_nfs_server',
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=extra_vars_dict
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_backup_setup_rear_with_extra_vars(self, mock_playbook):
arglist = [
'--setup-rear',
'--extra-vars',
'/tmp/test_vars.yaml'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
extra_vars='/tmp/test_vars.yaml'
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
@ -140,8 +247,9 @@ class TestOvercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='cli-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
extra_vars={}
)

@ -20,6 +20,7 @@ from osc_lib.tests import utils
from tripleoclient import constants
from tripleoclient.tests import fakes
from tripleoclient.v1 import undercloud_backup
from unittest.mock import call
class TestUndercloudBackup(utils.TestCommand):
@ -53,6 +54,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
tags=None,
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
@ -81,6 +83,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
tags=None,
skip_tags=None,
verbosity=3,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
@ -109,6 +112,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
tags=None,
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
@ -133,6 +137,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
tags=None,
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
@ -152,6 +157,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='cli-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
@ -173,19 +179,63 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='prepare-undercloud-backup.yaml',
inventory=parsed_args.inventory,
skip_tags='bar_create_recover_image',
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
)
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_undercloud_backup_init_with_inventory(self, mock_playbook):
def test_undercloud_backup_init_nfs(self, mock_playbook):
arglist = [
'--init',
'--inventory',
'/tmp/test_inventory.yaml'
'nfs'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_undercloud_backup_setup_nfs(self, mock_playbook):
arglist = [
'--setup-nfs'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_undercloud_backup_setup_rear(self, mock_playbook):
arglist = [
'--setup-rear'
]
verifylist = []
@ -196,10 +246,97 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='prepare-undercloud-backup.yaml',
inventory=parsed_args.inventory,
skip_tags='bar_create_recover_image',
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_undercloud_backup_setup_rear_extra_vars_inline(self,
mock_playbook):
arglist = [
'--setup-rear',
'--extra-vars',
'{"tripleo_backup_and_restore_nfs_server": "192.168.24.1"}'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
extra_vars_dict = {
'tripleo_backup_and_restore_nfs_server': '192.168.24.1'
}
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=extra_vars_dict
)
@mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True)
def test_undercloud_backup_setup_nfs_rear_with_inventory(self,
mock_playbook):
arglist = [
'--setup-nfs',
'--setup-rear',
'--inventory',
'/tmp/test_inventory.yaml'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
calls = [call(workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None),
call(workdir=mock.ANY,
playbook='prepare-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars=None)]
mock_playbook.assert_has_calls(calls)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_undercloud_backup_setup_nfs_with_extra_vars(self, mock_playbook):
arglist = [
'--setup-nfs',
'--extra-vars',
'/tmp/test_vars.yaml'
]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,
extra_vars='/tmp/test_vars.yaml'
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
@ -218,6 +355,7 @@ class TestUndercloudBackup(utils.TestCommand):
workdir=mock.ANY,
playbook='cli-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=3,

@ -15,6 +15,8 @@
import argparse
import logging
import os
import yaml
from osc_lib.command import command
from osc_lib.i18n import _
@ -37,62 +39,167 @@ class BackupOvercloud(command.Command):
parser.add_argument(
'--init',
const='rear',
nargs='?',
action='store',
help=_("Initialize environment for backup,"
"using 'rear' or 'nfs' as args "
"which will check for package install "
"and configured ReaR or NFS server. "
"Defaults to: rear. "
"i.e. --init rear. "
"WARNING: This flag will be deprecated"
"and replaced by '--setup-rear' and"
"'--setup-nfs'.")
)
parser.add_argument(
'--setup-nfs',
default=False,
action='store_true',
help=_("Setup the NFS server on the backup node "
"which will install required packages "
"and configuration on the host 'BackupNode' "
"in the ansible inventory.")
)
parser.add_argument(
'--setup-rear',
default=False,
action='store_true',
help=_("Initialize enviornment for backup,"
"which will check for package install"
"status and configured ReaR.")
help=_("Setup ReaR on the overcloud 'Controller' hosts which will "
"install and configure ReaR.")
)
parser.add_argument(
'--inventory',
default='/home/stack/tripleo-inventory.yaml',
help=_("Tripleo inventory file generated with"
"tripleo-ansible-inventory command.")
help=_("Tripleo inventory file generated with "
"tripleo-ansible-inventory command. "
"Defaults to: /home/stack/tripleo-inventory.yaml.")
)
parser.add_argument(
'--storage-ip',
help=_("Storage IP is an optional parameter"
"which allows for an ip of a storage"
"server to be specified, overriding the"
"default undercloud.")
help=_("Storage IP is an optional parameter "
"which allows for an ip of a storage "
"server to be specified, overriding the "
"default undercloud. "
"WARNING: This flag will be deprecated in "
"favor of '--extra-vars' which will allow "
"to pass this and other variables.")
)
parser.add_argument(
'--extra-vars',
default=None,
action='store',
help=_("Set additional variables as Dict or as "
"an absolute path of a JSON or YAML file type. "
"i.e. --extra-vars '{\"key\": \"val\", "
" \"key2\": \"val2\"}' "
"i.e. --extra-vars /path/to/my_vars.yaml "
"i.e. --extra-vars /path/to/my_vars.json. "
"For more information about the variables that "
"can be passed, visit: https://opendev.org/openstack/"
"tripleo-ansible/src/branch/master/tripleo_ansible/"
"roles/backup_and_restore/defaults/main.yml.")
)
return parser
def _run_backup_Overcloud(self, parsed_args):
def _parse_extra_vars(self, raw_extra_vars):
if raw_extra_vars is None:
return {}
elif os.path.exists(raw_extra_vars):
with open(raw_extra_vars, 'r') as fp:
extra_vars = yaml.safe_load(fp.read())
else:
try:
extra_vars = yaml.safe_load(raw_extra_vars)
except yaml.YAMLError as exc:
raise RuntimeError(
_('--extra-vars is not an existing file and cannot be '
'parsed as YAML / JSON: %s') % exc)
return extra_vars
def _run_backup_overcloud(self, parsed_args):
"""Backup defined overcloud nodes."""
if parsed_args.init is False:
playbook = 'cli-overcloud-backup.yaml'
skip_tags = None
elif parsed_args.init is True:
playbook = 'prepare-overcloud-backup.yaml'
skip_tags = 'bar_create_recover_image, bar_setup_nfs_server'
extra_vars = self._parse_extra_vars(parsed_args.extra_vars)
if parsed_args.storage_ip:
extra_vars = {
"tripleo_backup_and_restore_nfs_server": parsed_args.storage_ip
}
else:
extra_vars = None
storage_ip = parsed_args.storage_ip
extra_vars[
'tripleo_backup_and_restore_nfs_server'
] = storage_ip
if parsed_args.setup_nfs is True or parsed_args.init == 'nfs':
LOG.debug(_('Setting up NFS Backup node'))
self._run_ansible_playbook(
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
extra_vars=extra_vars
)
if parsed_args.setup_rear is True or parsed_args.init == 'rear':
LOG.debug(_('Installing ReaR on controller nodes'))
self._run_ansible_playbook(
playbook='prepare-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
extra_vars=extra_vars
)
if (parsed_args.setup_nfs is False and
parsed_args.setup_rear is False and
parsed_args.init is None):
LOG.debug(_('Starting Overcloud Backup'))
self._run_ansible_playbook(
playbook='cli-overcloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
extra_vars=extra_vars
)
def _run_ansible_playbook(self,
playbook,
inventory,
tags,
skip_tags,
extra_vars):
"""Run ansible playbook"""
LOG.debug(_('Starting Overcloud Backup'))
with utils.TempDirs() as tmp:
utils.run_ansible_playbook(
playbook=playbook,
inventory=parsed_args.inventory,
inventory=inventory,
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
tags=tags,
skip_tags=skip_tags,
verbosity=utils.playbook_verbosity(self=self),
extra_vars=extra_vars
)
)
def take_action(self, parsed_args):
self._run_backup_Overcloud(parsed_args)
if parsed_args.init:
LOG.warning("The following flags will be deprecated:"
"[--init, --storage-ip]")
self._run_backup_overcloud(parsed_args)
print(
'\n'
' #############################################################\n'

@ -15,6 +15,8 @@
import argparse
import logging
import os
import yaml
from osc_lib.command import command
from osc_lib.i18n import _
@ -35,14 +37,40 @@ class BackupUndercloud(command.Command):
add_help=False
)
# New flags for tripleo-ansible backup and restore role.
parser.add_argument(
'--init',
const='rear',
nargs='?',
action='store',
help=_("Initialize environment for backup,"
"using 'rear' or 'nfs' as args "
"which will check for package install "
"and configured ReaR or NFS server. "
"Defaults to: rear. "
"i.e. --init rear. "
"WARNING: This flag will be deprecated"
"and replaced by '--setup-rear' and"
"'--setup-nfs'.")
)
# New flags for tripleo-ansible backup and restore role.
parser.add_argument(
'--setup-nfs',
default=False,
action='store_true',
help=_("Setup the NFS server on the backup node"
"which will install required packages"
"and configuration on the host 'BackupNode' "
"in the ansible inventory.")
)
parser.add_argument(
'--setup-rear',
default=False,
action='store_true',
help=_("Initialize enviornment for backup,"
"which will check for package install"
"status and configured ReaR.")
help=_("Setup ReaR on the 'Undercloud' host which will"
"install and configure ReaR.")
)
parser.add_argument(
@ -50,7 +78,8 @@ class BackupUndercloud(command.Command):
action='store',
default='/home/stack/tripleo-inventory.yaml',
help=_("Tripleo inventory file generated with"
"tripleo-ansible-inventory command.")
"tripleo-ansible-inventory command. "
"Defaults to: /home/stack/tripleo-inventory.yaml.")
)
# Parameter to choose the files to backup
@ -61,8 +90,9 @@ class BackupUndercloud(command.Command):
help=_("Add additional files to backup. "
"Defaults to: /home/stack/ "
"i.e. --add-path /this/is/a/folder/ "
" --add-path /this/is/a/texfile.txt")
" --add-path /this/is/a/texfile.txt.")
)
parser.add_argument(
"--exclude-path",
default=[],
@ -71,8 +101,9 @@ class BackupUndercloud(command.Command):
"this option can be specified multiple times. "
"Defaults to: none "
"i.e. --exclude-path /this/is/a/folder/ "
" --exclude-path /this/is/a/texfile.txt")
" --exclude-path /this/is/a/texfile.txt.")
)
parser.add_argument(
'--save-swift',
default=False,
@ -81,26 +112,79 @@ class BackupUndercloud(command.Command):
"Defaults to: False "
"Special attention should be taken that "
"Swift itself is backed up if you call this multiple times "
"the backup size will grow exponentially")
"the backup size will grow exponentially.")
)
parser.add_argument(
'--extra-vars',
default=None,
action='store',
help=_("Set additional variables as Dict or as "
"an absolute path of a JSON or YAML file type. "
"i.e. --extra-vars '{\"key\": \"val\", "
"\"key2\": \"val2\"}' "
"i.e. --extra-vars /path/to/my_vars.yaml "
"i.e. --extra-vars /path/to/my_vars.json. "
"For more information about the variables that "
"can be passed, visit: https://opendev.org/openstack/"
"tripleo-ansible/src/branch/master/tripleo_ansible/"
"roles/backup_and_restore/defaults/main.yml.")
)
return parser
def _parse_extra_vars(self, raw_extra_vars):
if raw_extra_vars is None:
return raw_extra_vars
elif os.path.exists(raw_extra_vars):
with open(raw_extra_vars, 'r') as fp:
extra_vars = yaml.safe_load(fp.read())
else:
try:
extra_vars = yaml.safe_load(raw_extra_vars)
except yaml.YAMLError as exc:
raise RuntimeError(
_('--extra-vars is not an existing file and cannot be '
'parsed as YAML / JSON: %s') % exc)
return extra_vars
def _run_backup_undercloud(self, parsed_args):
if parsed_args.init is False:
playbook = 'cli-undercloud-backup.yaml'
skip_tags = None
elif parsed_args.init is True:
playbook = 'prepare-undercloud-backup.yaml'
skip_tags = 'bar_create_recover_image'
extra_vars = self._parse_extra_vars(parsed_args.extra_vars)
self._run_ansible_playbook(
playbook=playbook,
inventory=parsed_args.inventory,
skip_tags=skip_tags,
extra_vars=None
)
if parsed_args.setup_nfs is True or parsed_args.init == 'nfs':
self._run_ansible_playbook(
playbook='prepare-nfs-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_nfs_server',
skip_tags=None,
extra_vars=extra_vars
)
if parsed_args.setup_rear is True or parsed_args.init == 'rear':
self._run_ansible_playbook(
playbook='prepare-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_setup_rear',
skip_tags=None,
extra_vars=extra_vars
)
if (parsed_args.setup_nfs is False and
parsed_args.setup_rear is False and
parsed_args.init is None):
self._run_ansible_playbook(
playbook='cli-undercloud-backup.yaml',
inventory=parsed_args.inventory,
tags='bar_create_recover_image',
skip_tags=None,
extra_vars=extra_vars
)
def _legacy_backup_undercloud(self, parsed_args):
"""Legacy backup undercloud.
@ -127,6 +211,7 @@ class BackupUndercloud(command.Command):
self._run_ansible_playbook(
playbook='cli-undercloud-backup-legacy.yaml',
inventory='localhost, ',
tags=None,
skip_tags=None,
extra_vars=extra_vars
)
@ -134,6 +219,7 @@ class BackupUndercloud(command.Command):
def _run_ansible_playbook(self,
playbook,
inventory,
tags,
skip_tags,
extra_vars):
"""Run ansible playbook"""
@ -144,6 +230,7 @@ class BackupUndercloud(command.Command):
inventory=inventory,
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
tags=tags,
skip_tags=skip_tags,
verbosity=utils.playbook_verbosity(self=self),
extra_vars=extra_vars
@ -154,7 +241,7 @@ class BackupUndercloud(command.Command):
if len(parsed_args.add_path) > 1 or parsed_args.save_swift:
LOG.warning("The following flags will be deprecated:"
"[--add-path, --exclude-path, --save-swift]")
"[--add-path, --exclude-path, --init, --save-swift]")
self._legacy_backup_undercloud(parsed_args)

Loading…
Cancel
Save