Merge "Add --db-only option in undercloud_backup."
This commit is contained in:
commit
c1ef843790
@ -261,6 +261,35 @@ class TestUndercloudBackup(utils.TestCommand):
|
||||
extra_vars=None
|
||||
)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('os.access')
|
||||
@mock.patch('tripleoclient.utils.run_ansible_playbook',
|
||||
autospec=True)
|
||||
def test_undercloud_backup_db_only(self,
|
||||
mock_playbook,
|
||||
mock_access,
|
||||
mock_isfile):
|
||||
arglist = [
|
||||
'--db-only'
|
||||
]
|
||||
verifylist = []
|
||||
mock_isfile.return_value = True
|
||||
mock_access.return_value = True
|
||||
|
||||
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='cli-undercloud-db-backup.yaml',
|
||||
inventory=parsed_args.inventory,
|
||||
tags=None,
|
||||
skip_tags=None,
|
||||
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
verbosity=3,
|
||||
extra_vars=None
|
||||
)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('os.access')
|
||||
@mock.patch('tripleoclient.utils.run_ansible_playbook',
|
||||
@ -322,6 +351,37 @@ class TestUndercloudBackup(utils.TestCommand):
|
||||
extra_vars=extra_vars_dict
|
||||
)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('os.access')
|
||||
@mock.patch('tripleoclient.utils.run_ansible_playbook',
|
||||
autospec=True)
|
||||
def test_undercloud_backup_db_only_with_setup_options(self,
|
||||
mock_playbook,
|
||||
mock_access,
|
||||
mock_isfile):
|
||||
arglist = [
|
||||
'--db-only',
|
||||
'--setup-nfs',
|
||||
'--setup-rear'
|
||||
]
|
||||
verifylist = []
|
||||
mock_isfile.return_value = True
|
||||
mock_access.return_value = True
|
||||
|
||||
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='cli-undercloud-db-backup.yaml',
|
||||
inventory=parsed_args.inventory,
|
||||
tags=None,
|
||||
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_rear_with_inventory(self,
|
||||
mock_playbook):
|
||||
|
@ -73,6 +73,15 @@ class BackupUndercloud(command.Command):
|
||||
"install and configure ReaR.")
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--db-only',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=_("Perform a DB backup of the 'Undercloud' host. "
|
||||
"The DB backup file will be stored in /home/stack "
|
||||
"with the name openstack-backup-mysql-<timestamp>.sql.")
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--inventory',
|
||||
action='store',
|
||||
@ -161,36 +170,47 @@ class BackupUndercloud(command.Command):
|
||||
_('The inventory file {} does not exist or is not '
|
||||
'readable'.format(parsed_args.inventory)))
|
||||
|
||||
if parsed_args.setup_nfs is True or parsed_args.init == 'nfs':
|
||||
if parsed_args.db_only is True:
|
||||
|
||||
self._run_ansible_playbook(
|
||||
playbook='prepare-nfs-backup.yaml',
|
||||
playbook='cli-undercloud-db-backup.yaml',
|
||||
inventory=parsed_args.inventory,
|
||||
tags='bar_setup_nfs_server',
|
||||
tags=None,
|
||||
skip_tags=None,
|
||||
extra_vars=extra_vars
|
||||
)
|
||||
if parsed_args.setup_rear is True or parsed_args.init == 'rear':
|
||||
else:
|
||||
|
||||
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 True or parsed_args.init == 'nfs':
|
||||
|
||||
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='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='cli-undercloud-backup.yaml',
|
||||
inventory=parsed_args.inventory,
|
||||
tags='bar_create_recover_image',
|
||||
skip_tags=None,
|
||||
extra_vars=extra_vars
|
||||
)
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user