Add metadata parameter to checkpoint API
Change-Id: I86f6e6e8338e8256fec62a61275aeff8669b830c
This commit is contained in:
@@ -88,5 +88,5 @@ class CheckpointsTest(base.TestCaseShell):
|
||||
'checkpoints'.format(
|
||||
provider_id=FAKE_PROVIDER_ID),
|
||||
data={
|
||||
'checkpoint': {'plan_id': FAKE_PLAN_ID}},
|
||||
'checkpoint': {'plan_id': FAKE_PLAN_ID, 'extra-info': None}},
|
||||
headers={})
|
||||
|
||||
@@ -26,8 +26,9 @@ class Checkpoint(base.Resource):
|
||||
class CheckpointManager(base.ManagerWithFind):
|
||||
resource_class = Checkpoint
|
||||
|
||||
def create(self, provider_id, plan_id):
|
||||
body = {'checkpoint': {'plan_id': plan_id}}
|
||||
def create(self, provider_id, plan_id, checkpoint_extra_info=None):
|
||||
body = {'checkpoint': {'plan_id': plan_id,
|
||||
'extra-info': checkpoint_extra_info}}
|
||||
url = "/providers/{provider_id}/" \
|
||||
"checkpoints" .format(provider_id=provider_id)
|
||||
return self._create(url, body, 'checkpoint')
|
||||
|
||||
@@ -509,12 +509,37 @@ def do_provider_list(cs, args):
|
||||
@utils.arg('plan_id',
|
||||
metavar='<plan_id>',
|
||||
help='ID of plan.')
|
||||
@utils.arg('--extra_info',
|
||||
type=str,
|
||||
nargs='*',
|
||||
metavar='<key=value>',
|
||||
default=None,
|
||||
help='The extra info of a checkpoint.')
|
||||
def do_checkpoint_create(cs, args):
|
||||
"""Create a checkpoint."""
|
||||
checkpoint = cs.checkpoints.create(args.provider_id, args.plan_id)
|
||||
|
||||
checkpoint_extra_info = None
|
||||
if args.extra_info is not None:
|
||||
checkpoint_extra_info = _extract_extra_info(args)
|
||||
checkpoint = cs.checkpoints.create(args.provider_id, args.plan_id,
|
||||
checkpoint_extra_info)
|
||||
utils.print_dict(checkpoint.to_dict())
|
||||
|
||||
|
||||
def _extract_extra_info(args):
|
||||
checkpoint_extra_info = {}
|
||||
for data in args.extra_info:
|
||||
# unset doesn't require a val, so we have the if/else
|
||||
if '=' in data:
|
||||
(key, value) = data.split('=', 1)
|
||||
else:
|
||||
key = data
|
||||
value = None
|
||||
|
||||
checkpoint_extra_info[key] = value
|
||||
return checkpoint_extra_info
|
||||
|
||||
|
||||
@utils.arg('provider_id',
|
||||
metavar='<provider_id>',
|
||||
help='ID of provider.')
|
||||
@@ -569,7 +594,7 @@ def do_checkpoint_list(cs, args):
|
||||
marker=args.marker, limit=args.limit, sort_key=args.sort_key,
|
||||
sort_dir=args.sort_dir, sort=args.sort)
|
||||
|
||||
key_list = ['Id', 'Project id', 'Status', 'Protection plan']
|
||||
key_list = ['Id', 'Project id', 'Status', 'Protection plan', 'Metadata']
|
||||
|
||||
if args.sort_key or args.sort_dir or args.sort:
|
||||
sortby_index = None
|
||||
|
||||
Reference in New Issue
Block a user