Updating volume type 'is_public' status support

Cinder supports updating volume type 'is_public' status, it should
be added in cinderclient also. New option 'is_public' will be introduced
for 'cinder type-update'.

DocImpact
Change-Id: Ibfa9ba16c0775e401f6eda0729fcf34a99a14697
Closes-bug: #1493612
This commit is contained in:
liyingjun
2015-09-09 10:08:19 +08:00
parent 68a4707216
commit 806fa65d84
4 changed files with 22 additions and 5 deletions

View File

@@ -559,6 +559,15 @@ class ShellTest(utils.TestCase):
'--is-public=False')
self.assert_called('POST', '/types', body=expected)
def test_type_update(self):
expected = {'volume_type': {'name': 'test-type-1',
'description': 'test_type-1-desc',
'is_public': False}}
self.run_command('type-update --name test-type-1 '
'--description=test_type-1-desc '
'--is-public=False 1')
self.assert_called('PUT', '/types/1', body=expected)
def test_type_access_list(self):
self.run_command('type-access-list --volume-type 3')
self.assert_called('GET', '/types/3/os-volume-type-access')

View File

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

View File

@@ -804,10 +804,15 @@ def do_type_default(cs, args):
@utils.arg('--description',
metavar='<description>',
help='Description of the volume type.')
@utils.arg('--is-public',
metavar='<is-public>',
help='Make type accessible to the public or not.')
@utils.service_type('volumev2')
def do_type_update(cs, args):
"""Updates volume type name and/or description."""
vtype = cs.volume_types.update(args.id, args.name, args.description)
"""Updates volume type name ,description and/or is_public."""
is_public = strutils.bool_from_string(args.is_public)
vtype = cs.volume_types.update(args.id, args.name, args.description,
is_public)
_print_volume_type_list([vtype])

View File

@@ -128,7 +128,7 @@ class VolumeTypeManager(base.ManagerWithFind):
return self._create("/types", body, "volume_type")
def update(self, volume_type, name=None, description=None):
def update(self, volume_type, name=None, description=None, is_public=None):
"""Update the name and/or description for a volume type.
:param volume_type: The ID of the :class:`VolumeType` to update.
@@ -143,6 +143,8 @@ class VolumeTypeManager(base.ManagerWithFind):
"description": description
}
}
if is_public is not None:
body["volume_type"]["is_public"] = is_public
return self._update("/types/%s" % base.getid(volume_type),
body, response_key="volume_type")