Merge "Add "volume host failover" command"
This commit is contained in:
commit
1b4605e4ad
@ -4,6 +4,28 @@ volume host
|
||||
|
||||
Volume v2
|
||||
|
||||
volume host failover
|
||||
--------------------
|
||||
|
||||
Failover volume host to different backend
|
||||
|
||||
.. program:: volume host failover
|
||||
.. code:: bash
|
||||
|
||||
openstack volume host failover
|
||||
--volume-backend <backend-id>
|
||||
<host-name>
|
||||
|
||||
.. option:: --volume-backend <backend-id>
|
||||
|
||||
The ID of the volume backend replication
|
||||
target where the host will failover to (required)
|
||||
|
||||
.. _volume_host_failover-host-name:
|
||||
.. describe:: <host-name>
|
||||
|
||||
Name of volume host
|
||||
|
||||
volume host set
|
||||
---------------
|
||||
|
||||
@ -18,13 +40,13 @@ Set volume host properties
|
||||
|
||||
.. option:: --enable
|
||||
|
||||
Thaw and enable the specified volume host
|
||||
Thaw and enable the specified volume host.
|
||||
|
||||
.. option:: --disable
|
||||
|
||||
Freeze and disable the specified volume host
|
||||
|
||||
.. _volume-host-set:
|
||||
.. _volume_host_set-host-name:
|
||||
.. describe:: <host-name>
|
||||
|
||||
Name of volume host
|
||||
|
@ -239,6 +239,7 @@ Those actions with an opposite action are noted in parens if applicable.
|
||||
* ``create`` (``delete``) - create a new occurrence of the specified object
|
||||
* ``delete`` (``create``) - delete specific occurrences of the specified objects
|
||||
* ``expand`` (``shrink``) - increase the capacity of a cluster
|
||||
* ``failover`` - failover volume host to different backend
|
||||
* ``issue`` (``revoke``) - issue a token
|
||||
* ``list`` - display summary information about multiple objects
|
||||
* ``lock`` (``unlock``) - lock one or more servers so that non-admin user won't be able to execute actions
|
||||
|
@ -35,6 +35,7 @@ class TestVolumeHostSet(TestVolumeHost):
|
||||
self.host_mock.freeze_host.return_value = None
|
||||
self.host_mock.thaw_host.return_value = None
|
||||
|
||||
# Get the command object to mock
|
||||
self.cmd = volume_host.SetVolumeHost(self.app, None)
|
||||
|
||||
def test_volume_host_set_nothing(self):
|
||||
@ -84,3 +85,33 @@ class TestVolumeHostSet(TestVolumeHost):
|
||||
self.host_mock.freeze_host.assert_called_with(self.service.host)
|
||||
self.host_mock.thaw_host.assert_not_called()
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestVolumeHostFailover(TestVolumeHost):
|
||||
|
||||
service = host_fakes.FakeService.create_one_service()
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeHostFailover, self).setUp()
|
||||
|
||||
self.host_mock.failover_host.return_value = None
|
||||
|
||||
# Get the command object to mock
|
||||
self.cmd = volume_host.FailoverVolumeHost(self.app, None)
|
||||
|
||||
def test_volume_host_failover(self):
|
||||
arglist = [
|
||||
'--volume-backend', 'backend_test',
|
||||
self.service.host,
|
||||
]
|
||||
verifylist = [
|
||||
('volume_backend', 'backend_test'),
|
||||
('host', self.service.host),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.host_mock.failover_host.assert_called_with(
|
||||
self.service.host, 'backend_test')
|
||||
self.assertIsNone(result)
|
||||
|
@ -19,6 +19,31 @@ from osc_lib.command import command
|
||||
from openstackclient.i18n import _
|
||||
|
||||
|
||||
class FailoverVolumeHost(command.Command):
|
||||
_description = _("Failover volume host to different backend")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(FailoverVolumeHost, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"host",
|
||||
metavar="<host-name>",
|
||||
help=_("Name of volume host")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--volume-backend",
|
||||
metavar="<backend-id>",
|
||||
required=True,
|
||||
help=_("The ID of the volume backend replication "
|
||||
"target where the host will failover to (required)")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
service_client = self.app.client_manager.volume
|
||||
service_client.services.failover_host(parsed_args.host,
|
||||
parsed_args.volume_backend)
|
||||
|
||||
|
||||
class SetVolumeHost(command.Command):
|
||||
_description = _("Set volume host properties")
|
||||
|
||||
@ -33,12 +58,12 @@ class SetVolumeHost(command.Command):
|
||||
enabled_group.add_argument(
|
||||
"--disable",
|
||||
action="store_true",
|
||||
help=_("Freeze and disable the specified volume host.")
|
||||
help=_("Freeze and disable the specified volume host")
|
||||
)
|
||||
enabled_group.add_argument(
|
||||
"--enable",
|
||||
action="store_true",
|
||||
help=_("Thaw and enable the specified volume host.")
|
||||
help=_("Thaw and enable the specified volume host")
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``volume host failover`` command.
|
||||
[Blueprint `cinder-command-support <https://blueprints.launchpad.net/python-openstackclient/+spec/cinder-command-support>`_]
|
@ -568,6 +568,7 @@ openstack.volume.v2 =
|
||||
volume_backup_set = openstackclient.volume.v2.backup:SetVolumeBackup
|
||||
volume_backup_show = openstackclient.volume.v2.backup:ShowVolumeBackup
|
||||
|
||||
volume_host_failover = openstackclient.volume.v2.volume_host:FailoverVolumeHost
|
||||
volume_host_set = openstackclient.volume.v2.volume_host:SetVolumeHost
|
||||
|
||||
volume_snapshot_create = openstackclient.volume.v2.volume_snapshot:CreateVolumeSnapshot
|
||||
|
Loading…
Reference in New Issue
Block a user