From 778d2d90227771976f9b98ab686dbe1d88154806 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 24 Jul 2012 19:29:02 -0600 Subject: [PATCH] Add missing parameters to volume create body * Fixes bug 1028684 * Adds metadata and other parameters to volume create Change-Id: Iaa0c9fd5edac8b48d92ee9722ea5d31d8249cd67 --- cinderclient/v1/volumes.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/cinderclient/v1/volumes.py b/cinderclient/v1/volumes.py index 64c2dfebc..984952c6d 100644 --- a/cinderclient/v1/volumes.py +++ b/cinderclient/v1/volumes.py @@ -85,7 +85,9 @@ class VolumeManager(base.ManagerWithFind): def create(self, size, snapshot_id=None, display_name=None, display_description=None, - volume_type=None): + volume_type=None, user_id=None, + project_id=None, availability_zone=None, + metadata=None): """ Create a volume. @@ -95,12 +97,34 @@ class VolumeManager(base.ManagerWithFind): :param display_description: Description of the volume :param volume_type: Type of volume :rtype: :class:`Volume` + :param user_id: User id derived from context + :param project_id: Project id derived from context + :param availability_zone: Availability Zone to use + :param metadata: Optional metadata to set on volume creation """ + + if volume_type is None: + volume_type_id = None + else: + volume_type_id = volume_type.get('id', None) + + if metadata is None: + volume_metadata = {} + else: + volume_metadata = metadata + body = {'volume': {'size': size, 'snapshot_id': snapshot_id, 'display_name': display_name, 'display_description': display_description, - 'volume_type': volume_type}} + 'volume_type_id': volume_type_id, + 'user_id': user_id, + 'project_id': project_id, + 'availability_zone': availability_zone, + 'status': "creating", + 'attach_status': "detached", + 'metadata': volume_metadata, + }} return self._create('/volumes', body, 'volume') def get(self, volume_id):