Add missing parameters to volume create body

* Fixes bug 1028684
* Adds metadata and other parameters to volume create

Change-Id: Iaa0c9fd5edac8b48d92ee9722ea5d31d8249cd67
This commit is contained in:
John Griffith
2012-07-24 19:29:02 -06:00
parent 1a32f024ce
commit 778d2d9022

View File

@@ -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):