From cf1cc4c0569a07ce39e0470bf21ba5feab157f18 Mon Sep 17 00:00:00 2001 From: Craig Vyvial Date: Wed, 13 Mar 2013 11:57:27 -0500 Subject: [PATCH] adding the mgmt migrate to specific host api call implements blueprint migrate-to-host Change-Id: If7c4b02a2616d9dfebdfab8af91dd999fd6f3156 --- reddwarfclient/management.py | 7 +++++-- reddwarfclient/mcli.py | 3 ++- tests/test_management.py | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/reddwarfclient/management.py b/reddwarfclient/management.py index 346999d8..931c0d59 100644 --- a/reddwarfclient/management.py +++ b/reddwarfclient/management.py @@ -109,13 +109,16 @@ class Management(base.ManagerWithFind): body = {'reboot': {}} self._action(instance_id, body) - def migrate(self, instance_id): + def migrate(self, instance_id, host=None): """ Migrate the instance. :param instance_id: The :class:`Instance` (or its ID) to share onto. """ - body = {'migrate': {}} + if host: + body = {'migrate': {'host': host}} + else: + body = {'migrate': {}} self._action(instance_id, body) def update(self, instance_id): diff --git a/reddwarfclient/mcli.py b/reddwarfclient/mcli.py index fdcbf9be..e26af90d 100644 --- a/reddwarfclient/mcli.py +++ b/reddwarfclient/mcli.py @@ -125,6 +125,7 @@ class InstanceCommands(common.AuthedCommandsBase): 'id', 'limit', 'marker', + 'host', ] def get(self): @@ -165,7 +166,7 @@ class InstanceCommands(common.AuthedCommandsBase): def migrate(self): """Migrate the instance.""" self._require('id') - self._pretty_print(self.dbaas.management.migrate, self.id) + self._pretty_print(self.dbaas.management.migrate, self.id, self.host) def reset_task_status(self): """Set the instance's task status to NONE.""" diff --git a/tests/test_management.py b/tests/test_management.py index ddbb38ca..810961ac 100644 --- a/tests/test_management.py +++ b/tests/test_management.py @@ -124,6 +124,13 @@ class ManagementTest(TestCase): self.assertEqual(1, self.management._action.call_count) self.assertEqual({'migrate': {}}, self.body_) + def test_migrate_to_host(self): + hostname = 'hostname2' + self._mock_action() + self.management.migrate(1, host=hostname) + self.assertEqual(1, self.management._action.call_count) + self.assertEqual({'migrate': {'host': hostname}}, self.body_) + def test_update(self): self._mock_action() self.management.update(1)