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:
@@ -559,6 +559,15 @@ class ShellTest(utils.TestCase):
|
|||||||
'--is-public=False')
|
'--is-public=False')
|
||||||
self.assert_called('POST', '/types', body=expected)
|
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):
|
def test_type_access_list(self):
|
||||||
self.run_command('type-access-list --volume-type 3')
|
self.run_command('type-access-list --volume-type 3')
|
||||||
self.assert_called('GET', '/types/3/os-volume-type-access')
|
self.assert_called('GET', '/types/3/os-volume-type-access')
|
||||||
|
@@ -54,11 +54,12 @@ 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_type_1', 'test_desc_1')
|
t = cs.volume_types.update('1', 'test_type_1', 'test_desc_1', False)
|
||||||
cs.assert_called('PUT',
|
cs.assert_called('PUT',
|
||||||
'/types/1',
|
'/types/1',
|
||||||
{'volume_type': {'name': 'test_type_1',
|
{'volume_type': {'name': 'test_type_1',
|
||||||
'description': 'test_desc_1'}})
|
'description': 'test_desc_1',
|
||||||
|
'is_public': False}})
|
||||||
self.assertIsInstance(t, volume_types.VolumeType)
|
self.assertIsInstance(t, volume_types.VolumeType)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
|
@@ -804,10 +804,15 @@ def do_type_default(cs, args):
|
|||||||
@utils.arg('--description',
|
@utils.arg('--description',
|
||||||
metavar='<description>',
|
metavar='<description>',
|
||||||
help='Description of the volume type.')
|
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')
|
@utils.service_type('volumev2')
|
||||||
def do_type_update(cs, args):
|
def do_type_update(cs, args):
|
||||||
"""Updates volume type name and/or description."""
|
"""Updates volume type name ,description and/or is_public."""
|
||||||
vtype = cs.volume_types.update(args.id, args.name, args.description)
|
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])
|
_print_volume_type_list([vtype])
|
||||||
|
|
||||||
|
|
||||||
|
@@ -128,7 +128,7 @@ class VolumeTypeManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
return self._create("/types", body, "volume_type")
|
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.
|
"""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.
|
||||||
@@ -143,6 +143,8 @@ class VolumeTypeManager(base.ManagerWithFind):
|
|||||||
"description": description
|
"description": description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if is_public is not None:
|
||||||
|
body["volume_type"]["is_public"] = is_public
|
||||||
|
|
||||||
return self._update("/types/%s" % base.getid(volume_type),
|
return self._update("/types/%s" % base.getid(volume_type),
|
||||||
body, response_key="volume_type")
|
body, response_key="volume_type")
|
||||||
|
Reference in New Issue
Block a user