Allow use of backup name in trove create

'trove create' only accepts a backup id as a value
when restoring an instance from a backup. This change
enables the use of the backup name as well.

A few minor typos were fixed as well to make the output
more consistent.

Co-authored-by: Sushil Kumar <skm.net@gmail.com>
Co-authored-by: Peter Stachowski <peter@tesora.com>
Change-Id: I01f9ba96c8bdec5cfa4c4b477eb824b4456774d1
Closes-Bug: #1513636
This commit is contained in:
Sushil Kumar 2015-11-05 22:19:58 +00:00 committed by Peter Stachowski
parent 4b2d76931b
commit 6b2fad5670
4 changed files with 40 additions and 8 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- Allow use of backup name in trove create
when restoring a backup.

View File

@ -509,6 +509,10 @@ class FakeHTTPClient(base_client.HTTPClient):
r = {'backup': self.get_backups()[2]['backups'][0]}
return (200, {}, r)
def get_backups_bkp_1(self, **kw):
r = {'backup': self.get_backups()[2]['backups'][0]}
return (200, {}, r)
def get_instances_1234_backups(self, **kw):
r = {'backups': [self.get_backups()[2]['backups'][0]]}
return (200, {}, r)

View File

@ -298,6 +298,30 @@ class ShellTest(utils.TestCase):
'Invalid NIC argument: nic=\'net-id=some-id,port-id=some-id\'',
self.run_command, cmd)
def test_boot_restore_by_id(self):
self.run_command('create test-restore-1 1 --size 1 --backup bk_1234')
self.assert_called_anytime(
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'name': 'test-restore-1',
'restorePoint': {'backupRef': 'bk-1234'},
'replica_count': 1
}})
def test_boot_restore_by_name(self):
self.run_command('create test-restore-1 1 --size 1 --backup bkp_1')
self.assert_called_anytime(
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'name': 'test-restore-1',
'restorePoint': {'backupRef': 'bk-1234'},
'replica_count': 1
}})
def test_cluster_create(self):
cmd = ('cluster-create test-clstr vertica 7.1 '
'--instance flavor=2,volume=2 '

View File

@ -344,7 +344,7 @@ def do_cluster_shrink(cs, args):
@utils.arg('instance', metavar='<instance>',
help='ID or name of the instance.')
help='ID or name of the instance.')
@utils.service_type('database')
def do_delete(cs, args):
"""Deletes an instance."""
@ -411,7 +411,7 @@ def do_update(cs, args):
help="Volume type. Optional when volume support is enabled.")
@utils.arg('flavor',
metavar='<flavor>',
help='Flavor ID or name of the instance.')
help='A flavor name or ID.')
@utils.arg('--databases', metavar='<database>',
help='Optional list of databases.',
nargs="+", default=[])
@ -421,7 +421,7 @@ def do_update(cs, args):
@utils.arg('--backup',
metavar='<backup>',
default=None,
help='A backup ID.')
help='A backup name or ID.')
@utils.arg('--availability_zone',
metavar='<availability_zone>',
default=None,
@ -475,7 +475,7 @@ def do_create(cs, args):
"type": args.volume_type}
restore_point = None
if args.backup:
restore_point = {"backupRef": args.backup}
restore_point = {"backupRef": _find_backup(cs, args.backup).id}
if args.replica_of:
replica_of_instance = _find_instance(cs, args.replica_of)
databases = [{'name': value} for value in args.databases]
@ -783,7 +783,7 @@ def do_eject_replica_source(cs, args):
# Backup related commands
@utils.arg('backup', metavar='<backup>', help='ID of the backup.')
@utils.arg('backup', metavar='<backup>', help='ID or name of the backup.')
@utils.service_type('database')
def do_backup_show(cs, args):
"""Shows details of a backup."""
@ -824,7 +824,7 @@ def do_backup_list_instance(cs, args):
'the last ID displayed in the previous run.')
@utils.arg('--datastore', metavar='<datastore>',
default=None,
help='Name or ID of the datastore to list backups for.')
help='ID or name of the datastore (to filter backups by).')
@utils.service_type('database')
def do_backup_list(cs, args):
"""Lists available backups."""
@ -929,7 +929,7 @@ def do_database_list(cs, args):
@utils.arg('instance', metavar='<instance>',
help='ID or name of the instance.')
help='ID or name of the instance.')
@utils.arg('database', metavar='<database>', help='Name of the database.')
@utils.service_type('database')
def do_database_delete(cs, args):
@ -941,7 +941,7 @@ def do_database_delete(cs, args):
# User related actions
@utils.arg('instance', metavar='<instance>',
help='ID or name of the instance.')
help='ID or name of the instance.')
@utils.arg('name', metavar='<name>', help='Name of user.')
@utils.arg('password', metavar='<password>', help='Password of user.')
@utils.arg('--host', metavar='<host>', default=None,