Commit 2a10865c authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent 6e7275c0
......@@ -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.
......
......@@ -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.
......
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment