Merge "Fix volume type 'is_public' flag update"
This commit is contained in:
commit
4bfb943cf5
|
@ -770,6 +770,13 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||
def put_types_1(self, **kw):
|
||||
return self.get_types_1()
|
||||
|
||||
def put_types_3(self, **kw):
|
||||
return (200, {}, {'volume_type': {'id': 3,
|
||||
'name': 'test-type-2',
|
||||
'description': 'test_type-3-desc',
|
||||
'is_public': True,
|
||||
'extra_specs': {}}})
|
||||
|
||||
#
|
||||
# VolumeAccess
|
||||
#
|
||||
|
|
|
@ -744,6 +744,10 @@ class ShellTest(utils.TestCase):
|
|||
'--description=test_type-1-desc '
|
||||
'--is-public=invalid_bool 1')
|
||||
|
||||
def test_type_update_without_args(self):
|
||||
self.assertRaises(exceptions.CommandError, self.run_command,
|
||||
'type-update 1')
|
||||
|
||||
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')
|
||||
|
|
|
@ -67,6 +67,27 @@ class TypesTest(utils.TestCase):
|
|||
self.assertIsInstance(t, volume_types.VolumeType)
|
||||
self._assert_request_id(t)
|
||||
|
||||
def test_update_name(self):
|
||||
"""Test volume_type update shell command
|
||||
|
||||
Verify that only name is updated and the description and
|
||||
is_public properties remains unchanged.
|
||||
"""
|
||||
# create volume_type with is_public True
|
||||
t = cs.volume_types.create('test-type-3', 'test_type-3-desc', True)
|
||||
self.assertTrue(t.is_public)
|
||||
# update name only
|
||||
t1 = cs.volume_types.update(t.id, 'test-type-2')
|
||||
cs.assert_called('PUT',
|
||||
'/types/3',
|
||||
{'volume_type': {'name': 'test-type-2',
|
||||
'description': None}})
|
||||
# verify that name is updated and the description
|
||||
# and is_public are the same.
|
||||
self.assertEqual('test-type-2', t1.name)
|
||||
self.assertEqual('test_type-3-desc', t1.description)
|
||||
self.assertTrue(t1.is_public)
|
||||
|
||||
def test_get(self):
|
||||
t = cs.volume_types.get('1')
|
||||
cs.assert_called('GET', '/types/1')
|
||||
|
|
|
@ -1004,7 +1004,13 @@ def do_group_type_show(cs, args):
|
|||
@utils.service_type('volumev3')
|
||||
def do_type_update(cs, args):
|
||||
"""Updates volume type name, description, and/or is_public."""
|
||||
is_public = strutils.bool_from_string(args.is_public, strict=True)
|
||||
is_public = args.is_public
|
||||
if args.name is None and args.description is None and is_public is None:
|
||||
raise exceptions.CommandError('Specify a new type name, description, '
|
||||
'is_public or a combination thereof.')
|
||||
|
||||
if is_public is not None:
|
||||
is_public = strutils.bool_from_string(args.is_public, strict=True)
|
||||
vtype = cs.volume_types.update(args.id, args.name, args.description,
|
||||
is_public)
|
||||
_print_volume_type_list([vtype])
|
||||
|
|
Loading…
Reference in New Issue