Revision c5708931
b/lib/backend.py | ||
---|---|---|
1966 | 1966 |
_Fail("Failed to get migration status: %s", err, exc=True) |
1967 | 1967 |
|
1968 | 1968 |
|
1969 |
def HotplugDevice(instance, action, dev_type, device, extra, seq): |
|
1970 |
"""Hotplug a device |
|
1971 |
|
|
1972 |
Hotplug is currently supported only for KVM Hypervisor. |
|
1973 |
@type instance: L{objects.Instance} |
|
1974 |
@param instance: the instance to which we hotplug a device |
|
1975 |
@type action: string |
|
1976 |
@param action: the hotplug action to perform |
|
1977 |
@type dev_type: string |
|
1978 |
@param dev_type: the device type to hotplug |
|
1979 |
@type device: either L{objects.NIC} or L{objects.Disk} |
|
1980 |
@param device: the device object to hotplug |
|
1981 |
@type extra: string |
|
1982 |
@param extra: extra info used by hotplug code (e.g. disk link) |
|
1983 |
@type seq: int |
|
1984 |
@param seq: the index of the device from master perspective |
|
1985 |
@raise RPCFail: in case instance does not have KVM hypervisor |
|
1986 |
|
|
1987 |
""" |
|
1988 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1989 |
try: |
|
1990 |
hyper.HotplugSupported(instance, action, dev_type) |
|
1991 |
except (errors.HotplugError, errors.HypervisorError), err: |
|
1992 |
_Fail("Hotplug is not supported: %s", err) |
|
1993 |
|
|
1994 |
if action == constants.HOTPLUG_ACTION_ADD: |
|
1995 |
fn = hyper.HotAddDevice |
|
1996 |
elif action == constants.HOTPLUG_ACTION_REMOVE: |
|
1997 |
fn = hyper.HotDelDevice |
|
1998 |
elif action == constants.HOTPLUG_ACTION_MODIFY: |
|
1999 |
fn = hyper.HotModDevice |
|
2000 |
else: |
|
2001 |
assert action in constants.HOTPLUG_ALL_ACTIONS |
|
2002 |
|
|
2003 |
return fn(instance, dev_type, device, extra, seq) |
|
2004 |
|
|
2005 |
|
|
1969 | 2006 |
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor): |
1970 | 2007 |
"""Creates a block device for an instance. |
1971 | 2008 |
|
b/lib/hypervisor/hv_base.py | ||
---|---|---|
563 | 563 |
return "; ".join(msgs) |
564 | 564 |
else: |
565 | 565 |
return None |
566 |
|
|
567 |
def HotAddDevice(self, instance, dev_type, device, extra, seq): |
|
568 |
"""Hot-add a device. |
|
569 |
|
|
570 |
""" |
|
571 |
pass |
|
572 |
|
|
573 |
def HotDelDevice(self, instance, dev_type, device, extra, seq): |
|
574 |
"""Hot-del a device. |
|
575 |
|
|
576 |
""" |
|
577 |
pass |
|
578 |
|
|
579 |
def HotModDevice(self, instance, dev_type, device, extra, seq): |
|
580 |
"""Hot-mod a device. |
|
581 |
|
|
582 |
""" |
|
583 |
pass |
|
584 |
|
|
585 |
def HotplugSupported(self, instance, action, dev_type): |
|
586 |
"""Whether hotplug is supported. |
|
587 |
|
|
588 |
Depends on instance's hvparam, the action. and the dev_type |
|
589 |
""" |
|
590 |
raise NotImplementedError |
b/lib/hypervisor/hv_chroot.py | ||
---|---|---|
329 | 329 |
|
330 | 330 |
""" |
331 | 331 |
raise HypervisorError("Migration not supported by the chroot hypervisor") |
332 |
|
|
333 |
def HotplugSupported(self, instance, action, dev_type): |
|
334 |
"""Whether hotplug is supported. |
|
335 |
|
|
336 |
""" |
|
337 |
raise HypervisorError("Hotplug not supported by the chroot hypervisor") |
b/lib/hypervisor/hv_fake.py | ||
---|---|---|
354 | 354 |
|
355 | 355 |
""" |
356 | 356 |
return objects.MigrationStatus(status=constants.HV_MIGRATION_COMPLETED) |
357 |
|
|
358 |
def HotplugSupported(self, instance, action, dev_type): |
|
359 |
"""Whether hotplug is supported. |
|
360 |
|
|
361 |
""" |
|
362 |
raise errors.HypervisorError("Hotplug not supported by the fake hypervisor") |
b/lib/hypervisor/hv_lxc.py | ||
---|---|---|
477 | 477 |
|
478 | 478 |
""" |
479 | 479 |
raise HypervisorError("Migration is not supported by the LXC hypervisor") |
480 |
|
|
481 |
def HotplugSupported(self, instance, action, dev_type): |
|
482 |
"""Whether hotplug is supported. |
|
483 |
|
|
484 |
""" |
|
485 |
raise HypervisorError("Hotplug not supported by the LXC hypervisor") |
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
948 | 948 |
raise errors.HypervisorError("Cannot run xen ('%s'). Error: %s." |
949 | 949 |
% (constants.XEN_CMD_XL, result.stderr)) |
950 | 950 |
|
951 |
def HotplugSupported(self, instance, action, dev_type): |
|
952 |
"""Whether hotplug is supported. |
|
953 |
|
|
954 |
""" |
|
955 |
raise errors.HypervisorError("Hotplug not supported by the xen hypervisor") |
|
956 |
|
|
951 | 957 |
|
952 | 958 |
class XenPvmHypervisor(XenHypervisor): |
953 | 959 |
"""Xen PVM hypervisor interface""" |
b/lib/rpc.py | ||
---|---|---|
790 | 790 |
rpc_defs.ED_INST_DICT_HVP_BEP_DP: self._InstDictHvpBepDp, |
791 | 791 |
rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp, |
792 | 792 |
rpc_defs.ED_NIC_DICT: self._NicDict, |
793 |
rpc_defs.ED_DEVICE_DICT: self._DeviceDict, |
|
793 | 794 |
|
794 | 795 |
# Encoders annotating disk parameters |
795 | 796 |
rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP, |
... | ... | |
831 | 832 |
n.netinfo = objects.Network.ToDict(nobj) |
832 | 833 |
return n.ToDict() |
833 | 834 |
|
835 |
def _DeviceDict(self, _, device): |
|
836 |
if isinstance(device, objects.NIC): |
|
837 |
return self._NicDict(None, device) |
|
838 |
elif isinstance(device, objects.Disk): |
|
839 |
return _ObjectToDict(None, device) |
|
840 |
|
|
834 | 841 |
def _InstDict(self, node, instance, hvp=None, bep=None, osp=None): |
835 | 842 |
"""Convert the given instance to a dict. |
836 | 843 |
|
b/lib/rpc_defs.py | ||
---|---|---|
72 | 72 |
ED_DISKS_DICT_DP, |
73 | 73 |
ED_MULTI_DISKS_DICT_DP, |
74 | 74 |
ED_SINGLE_DISK_DICT_DP, |
75 |
ED_NIC_DICT) = range(1, 16) |
|
75 |
ED_NIC_DICT, |
|
76 |
ED_DEVICE_DICT) = range(1, 17) |
|
76 | 77 |
|
77 | 78 |
|
78 | 79 |
def _Prepare(calls): |
... | ... | |
291 | 292 |
("reinstall", None, None), |
292 | 293 |
("debug", None, None), |
293 | 294 |
], None, None, "Starts an instance"), |
295 |
("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
|
296 |
("instance", ED_INST_DICT, "Instance object"), |
|
297 |
("action", None, "Hotplug Action"), |
|
298 |
("dev_type", None, "Device type"), |
|
299 |
("device", ED_DEVICE_DICT, "Device dict"), |
|
300 |
("extra", None, "Extra info for device (dev_path for disk)"), |
|
301 |
("seq", None, "Device seq"), |
|
302 |
], None, None, "Hoplug a device to a running instance"), |
|
294 | 303 |
] |
295 | 304 |
|
296 | 305 |
_IMPEXP_CALLS = [ |
b/lib/server/noded.py | ||
---|---|---|
616 | 616 |
return backend.StartInstance(instance, startup_paused, trail) |
617 | 617 |
|
618 | 618 |
@staticmethod |
619 |
def perspective_hotplug_device(params): |
|
620 |
"""Hotplugs device to a running instance. |
|
621 |
|
|
622 |
""" |
|
623 |
(idict, action, dev_type, ddict, extra, seq) = params |
|
624 |
instance = objects.Instance.FromDict(idict) |
|
625 |
if dev_type == constants.HOTPLUG_TARGET_DISK: |
|
626 |
device = objects.Disk.FromDict(ddict) |
|
627 |
elif dev_type == constants.HOTPLUG_TARGET_NIC: |
|
628 |
device = objects.NIC.FromDict(ddict) |
|
629 |
else: |
|
630 |
assert dev_type in constants.HOTPLUG_ALL_TARGETS |
|
631 |
return backend.HotplugDevice(instance, action, dev_type, device, extra, seq) |
|
632 |
|
|
633 |
@staticmethod |
|
619 | 634 |
def perspective_migration_info(params): |
620 | 635 |
"""Gather information about an instance to be migrated. |
621 | 636 |
|
Also available in: Unified diff