diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index a493624c2331b3bf97a2087cb4cc9cb14a9affa9..b68a8faf0fdf4ed98ecbc80a62d164d39b09498a 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 8caf53f35b10bd04b296a8d76a33192339a31b25..89ceb2491be414fd135d30760422480f2887efe5 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 b6305d43c1a76a1925f11d7a9f142aca9eab3952..062d94311911bd9aee178685fdc0598944ebaf78 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 0efb6a7bcc83824663938f9f74b70a6bcc2d40ee..8b5e5baac8925deefbd2013752a2705b7b728cfb 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.