[BugFix] Make 'instance_id' required in attachment-create CLI.

There are some issues around new attach/detach APIs/CLIs,
fix them step by step. Based our current API design
in cinder [1] and irc conversation [2] the 'instance_uuid'
is required, also change the name from 'instance_uuid' to
'server_id'.

[1]
https://github.com/openstack/cinder/blob/master/cinder/api/v3/attachments.py#L152
[2]
http://eavesdrop.openstack.org/irclogs/%23openstack-cinder/%23openstack-cinder.2017-03-24.log.html#t2017-03-24T13:32:03
Change-Id: Ia819d04800a0f9cbd46e844895729126edc77ed9
Depends-On: 273c724382
Closes-Bug: #1675975
This commit is contained in:
TommyLike 2017-03-25 11:12:57 +08:00
parent 6493b810a7
commit ae7ab7dfc5
3 changed files with 13 additions and 8 deletions

View File

@ -95,11 +95,11 @@ class ShellTest(utils.TestCase):
self.run_command('availability-zone-list')
self.assert_called('GET', '/os-availability-zone')
@ddt.data({'cmd': '1234 --instance 1233',
@ddt.data({'cmd': '1234 1233',
'body': {'instance_uuid': '1233',
'connector': {},
'volume_uuid': '1234'}},
{'cmd': '1234 --instance 1233 '
{'cmd': '1234 1233 '
'--connect True '
'--ip 10.23.12.23 --host server01 '
'--platform x86_xx '

View File

@ -1355,7 +1355,7 @@ def do_attachment_list(cs, args):
marker=args.marker,
limit=args.limit,
sort=args.sort)
columns = ['ID', 'Volume ID', 'Status', 'Instance']
columns = ['ID', 'Volume ID', 'Status', 'Server ID']
if args.sort:
sortby_index = None
else:
@ -1385,10 +1385,9 @@ def do_attachment_show(cs, args):
@utils.arg('volume',
metavar='<volume>',
help='Name or ID of volume or volumes to attach.')
@utils.arg('--instance',
metavar='<instance>',
default=None,
help='UUID of Instance attaching to. Default=None.')
@utils.arg('server_id',
metavar='<server_id>',
help='ID of server attaching to.')
@utils.arg('--connect',
metavar='<connect>',
default=False,
@ -1437,7 +1436,7 @@ def do_attachment_create(cs, args):
'mountpoint': args.mountpoint}
attachment = cs.attachments.create(args.volume,
connector,
args.instance)
args.server_id)
connector_dict = attachment.pop('connection_info', None)
utils.print_dict(attachment)
if connector_dict:

View File

@ -0,0 +1,6 @@
---
fixes:
- The 'server_id' is now a required parameter when creating an
attachment, that means we should create an attachment with
a command like, 'cinder attachment-create <volume> <server_id>'.
[Bug `1675975 <https://bugs.launchpad.net/bugs/1675975>`_]