Revision 6e7275c0

b/lib/hypervisor/hv_base.py
93 93

  
94 94
    """
95 95
    raise NotImplementedError
96

  
97
  def MigrateInstance(self, name, target, live):
98
    """Migrate an instance.
99

  
100
    Arguments:
101
      - name: the name of the instance
102
      - target: the target of the migration (usually will be IP and not name)
103
      - live: whether to do live migration or not
104

  
105
    Returns: none, errors will be signaled by exception.
106

  
107
    """
108
    raise NotImplementedError
b/lib/hypervisor/hv_xen.py
257 257

  
258 258
    return disk_data
259 259

  
260
  def MigrateInstance(self, instance, target, live):
261
    """Migrate an instance to a target node.
262

  
263
    Arguments:
264
      - instance: the name of the instance
265
      - target: the ip of the target node
266
      - live: whether to do live migration or not
267

  
268
    Returns: none, errors will be signaled by exception.
269

  
270
    The migration will not be attempted if the instance is not
271
    currently running.
272

  
273
    """
274
    if self.GetInstanceInfo(instance) is None:
275
      raise errors.HypervisorError("Instance not running, cannot migrate")
276
    args = ["xm", "migrate"]
277
    if live:
278
      args.append("-l")
279
    args.extend([instance, target])
280
    result = utils.RunCmd(args)
281
    if result.failed:
282
      raise errors.HypervisorError("Failed to migrate instance %s: %s" %
283
                                   (instance, result.output))
284

  
260 285

  
261 286
class XenPvmHypervisor(XenHypervisor):
262 287
  """Xen PVM hypervisor interface"""

Also available in: Unified diff