summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-02-18 06:25:10 +0000
committerGerrit Code Review <review@openstack.org>2017-02-18 06:25:10 +0000
commit1b4605e4add3823f293d3ad063359787a469c52e (patch)
tree54ff0d5b58419b06feb807bed9511512a273ca67 /openstackclient
parentc88975136d675c947167533191b75c849cd0a1b5 (diff)
parent55195cec46fadd88f6151783b1e17557d5e94940 (diff)
downloadpython-openstackclient-1b4605e4add3823f293d3ad063359787a469c52e.tar.gz
Merge "Add "volume host failover" command"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_host.py31
-rw-r--r--openstackclient/volume/v2/volume_host.py29
2 files changed, 58 insertions, 2 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_host.py b/openstackclient/tests/unit/volume/v2/test_volume_host.py
index aad7bb0b..b024329a 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_host.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_host.py
@@ -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)
diff --git a/openstackclient/volume/v2/volume_host.py b/openstackclient/volume/v2/volume_host.py
index 376e5024..2fdeb968 100644
--- a/openstackclient/volume/v2/volume_host.py
+++ b/openstackclient/volume/v2/volume_host.py
@@ -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