Commit cd42d0ad authored by Guido Trotter's avatar Guido Trotter
Browse files

Implement the new live migration backend functions

MigrationInfo, AcceptInstance and AbortMigration are implemented as
hypervisor specific functions, and by default they do nothing (as
they're not always necessary).

This patch also converts hv_base.MigrateInstance docstring to epydoc,
adds a missing @type to the GetInstanceInfo docstring, and removes an
unneeded empty line.

Reviewed-by: iustinp
parent 38e250ba
......@@ -980,7 +980,14 @@ def MigrationInfo(instance):
@param instance: the instance definition
"""
return (True, '')
hyper = hypervisor.GetHypervisor(instance.hypervisor)
try:
info = hyper.MigrationInfo(instance)
except errors.HypervisorError, err:
msg = "Failed to fetch migration information"
logging.exception(msg)
return (False, '%s: %s' % (msg, err))
return (True, info)
def AcceptInstance(instance, info, target):
......@@ -994,6 +1001,13 @@ def AcceptInstance(instance, info, target):
@param target: target host (usually ip), on this node
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
try:
hyper.AcceptInstance(instance, info, target)
except errors.HypervisorError, err:
msg = "Failed to accept instance"
logging.exception(msg)
return (False, '%s: %s' % (msg, err))
return (True, "Accept successfull")
......@@ -1008,6 +1022,13 @@ def FinalizeMigration(instance, info, success):
@param success: whether the migration was a success or a failure
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
try:
hyper.FinalizeMigration(instance, info, success)
except errors.HypervisorError, err:
msg = "Failed to finalize migration"
logging.exception(msg)
return (False, '%s: %s' % (msg, err))
return (True, "Migration Finalized")
......
......@@ -57,6 +57,7 @@ class BaseHypervisor(object):
def GetInstanceInfo(self, instance_name):
"""Get instance properties.
@type instance_name: string
@param instance_name: the instance name
@return: tuple (name, id, memory, vcpus, state, times)
......@@ -96,20 +97,63 @@ class BaseHypervisor(object):
"""
raise NotImplementedError
def MigrationInfo(self, instance):
"""Get instance information to perform a migration.
By default assume no information is needed.
@type instance: L{objects.Instance}
@param instance: instance to be migrated
@rtype: string/data (opaque)
@return: instance migration information - serialized form
"""
return ''
def AcceptInstance(self, instance, info, target):
"""Prepare to accept an instance.
By default assume no preparation is needed.
@type instance: L{objects.Instance}
@param instance: instance to be accepted
@type info: string/data (opaque)
@param info: migration information, from the source node
@type target: string
@param target: target host (usually ip), on this node
"""
pass
def FinalizeMigration(self, instance, info, success):
"""Finalized an instance migration.
Should finalize or revert any preparation done to accept the instance.
Since by default we do no preparation, we also don't have anything to do
@type instance: L{objects.Instance}
@param instance: instance whose migration is being aborted
@type info: string/data (opaque)
@param info: migration information, from the source node
@type success: boolean
@param success: whether the migration was a success or a failure
"""
pass
def MigrateInstance(self, name, target, live):
"""Migrate an instance.
Arguments:
- name: the name of the instance
- target: the target of the migration (usually will be IP and not name)
- live: whether to do live migration or not
Returns: none, errors will be signaled by exception.
@type name: string
@param name: name of the instance to be migrated
@type target: string
@param target: hostname (usually ip) of the target node
@type live: boolean
@param live: whether to do a live or non-live migration
"""
raise NotImplementedError
@classmethod
def CheckParameterSyntax(cls, hvparams):
"""Check the given parameters for validity.
......
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