diff --git a/cinderclient/tests/v1/fakes.py b/cinderclient/tests/v1/fakes.py index c577438c6..f191b4a62 100644 --- a/cinderclient/tests/v1/fakes.py +++ b/cinderclient/tests/v1/fakes.py @@ -357,6 +357,8 @@ class FakeHTTPClient(base_client.HTTPClient): assert 'force_host_copy' in body[action] elif action == 'os-update_readonly_flag': assert list(body[action]) == ['readonly'] + elif action == 'os-set_bootable': + assert list(body[action]) == ['bootable'] else: raise AssertionError("Unexpected action: %s" % action) return (resp, {}, _body) diff --git a/cinderclient/tests/v1/test_volumes.py b/cinderclient/tests/v1/test_volumes.py index 571fa79c4..1b59f7f03 100644 --- a/cinderclient/tests/v1/test_volumes.py +++ b/cinderclient/tests/v1/test_volumes.py @@ -106,3 +106,8 @@ class VolumesTest(utils.TestCase): v = cs.volumes.get('1234') cs.volumes.update_readonly_flag(v, True) 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') diff --git a/cinderclient/tests/v2/fakes.py b/cinderclient/tests/v2/fakes.py index 494ed2896..98f3500b6 100644 --- a/cinderclient/tests/v2/fakes.py +++ b/cinderclient/tests/v2/fakes.py @@ -368,6 +368,8 @@ class FakeHTTPClient(base_client.HTTPClient): assert list(body[action]) == ['readonly'] elif action == 'os-retype': assert 'new_type' in body[action] + elif action == 'os-set_bootable': + assert list(body[action]) == ['bootable'] else: raise AssertionError("Unexpected action: %s" % action) return (resp, {}, _body) diff --git a/cinderclient/tests/v2/test_volumes.py b/cinderclient/tests/v2/test_volumes.py index d2a0610c1..a4c0e908d 100644 --- a/cinderclient/tests/v2/test_volumes.py +++ b/cinderclient/tests/v2/test_volumes.py @@ -134,3 +134,8 @@ class VolumesTest(utils.TestCase): cs.assert_called('POST', '/volumes/1234/action', {'os-retype': {'new_type': 'foo', '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') diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 2f2eb1989..47e0a5748 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -1443,3 +1443,16 @@ def do_readonly_mode_update(cs, args): volume = utils.find_volume(cs, args.volume) cs.volumes.update_readonly_flag(volume, strutils.bool_from_string(args.read_only)) + + +@utils.arg('volume', metavar='', help='ID of the volume to update.') +@utils.arg('bootable', + metavar='', + 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)) diff --git a/cinderclient/v1/volumes.py b/cinderclient/v1/volumes.py index d6c50b77c..37a4b88d1 100644 --- a/cinderclient/v1/volumes.py +++ b/cinderclient/v1/volumes.py @@ -425,3 +425,8 @@ class VolumeManager(base.ManagerWithFind): return self._action('os-update_readonly_flag', base.getid(volume), {'readonly': flag}) + + def set_bootable(self, volume, flag): + return self._action('os-set_bootable', + base.getid(volume), + {'bootable': flag}) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index a5c0f2d6c..4842709d0 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1547,3 +1547,16 @@ def do_readonly_mode_update(cs, args): volume = utils.find_volume(cs, args.volume) cs.volumes.update_readonly_flag(volume, strutils.bool_from_string(args.read_only)) + + +@utils.arg('volume', metavar='', help='ID of the volume to update.') +@utils.arg('bootable', + metavar='', + 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)) diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py index e76abbdba..ce2b06f60 100644 --- a/cinderclient/v2/volumes.py +++ b/cinderclient/v2/volumes.py @@ -422,3 +422,8 @@ class VolumeManager(base.ManagerWithFind): volume, {'new_type': volume_type, 'migration_policy': policy}) + + def set_bootable(self, volume, flag): + return self._action('os-set_bootable', + base.getid(volume), + {'bootable': flag})