From 2a10865c50390dbc54c60a04d814710fa7e08b56 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 16 Jun 2008 13:57:36 +0000 Subject: [PATCH] Add migration support at the rpc layer This patch adds the migration rpc call and its implementation in the backend. The patch does not deal with the correct activation of disks. Because of the new RPC, the protocol version is increased. Reviewed-by: imsnah --- daemons/ganeti-noded | 8 ++++++++ lib/backend.py | 15 +++++++++++++++ lib/constants.py | 2 +- lib/rpc.py | 12 ++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index a493624c2..b68a8faf0 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -340,6 +340,14 @@ class ServerObject(BaseHTTPServer.BaseHTTPRequestHandler): extra_args = params[1] return backend.StartInstance(instance, extra_args) + @staticmethod + def perspective_instance_migrate(params): + """Migrates an instance. + + """ + instance, target, live = params + return backend.MigrateInstance(instance, target, live) + @staticmethod def perspective_instance_reboot(params): """Reboot an instance. diff --git a/lib/backend.py b/lib/backend.py index 8caf53f35..89ceb2491 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -672,6 +672,21 @@ def RebootInstance(instance, reboot_type, extra_args): return True +def MigrateInstance(instance, target, live): + """Migrates an instance to another node. + + """ + hyper = hypervisor.GetHypervisor() + + try: + hyper.MigrateInstance(instance, target, live) + except errors.HypervisorError, err: + msg = "Failed to migrate instance: %s" % str(err) + logger.Error(msg) + return (False, msg) + return (True, "Migration successfull") + + def CreateBlockDevice(disk, size, owner, on_primary, info): """Creates a block device for an instance. diff --git a/lib/constants.py b/lib/constants.py index b6305d43c..062d94311 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -24,7 +24,7 @@ from ganeti import _autoconf # various versions -PROTOCOL_VERSION = 12 +PROTOCOL_VERSION = 13 RELEASE_VERSION = _autoconf.PACKAGE_VERSION OS_API_VERSION = 5 EXPORT_VERSION = 0 diff --git a/lib/rpc.py b/lib/rpc.py index 0efb6a7bc..8b5e5baac 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -208,6 +208,18 @@ def call_instance_shutdown(node, instance): return c.getresult().get(node, False) +def call_instance_migrate(node, instance, target, live): + """Migrate an instance. + + This is a single-node call. + + """ + c = Client("instance_migrate", [instance.name, target, live]) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + def call_instance_reboot(node, instance, reboot_type, extra_args): """Reboots an instance. -- GitLab