cluster_name = ssconf.SimpleStore().GetClusterName()
return self._MigrateInstance(cluster_name, instance.name, target, port,
- live)
+ live, instance.hvparams)
def _MigrateInstance(self, cluster_name, instance_name, target, port, live,
- _ping_fn=netutils.TcpPing):
+ hvparams, _ping_fn=netutils.TcpPing):
"""Migrate an instance to a target node.
@see: L{MigrateInstance} for details
"""
- if self.GetInstanceInfo(instance_name) is None:
+ if hvparams is None:
+ raise errors.HypervisorError("No hvparams provided.")
+
+ if self.GetInstanceInfo(instance_name, hvparams=hvparams) is None:
raise errors.HypervisorError("Instance not running, cannot migrate")
- cmd = self._GetCommand()
+ cmd = self._GetCommand(hvparams=hvparams)
if (cmd == constants.XEN_CMD_XM and
not _ping_fn(target, port, live_port_needed=True)):
TARGET = NotImplemented
CMD = NotImplemented
HVNAME = NotImplemented
+ VALID_HVPARAMS = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
def setUp(self):
super(_TestXenHypervisor, self).setUp()
for live in [False, True]:
try:
hv._MigrateInstance(NotImplemented, name, target, port, live,
- _ping_fn=NotImplemented)
+ self.VALID_HVPARAMS, _ping_fn=NotImplemented)
except errors.HypervisorError, err:
self.assertEqual(str(err), "Instance not running, cannot migrate")
else:
port = 28349
hv = self._GetHv(run_cmd=self._MigrateInstTargetUnreachCmd)
+ hvparams = {constants.HV_XEN_CMD: self.CMD}
for live in [False, True]:
if self.CMD == constants.XEN_CMD_XL:
else:
try:
hv._MigrateInstance(NotImplemented, name, target, port, live,
+ hvparams,
_ping_fn=compat.partial(self._FakeTcpPing,
(target, port), False))
except errors.HypervisorError, err:
target = constants.IP4_ADDRESS_LOCALHOST
port = 22364
+ hvparams = {constants.HV_XEN_CMD: self.CMD}
+
for live in [False, True]:
for fail in [False, True]:
ping_fn = \
if fail:
try:
hv._MigrateInstance(clustername, instname, target, port, live,
- _ping_fn=ping_fn)
+ hvparams, _ping_fn=ping_fn)
except errors.HypervisorError, err:
self.assertTrue(str(err).startswith("Failed to migrate instance"))
else:
self.fail("Exception was not raised")
else:
hv._MigrateInstance(clustername, instname, target, port, live,
- _ping_fn=ping_fn)
+ hvparams, _ping_fn=ping_fn)
if self.CMD == constants.XEN_CMD_XM:
expected_pings = 1