Update to change name for volume type client

This continues to update the name for volume type:

* Update a client method for volume type.
  update: to update an existing volume type's name

* Update a command-line operations.
  type-update: (adminitrator only) to update a volume type name

The corresponding cinder APIs change to update volume type name:
https://review.openstack.org/#/c/140906/

Implements: blueprint volume-type-description
Change-Id: I66adb7fd2a433e7443cb609046f64dbab3d9d4c7
This commit is contained in:
Gloria Gu
2014-12-11 11:26:00 -08:00
committed by Walter A. Boring IV (hemna)
parent 7c68f6f6df
commit 425565b79c
3 changed files with 15 additions and 7 deletions

View File

@@ -54,8 +54,11 @@ class TypesTest(utils.TestCase):
self.assertIsInstance(t, volume_types.VolumeType) self.assertIsInstance(t, volume_types.VolumeType)
def test_update(self): def test_update(self):
t = cs.volume_types.update('1', 'test_desc_1') t = cs.volume_types.update('1', 'test_type_1', 'test_desc_1')
cs.assert_called('PUT', '/types/1') cs.assert_called('PUT',
'/types/1',
{'volume_type': {'name': 'test_type_1',
'description': 'test_desc_1'}})
self.assertIsInstance(t, volume_types.VolumeType) self.assertIsInstance(t, volume_types.VolumeType)
def test_get(self): def test_get(self):

View File

@@ -752,13 +752,16 @@ def do_type_default(cs, args):
@utils.arg('id', @utils.arg('id',
metavar='<id>', metavar='<id>',
help="ID of the volume type.") help="ID of the volume type.")
@utils.arg('description', @utils.arg('--name',
metavar='<name>',
help="Name of the volume type.")
@utils.arg('--description',
metavar='<description>', metavar='<description>',
help="Description of the volume type.") help="Description of the volume type.")
@utils.service_type('volumev2') @utils.service_type('volumev2')
def do_type_update(cs, args): def do_type_update(cs, args):
"""Updates volume type description.""" """Updates volume type name and/or description."""
vtype = cs.volume_types.update(args.id, args.description) vtype = cs.volume_types.update(args.id, args.name, args.description)
_print_volume_type_list([vtype]) _print_volume_type_list([vtype])

View File

@@ -128,16 +128,18 @@ class VolumeTypeManager(base.ManagerWithFind):
return self._create("/types", body, "volume_type") return self._create("/types", body, "volume_type")
def update(self, volume_type, description): def update(self, volume_type, name=None, description=None):
"""Update the description for a volume type. """Update the name and/or description for a volume type.
:param volume_type: The ID of the :class:`VolumeType` to update. :param volume_type: The ID of the :class:`VolumeType` to update.
:param name: Descriptive name of the volume type.
:param description: Description of the the volume type. :param description: Description of the the volume type.
:rtype: :class:`VolumeType` :rtype: :class:`VolumeType`
""" """
body = { body = {
"volume_type": { "volume_type": {
"name": name,
"description": description "description": description
} }
} }