summaryrefslogtreecommitdiff
path: root/cinderclient/v3
diff options
context:
space:
mode:
authorRajat Dhasmana <rajatdhasmana@gmail.com>2021-03-29 06:31:31 -0400
committerRajat Dhasmana <rajatdhasmana@gmail.com>2021-07-14 11:20:28 -0400
commitd714249ca9e95297f5e53c9dcc0af9ba58d0ab6d (patch)
tree04e2a5a4f4a50e706238c8dc0dd6457211d5a44e /cinderclient/v3
parenta0e36218f20e95778f449edb9edccbead4a6eed9 (diff)
downloadpython-cinderclient-d714249ca9e95297f5e53c9dcc0af9ba58d0ab6d.tar.gz
Make instance_uuid optional in attachment create
Cinder and cinderclient assumes an attachment create request will always contain instance_uuid. This is not true when glance calls cinder for attachment in glance cinder configuration. This patch (along with the cinder patch) make the instance_uuid optional and allow glance to do attachments without passing instance_uuid. Change-Id: Ifbaca4aa87d890bc5130069638d42665b914b378
Diffstat (limited to 'cinderclient/v3')
-rw-r--r--cinderclient/v3/attachments.py5
-rw-r--r--cinderclient/v3/shell.py2
2 files changed, 5 insertions, 2 deletions
diff --git a/cinderclient/v3/attachments.py b/cinderclient/v3/attachments.py
index e1e9290..5067962 100644
--- a/cinderclient/v3/attachments.py
+++ b/cinderclient/v3/attachments.py
@@ -27,11 +27,12 @@ class VolumeAttachmentManager(base.ManagerWithFind):
resource_class = VolumeAttachment
@api_versions.wraps('3.27')
- def create(self, volume_id, connector, instance_id, mode='null'):
+ def create(self, volume_id, connector, instance_id=None, mode='null'):
"""Create a attachment for specified volume."""
body = {'attachment': {'volume_uuid': volume_id,
- 'instance_uuid': instance_id,
'connector': connector}}
+ if instance_id:
+ body['attachment']['instance_uuid'] = instance_id
if self.api_version >= api_versions.APIVersion("3.54"):
if mode and mode != 'null':
body['attachment']['mode'] = mode
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index 6d7d1eb..9865d38 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -2297,6 +2297,8 @@ def do_attachment_show(cs, args):
help='Name or ID of volume or volumes to attach.')
@utils.arg('server_id',
metavar='<server_id>',
+ nargs='?',
+ default=None,
help='ID of server attaching to.')
@utils.arg('--connect',
metavar='<connect>',