Merge "Volume size could be specified to create volume"

This commit is contained in:
Jenkins 2014-04-09 00:08:26 +00:00 committed by Gerrit Code Review
commit 09d780a0ce
7 changed files with 34 additions and 12 deletions

View File

@ -211,7 +211,7 @@
# admin credentials are known. (boolean value)
#allow_tenant_isolation=false
# Valid secondary image reference to be used in tests. (string
# Valid primary image reference to be used in tests. (string
# value)
#image_ref={$IMAGE_ID}
@ -978,6 +978,10 @@
# value)
#disk_format=raw
# Default size in GB for volumes created by volumes tests
# (integer value)
#volume_size=1
[volume-feature-enabled]

View File

@ -51,8 +51,7 @@ class VolumesGetTest(base.BaseVolumeV1Test):
v_name = data_utils.rand_name('Volume')
metadata = {'Type': 'Test'}
# Create a volume
resp, volume = self.client.create_volume(size=1,
display_name=v_name,
resp, volume = self.client.create_volume(display_name=v_name,
metadata=metadata,
**kwargs)
self.assertEqual(200, resp.status)

View File

@ -126,7 +126,7 @@ ComputeGroup = [
"OpenStack Identity API admin credentials are known."),
cfg.StrOpt('image_ref',
default="{$IMAGE_ID}",
help="Valid secondary image reference to be used in tests."),
help="Valid primary image reference to be used in tests."),
cfg.StrOpt('image_ref_alt',
default="{$IMAGE_ID_ALT}",
help="Valid secondary image reference to be used in tests."),
@ -441,6 +441,9 @@ VolumeGroup = [
cfg.StrOpt('disk_format',
default='raw',
help='Disk format to use when copying a volume to image'),
cfg.IntOpt('volume_size',
default=1,
help='Default size in GB for volumes created by volumes tests'),
]
volume_feature_group = cfg.OptGroup(name='volume-feature-enabled',

View File

@ -67,10 +67,10 @@ class VolumesClientJSON(rest_client.RestClient):
body = json.loads(body)
return resp, body['volume']
def create_volume(self, size, **kwargs):
def create_volume(self, size=None, **kwargs):
"""
Creates a new Volume.
size(Required): Size of volume in GB.
size: Size of volume in GB.
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
@ -78,6 +78,10 @@ class VolumesClientJSON(rest_client.RestClient):
snapshot_id: When specified the volume is created from this snapshot
imageRef: When specified the volume is created from this image
"""
# for bug #1293885:
# If no size specified, read volume size from CONF
if size is None:
size = CONF.volume.volume_size
post_body = {'size': size}
post_body.update(kwargs)
post_body = json.dumps({'volume': post_body})

View File

@ -68,10 +68,10 @@ class VolumesV2ClientJSON(rest_client.RestClient):
body = json.loads(body)
return resp, body['volume']
def create_volume(self, size, **kwargs):
def create_volume(self, size=None, **kwargs):
"""
Creates a new Volume.
size(Required): Size of volume in GB.
size: Size of volume in GB.
Following optional keyword arguments are accepted:
name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
@ -79,6 +79,10 @@ class VolumesV2ClientJSON(rest_client.RestClient):
snapshot_id: When specified the volume is created from this snapshot
imageRef: When specified the volume is created from this image
"""
# for bug #1293885:
# If no size specified, read volume size from CONF
if size is None:
size = CONF.volume.volume_size
post_body = {'size': size}
post_body.update(kwargs)
post_body = json.dumps({'volume': post_body})

View File

@ -117,10 +117,10 @@ class VolumesV2ClientXML(rest_client.RestClient):
body = self._check_if_bootable(body)
return resp, body
def create_volume(self, size, **kwargs):
def create_volume(self, size=None, **kwargs):
"""Creates a new Volume.
:param size: Size of volume in GB. (Required)
:param size: Size of volume in GB.
:param name: Optional Volume Name.
:param metadata: An optional dictionary of values for metadata.
:param volume_type: Optional Name of volume_type for the volume
@ -129,6 +129,10 @@ class VolumesV2ClientXML(rest_client.RestClient):
:param imageRef: When specified the volume is created from this
image
"""
# for bug #1293885:
# If no size specified, read volume size from CONF
if size is None:
size = CONF.volume.volume_size
# NOTE(afazekas): it should use a volume namespace
volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)

View File

@ -118,10 +118,10 @@ class VolumesClientXML(rest_client.RestClient):
body = self._check_if_bootable(body)
return resp, body
def create_volume(self, size, **kwargs):
def create_volume(self, size=None, **kwargs):
"""Creates a new Volume.
:param size: Size of volume in GB. (Required)
:param size: Size of volume in GB.
:param display_name: Optional Volume Name.
:param metadata: An optional dictionary of values for metadata.
:param volume_type: Optional Name of volume_type for the volume
@ -130,6 +130,10 @@ class VolumesClientXML(rest_client.RestClient):
:param imageRef: When specified the volume is created from this
image
"""
# for bug #1293885:
# If no size specified, read volume size from CONF
if size is None:
size = CONF.volume.volume_size
# NOTE(afazekas): it should use a volume namespace
volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)