Revision ee6ed186
b/lib/backend.py | ||
---|---|---|
1626 | 1626 |
_Fail("Failed to get migration status: %s", err, exc=True) |
1627 | 1627 |
|
1628 | 1628 |
|
1629 |
def HotplugDevice(instance, action, dev_type, device, extra, seq): |
|
1630 |
"""Hotplug a device |
|
1631 |
|
|
1632 |
Hotplug is currently supported only for KVM Hypervisor. |
|
1633 |
@type instance: L{objects.Instance} |
|
1634 |
@param instance: the instance to which we hotplug a device |
|
1635 |
@type action: string |
|
1636 |
@param action: the hotplug action to perform |
|
1637 |
@type dev_type: string |
|
1638 |
@param dev_type: the device type to hotplug |
|
1639 |
@type device: either L{objects.NIC} or L{objects.Disk} |
|
1640 |
@param device: the device object to hotplug |
|
1641 |
@type extra: string |
|
1642 |
@param extra: extra info used by hotplug code (e.g. disk link) |
|
1643 |
@type seq: int |
|
1644 |
@param seq: the index of the device from master perspective |
|
1645 |
@raise RPCFail: in case instance does not have KVM hypervisor |
|
1646 |
|
|
1647 |
""" |
|
1648 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1649 |
try: |
|
1650 |
hyper.HotplugSupported(instance, action, dev_type) |
|
1651 |
except (errors.HotplugError, errors.HypervisorError), err: |
|
1652 |
_Fail("Hotplug is not supported: %s", err) |
|
1653 |
|
|
1654 |
if action == constants.HOTPLUG_ACTION_ADD: |
|
1655 |
fn = hyper.HotAddDevice |
|
1656 |
elif action == constants.HOTPLUG_ACTION_REMOVE: |
|
1657 |
fn = hyper.HotDelDevice |
|
1658 |
elif action == constants.HOTPLUG_ACTION_MODIFY: |
|
1659 |
fn = hyper.HotModDevice |
|
1660 |
else: |
|
1661 |
assert action in constants.HOTPLUG_ALL_ACTIONS |
|
1662 |
|
|
1663 |
return fn(instance, dev_type, device, extra, seq) |
|
1664 |
|
|
1665 |
|
|
1629 | 1666 |
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor): |
1630 | 1667 |
"""Creates a block device for an instance. |
1631 | 1668 |
|
b/lib/hypervisor/hv_base.py | ||
---|---|---|
538 | 538 |
return "; ".join(msgs) |
539 | 539 |
else: |
540 | 540 |
return None |
541 |
|
|
542 |
def HotAddDevice(self, instance, dev_type, device, extra, seq): |
|
543 |
"""Hot-add a device. |
|
544 |
|
|
545 |
""" |
|
546 |
pass |
|
547 |
|
|
548 |
def HotDelDevice(self, instance, dev_type, device, extra, seq): |
|
549 |
"""Hot-del a device. |
|
550 |
|
|
551 |
""" |
|
552 |
pass |
|
553 |
|
|
554 |
def HotModDevice(self, instance, dev_type, device, extra, seq): |
|
555 |
"""Hot-mod a device. |
|
556 |
|
|
557 |
""" |
|
558 |
pass |
|
559 |
|
|
560 |
def HotplugSupported(self, instance, action, dev_type): |
|
561 |
"""Whether hotplug is supported. |
|
562 |
|
|
563 |
Depends on instance's hvparam, the action. and the dev_type |
|
564 |
""" |
|
565 |
raise NotImplementedError |
b/lib/hypervisor/hv_chroot.py | ||
---|---|---|
321 | 321 |
|
322 | 322 |
""" |
323 | 323 |
raise HypervisorError("Migration not supported by the chroot hypervisor") |
324 |
|
|
325 |
def HotplugSupported(self, instance, action, dev_type): |
|
326 |
"""Whether hotplug is supported. |
|
327 |
|
|
328 |
""" |
|
329 |
raise HypervisorError("Hotplug not supported by the chroot hypervisor") |
b/lib/hypervisor/hv_fake.py | ||
---|---|---|
341 | 341 |
|
342 | 342 |
""" |
343 | 343 |
return objects.MigrationStatus(status=constants.HV_MIGRATION_COMPLETED) |
344 |
|
|
345 |
def HotplugSupported(self, instance, action, dev_type): |
|
346 |
"""Whether hotplug is supported. |
|
347 |
|
|
348 |
""" |
|
349 |
raise errors.HypervisorError("Hotplug not supported by the fake hypervisor") |
b/lib/hypervisor/hv_lxc.py | ||
---|---|---|
470 | 470 |
|
471 | 471 |
""" |
472 | 472 |
raise HypervisorError("Migration is not supported by the LXC hypervisor") |
473 |
|
|
474 |
def HotplugSupported(self, instance, action, dev_type): |
|
475 |
"""Whether hotplug is supported. |
|
476 |
|
|
477 |
""" |
|
478 |
raise HypervisorError("Hotplug not supported by the LXC hypervisor") |
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
897 | 897 |
finally: |
898 | 898 |
utils.RunCmd([constants.XEN_CMD, "debug", "R"]) |
899 | 899 |
|
900 |
def HotplugSupported(self, instance, action, dev_type): |
|
901 |
"""Whether hotplug is supported. |
|
902 |
|
|
903 |
""" |
|
904 |
raise errors.HypervisorError("Hotplug not supported by the xen hypervisor") |
|
905 |
|
|
900 | 906 |
|
901 | 907 |
class XenPvmHypervisor(XenHypervisor): |
902 | 908 |
"""Xen PVM hypervisor interface""" |
b/lib/rpc.py | ||
---|---|---|
702 | 702 |
rpc_defs.ED_INST_DICT_HVP_BEP_DP: self._InstDictHvpBepDp, |
703 | 703 |
rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp, |
704 | 704 |
rpc_defs.ED_NIC_DICT: self._NicDict, |
705 |
rpc_defs.ED_DEVICE_DICT: self._DeviceDict, |
|
705 | 706 |
|
706 | 707 |
# Encoders annotating disk parameters |
707 | 708 |
rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP, |
... | ... | |
739 | 740 |
n.netinfo = objects.Network.ToDict(nobj) |
740 | 741 |
return n.ToDict() |
741 | 742 |
|
743 |
def _DeviceDict(self, device): |
|
744 |
if isinstance(device, objects.NIC): |
|
745 |
return self._NicDict(device) |
|
746 |
elif isinstance(device, objects.Disk): |
|
747 |
return _ObjectToDict(device) |
|
748 |
|
|
742 | 749 |
def _InstDict(self, instance, hvp=None, bep=None, osp=None): |
743 | 750 |
"""Convert the given instance to a dict. |
744 | 751 |
|
b/lib/rpc_defs.py | ||
---|---|---|
71 | 71 |
ED_BLOCKDEV_RENAME, |
72 | 72 |
ED_DISKS_DICT_DP, |
73 | 73 |
ED_SINGLE_DISK_DICT_DP, |
74 |
ED_NIC_DICT) = range(1, 15) |
|
74 |
ED_NIC_DICT, |
|
75 |
ED_DEVICE_DICT) = range(1, 16) |
|
75 | 76 |
|
76 | 77 |
|
77 | 78 |
def _Prepare(calls): |
... | ... | |
286 | 287 |
("reinstall", None, None), |
287 | 288 |
("debug", None, None), |
288 | 289 |
], None, None, "Starts an instance"), |
290 |
("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
|
291 |
("instance", ED_INST_DICT, "Instance object"), |
|
292 |
("action", None, "Hotplug Action"), |
|
293 |
("dev_type", None, "Device type"), |
|
294 |
("device", ED_DEVICE_DICT, "Device dict"), |
|
295 |
("extra", None, "Extra info for device (dev_path for disk)"), |
|
296 |
("seq", None, "Device seq"), |
|
297 |
], None, None, "Hoplug a device to a running instance"), |
|
289 | 298 |
] |
290 | 299 |
|
291 | 300 |
_IMPEXP_CALLS = [ |
b/lib/server/noded.py | ||
---|---|---|
604 | 604 |
return backend.StartInstance(instance, startup_paused, trail) |
605 | 605 |
|
606 | 606 |
@staticmethod |
607 |
def perspective_hotplug_device(params): |
|
608 |
"""Hotplugs device to a running instance. |
|
609 |
|
|
610 |
""" |
|
611 |
(idict, action, dev_type, ddict, extra, seq) = params |
|
612 |
instance = objects.Instance.FromDict(idict) |
|
613 |
if dev_type == constants.HOTPLUG_TARGET_DISK: |
|
614 |
device = objects.Disk.FromDict(ddict) |
|
615 |
elif dev_type == constants.HOTPLUG_TARGET_NIC: |
|
616 |
device = objects.NIC.FromDict(ddict) |
|
617 |
else: |
|
618 |
assert dev_type in constants.HOTPLUG_ALL_TARGETS |
|
619 |
return backend.HotplugDevice(instance, action, dev_type, device, extra, seq) |
|
620 |
|
|
621 |
@staticmethod |
|
607 | 622 |
def perspective_migration_info(params): |
608 | 623 |
"""Gather information about an instance to be migrated. |
609 | 624 |
|
Also available in: Unified diff