Commit 56e7640c authored by Iustin Pop's avatar Iustin Pop
Browse files

Add an instance_migratable rpc call

This is a forward-port of commit 1194 on the 1.2 branch:

  This call will check whether an instance is up on its primary, and that
  it has been started with symlinks. We currently have no on-secondary
  checks, nor any hypervisor specific call.

  Reviewed-by: iustinp

The difference from the original patch is that we don't include the
cmdlib changes, since those will come as a copy from the 1.2 cmdlib.py,
and not as individual patches.

Original-Author: ultrotter
parent cf8df3f3
......@@ -390,6 +390,14 @@ class NodeHttpServer(http.server.HttpServer):
"""
return backend.GetInstanceInfo(params[0], params[1])
@staticmethod
def perspective_instance_migratable(params):
"""Query whether the specified instance can be migrated.
"""
instance = objects.Instance.FromDict(params[0])
return backend.GetInstanceMigratable(instance)
@staticmethod
def perspective_all_instances_info(params):
"""Query information about all instances.
......
......@@ -597,6 +597,30 @@ def GetInstanceInfo(instance, hname):
return output
def GetInstanceMigratable(instance):
"""Gives whether an instance can be migrated.
@type instance: L{objects.Instance}
@param instance: object representing the instance to be checked.
@rtype: tuple
@return: tuple of (result, description) where:
- result: whether the instance can be migrated or not
- description: a description of the issue, if relevant
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
if instance.name not in hyper.ListInstances():
return (False, 'not running')
for idx in range(len(instance.disks)):
link_name = _GetBlockDevSymlinkPath(instance.name, idx)
if not os.path.islink(link_name):
return (False, 'not restarted since ganeti 1.2.5')
return (True, '')
def GetAllInstancesInfo(hypervisor_list):
"""Gather data about all instances.
......
......@@ -468,6 +468,20 @@ class RpcRunner(object):
"""
return self._SingleNodeCall(node, "instance_info", [instance, hname])
def call_instance_migratable(self, node, instance):
"""Checks whether the given instance can be migrated.
This is a single-node call.
@param node: the node to query
@type instance: L{objects.Instance}
@param instance: the instance to check
"""
return self._SingleNodeCall(node, "instance_migratable",
[self._InstDict(instance)])
def call_all_instances_info(self, node_list, hypervisor_list):
"""Returns information about all instances on the given nodes.
......
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