Merge "adding the mgmt migrate to specific host api call"

This commit is contained in:
Jenkins
2013-04-11 17:38:55 +00:00
committed by Gerrit Code Review
3 changed files with 14 additions and 3 deletions

View File

@@ -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):

View File

@@ -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."""

View File

@@ -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)