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) # admin credentials are known. (boolean value)
#allow_tenant_isolation=false #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) # value)
#image_ref={$IMAGE_ID} #image_ref={$IMAGE_ID}
@ -978,6 +978,10 @@
# value) # value)
#disk_format=raw #disk_format=raw
# Default size in GB for volumes created by volumes tests
# (integer value)
#volume_size=1
[volume-feature-enabled] [volume-feature-enabled]

View File

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

View File

@ -126,7 +126,7 @@ ComputeGroup = [
"OpenStack Identity API admin credentials are known."), "OpenStack Identity API admin credentials are known."),
cfg.StrOpt('image_ref', cfg.StrOpt('image_ref',
default="{$IMAGE_ID}", 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', cfg.StrOpt('image_ref_alt',
default="{$IMAGE_ID_ALT}", default="{$IMAGE_ID_ALT}",
help="Valid secondary image reference to be used in tests."), help="Valid secondary image reference to be used in tests."),
@ -441,6 +441,9 @@ VolumeGroup = [
cfg.StrOpt('disk_format', cfg.StrOpt('disk_format',
default='raw', default='raw',
help='Disk format to use when copying a volume to image'), 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', volume_feature_group = cfg.OptGroup(name='volume-feature-enabled',

View File

@ -67,10 +67,10 @@ class VolumesClientJSON(rest_client.RestClient):
body = json.loads(body) body = json.loads(body)
return resp, body['volume'] return resp, body['volume']
def create_volume(self, size, **kwargs): def create_volume(self, size=None, **kwargs):
""" """
Creates a new Volume. Creates a new Volume.
size(Required): Size of volume in GB. size: Size of volume in GB.
Following optional keyword arguments are accepted: Following optional keyword arguments are accepted:
display_name: Optional Volume Name. display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata. 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 snapshot_id: When specified the volume is created from this snapshot
imageRef: When specified the volume is created from this image 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 = {'size': size}
post_body.update(kwargs) post_body.update(kwargs)
post_body = json.dumps({'volume': post_body}) post_body = json.dumps({'volume': post_body})

View File

@ -68,10 +68,10 @@ class VolumesV2ClientJSON(rest_client.RestClient):
body = json.loads(body) body = json.loads(body)
return resp, body['volume'] return resp, body['volume']
def create_volume(self, size, **kwargs): def create_volume(self, size=None, **kwargs):
""" """
Creates a new Volume. Creates a new Volume.
size(Required): Size of volume in GB. size: Size of volume in GB.
Following optional keyword arguments are accepted: Following optional keyword arguments are accepted:
name: Optional Volume Name. name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata. 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 snapshot_id: When specified the volume is created from this snapshot
imageRef: When specified the volume is created from this image 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 = {'size': size}
post_body.update(kwargs) post_body.update(kwargs)
post_body = json.dumps({'volume': post_body}) post_body = json.dumps({'volume': post_body})

View File

@ -117,10 +117,10 @@ class VolumesV2ClientXML(rest_client.RestClient):
body = self._check_if_bootable(body) body = self._check_if_bootable(body)
return resp, body return resp, body
def create_volume(self, size, **kwargs): def create_volume(self, size=None, **kwargs):
"""Creates a new Volume. """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 name: Optional Volume Name.
:param metadata: An optional dictionary of values for metadata. :param metadata: An optional dictionary of values for metadata.
:param volume_type: Optional Name of volume_type for the volume :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 :param imageRef: When specified the volume is created from this
image 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 # NOTE(afazekas): it should use a volume namespace
volume = common.Element("volume", xmlns=common.XMLNS_11, size=size) 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) body = self._check_if_bootable(body)
return resp, body return resp, body
def create_volume(self, size, **kwargs): def create_volume(self, size=None, **kwargs):
"""Creates a new Volume. """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 display_name: Optional Volume Name.
:param metadata: An optional dictionary of values for metadata. :param metadata: An optional dictionary of values for metadata.
:param volume_type: Optional Name of volume_type for the volume :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 :param imageRef: When specified the volume is created from this
image 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 # NOTE(afazekas): it should use a volume namespace
volume = common.Element("volume", xmlns=common.XMLNS_11, size=size) volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)