From 1f334d96302c25443cc466395ab9273d85f10305 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 22 Jul 2010 13:42:01 -0400 Subject: [PATCH] Update the RAPI client for the migration mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the discussion on the previous patch about this. Basically unless we want to a add a new 'feature' marking for the live migration parameter, there is no simple way to handle this nicely in the client. Given that the client was/is marked as experimental, this patch simply replaces live with mode. This means that this client won't work with 2.1 clusters⦠Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: René Nussbaumer <rn@google.com> --- lib/rapi/client.py | 11 ++++++----- test/ganeti.rapi.client_unittest.py | 10 +++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 483f7289a..94000967a 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -1068,13 +1068,14 @@ class GanetiRapiClient(object): ("/%s/nodes/%s/evacuate" % (GANETI_RAPI_VERSION, node)), query, None) - def MigrateNode(self, node, live=True, dry_run=False): + def MigrateNode(self, node, mode=None, dry_run=False): """Migrates all primary instances from a node. @type node: str @param node: node to migrate - @type live: bool - @param live: whether to use live migration + @type mode: string + @param mode: if passed, it will overwrite the live migration type, + otherwise the hypervisor default will be used @type dry_run: bool @param dry_run: whether to perform a dry run @@ -1083,8 +1084,8 @@ class GanetiRapiClient(object): """ query = [] - if live: - query.append(("live", 1)) + if mode is not None: + query.append(("mode", mode)) if dry_run: query.append(("dry-run", 1)) diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index de0474c35..6069bcf99 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -775,7 +775,15 @@ class GanetiRapiClientTests(testutils.GanetiTestCase): self.assertEqual(1111, self.client.MigrateNode("node-a", dry_run=True)) self.assertHandler(rlib2.R_2_nodes_name_migrate) self.assertItems(["node-a"]) - self.assertQuery("live", ["1"]) + self.assert_("mode" not in self.rapi.GetLastHandler().queryargs) + self.assertDryRun() + + self.rapi.AddResponse("1112") + self.assertEqual(1112, self.client.MigrateNode("node-a", dry_run=True, + mode="live")) + self.assertHandler(rlib2.R_2_nodes_name_migrate) + self.assertItems(["node-a"]) + self.assertQuery("mode", ["live"]) self.assertDryRun() def testGetNodeRole(self): -- GitLab