Merge "Add set-bootable command"
This commit is contained in:
@@ -357,6 +357,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
assert 'force_host_copy' in body[action]
|
assert 'force_host_copy' in body[action]
|
||||||
elif action == 'os-update_readonly_flag':
|
elif action == 'os-update_readonly_flag':
|
||||||
assert list(body[action]) == ['readonly']
|
assert list(body[action]) == ['readonly']
|
||||||
|
elif action == 'os-set_bootable':
|
||||||
|
assert list(body[action]) == ['bootable']
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected action: %s" % action)
|
raise AssertionError("Unexpected action: %s" % action)
|
||||||
return (resp, {}, _body)
|
return (resp, {}, _body)
|
||||||
|
@@ -106,3 +106,8 @@ class VolumesTest(utils.TestCase):
|
|||||||
v = cs.volumes.get('1234')
|
v = cs.volumes.get('1234')
|
||||||
cs.volumes.update_readonly_flag(v, True)
|
cs.volumes.update_readonly_flag(v, True)
|
||||||
cs.assert_called('POST', '/volumes/1234/action')
|
cs.assert_called('POST', '/volumes/1234/action')
|
||||||
|
|
||||||
|
def test_set_bootable(self):
|
||||||
|
v = cs.volumes.get('1234')
|
||||||
|
cs.volumes.set_bootable(v, True)
|
||||||
|
cs.assert_called('POST', '/volumes/1234/action')
|
||||||
|
@@ -368,6 +368,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
assert list(body[action]) == ['readonly']
|
assert list(body[action]) == ['readonly']
|
||||||
elif action == 'os-retype':
|
elif action == 'os-retype':
|
||||||
assert 'new_type' in body[action]
|
assert 'new_type' in body[action]
|
||||||
|
elif action == 'os-set_bootable':
|
||||||
|
assert list(body[action]) == ['bootable']
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected action: %s" % action)
|
raise AssertionError("Unexpected action: %s" % action)
|
||||||
return (resp, {}, _body)
|
return (resp, {}, _body)
|
||||||
|
@@ -134,3 +134,8 @@ class VolumesTest(utils.TestCase):
|
|||||||
cs.assert_called('POST', '/volumes/1234/action',
|
cs.assert_called('POST', '/volumes/1234/action',
|
||||||
{'os-retype': {'new_type': 'foo',
|
{'os-retype': {'new_type': 'foo',
|
||||||
'migration_policy': 'on-demand'}})
|
'migration_policy': 'on-demand'}})
|
||||||
|
|
||||||
|
def test_set_bootable(self):
|
||||||
|
v = cs.volumes.get('1234')
|
||||||
|
cs.volumes.set_bootable(v, True)
|
||||||
|
cs.assert_called('POST', '/volumes/1234/action')
|
||||||
|
@@ -1443,3 +1443,16 @@ def do_readonly_mode_update(cs, args):
|
|||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
cs.volumes.update_readonly_flag(volume,
|
cs.volumes.update_readonly_flag(volume,
|
||||||
strutils.bool_from_string(args.read_only))
|
strutils.bool_from_string(args.read_only))
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to update.')
|
||||||
|
@utils.arg('bootable',
|
||||||
|
metavar='<True|true|False|false>',
|
||||||
|
choices=['True', 'true', 'False', 'false'],
|
||||||
|
help='Flag to indicate whether volume is bootable.')
|
||||||
|
@utils.service_type('volume')
|
||||||
|
def do_set_bootable(cs, args):
|
||||||
|
"""Update bootable status of a volume."""
|
||||||
|
volume = utils.find_volume(cs, args.volume)
|
||||||
|
cs.volumes.set_bootable(volume,
|
||||||
|
strutils.bool_from_string(args.bootable))
|
||||||
|
@@ -425,3 +425,8 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
return self._action('os-update_readonly_flag',
|
return self._action('os-update_readonly_flag',
|
||||||
base.getid(volume),
|
base.getid(volume),
|
||||||
{'readonly': flag})
|
{'readonly': flag})
|
||||||
|
|
||||||
|
def set_bootable(self, volume, flag):
|
||||||
|
return self._action('os-set_bootable',
|
||||||
|
base.getid(volume),
|
||||||
|
{'bootable': flag})
|
||||||
|
@@ -1547,3 +1547,16 @@ def do_readonly_mode_update(cs, args):
|
|||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
cs.volumes.update_readonly_flag(volume,
|
cs.volumes.update_readonly_flag(volume,
|
||||||
strutils.bool_from_string(args.read_only))
|
strutils.bool_from_string(args.read_only))
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to update.')
|
||||||
|
@utils.arg('bootable',
|
||||||
|
metavar='<True|true|False|false>',
|
||||||
|
choices=['True', 'true', 'False', 'false'],
|
||||||
|
help='Flag to indicate whether volume is bootable.')
|
||||||
|
@utils.service_type('volumev2')
|
||||||
|
def do_set_bootable(cs, args):
|
||||||
|
"""Update bootable status of a volume."""
|
||||||
|
volume = utils.find_volume(cs, args.volume)
|
||||||
|
cs.volumes.set_bootable(volume,
|
||||||
|
strutils.bool_from_string(args.bootable))
|
||||||
|
@@ -422,3 +422,8 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
volume,
|
volume,
|
||||||
{'new_type': volume_type,
|
{'new_type': volume_type,
|
||||||
'migration_policy': policy})
|
'migration_policy': policy})
|
||||||
|
|
||||||
|
def set_bootable(self, volume, flag):
|
||||||
|
return self._action('os-set_bootable',
|
||||||
|
base.getid(volume),
|
||||||
|
{'bootable': flag})
|
||||||
|
Reference in New Issue
Block a user