Hotplug is not supported by default and thus we raise
HotplugError() for hotplug related methods.
If a hypervisor wants to support it, we must override VerifyHotplugSupport()
and implement the Hot* method.
Backend invokes VerifyHotplugSupport() and raises RPCFail if an
exception is raised.
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
try:
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
try:
- hyper.HotplugSupported(instance, action, dev_type)
- except (errors.HotplugError, errors.HypervisorError), err:
+ hyper.VerifyHotplugSupport(instance, action, dev_type)
+ except errors.HotplugError, err:
_Fail("Hotplug is not supported: %s", err)
if action == constants.HOTPLUG_ACTION_ADD:
_Fail("Hotplug is not supported: %s", err)
if action == constants.HOTPLUG_ACTION_ADD:
+ # pylint: disable=R0201,W0613
def HotAddDevice(self, instance, dev_type, device, extra, seq):
"""Hot-add a device.
"""
def HotAddDevice(self, instance, dev_type, device, extra, seq):
"""Hot-add a device.
"""
+ raise errors.HotplugError("Hotplug is not supported by this hypervisor")
+ # pylint: disable=R0201,W0613
def HotDelDevice(self, instance, dev_type, device, extra, seq):
"""Hot-del a device.
"""
def HotDelDevice(self, instance, dev_type, device, extra, seq):
"""Hot-del a device.
"""
+ raise errors.HotplugError("Hotplug is not supported by this hypervisor")
+ # pylint: disable=R0201,W0613
def HotModDevice(self, instance, dev_type, device, extra, seq):
"""Hot-mod a device.
"""
def HotModDevice(self, instance, dev_type, device, extra, seq):
"""Hot-mod a device.
"""
+ raise errors.HotplugError("Hotplug is not supported by this hypervisor")
+
+ # pylint: disable=R0201,W0613
+ def VerifyHotplugSupport(self, instance, action, dev_type):
+ """Verifies that hotplug is supported.
- def HotplugSupported(self, instance, action, dev_type):
- """Whether hotplug is supported.
+ Hotplug is not supported by default. If a hypervisor wants to support
+ it it should override this method.
+
+ @type instance: L{objects.Instance}
+ @param instance: the instance object
+ @type action: string
+ @param action: one of the supported hotplug commands
+ @type dev_type: string
+ @param dev_type: one of the supported device types to hotplug
+ @raise errors.HotplugError: if hotplugging is not supported
- Depends on instance's hvparam, the action. and the dev_type
- raise NotImplementedError
+ raise errors.HotplugError("Hotplug is not supported by this hypervisor")
"""
raise HypervisorError("Migration not supported by the chroot hypervisor")
"""
raise HypervisorError("Migration not supported by the chroot hypervisor")
-
- def HotplugSupported(self, instance, action, dev_type):
- """Whether hotplug is supported.
-
- """
- raise HypervisorError("Hotplug not supported by the chroot hypervisor")
"""
return objects.MigrationStatus(status=constants.HV_MIGRATION_COMPLETED)
"""
return objects.MigrationStatus(status=constants.HV_MIGRATION_COMPLETED)
-
- def HotplugSupported(self, instance, action, dev_type):
- """Whether hotplug is supported.
-
- """
- raise errors.HypervisorError("Hotplug not supported by the fake hypervisor")
- def HotplugSupported(self, instance, action, dev_type):
- """Check if hotplug is supported.
+ def VerifyHotplugSupport(self, instance, action, dev_type):
+ """Verifies that hotplug is supported.
Hotplug is *not* supported in case of:
- qemu versions < 1.0
- security models and chroot (disk hotplug)
- fdsend module is missing (nic hot-add)
Hotplug is *not* supported in case of:
- qemu versions < 1.0
- security models and chroot (disk hotplug)
- fdsend module is missing (nic hot-add)
- @raise errors.HypervisorError: in previous cases
+ @raise errors.HypervisorError: in one of the previous cases
"""
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
"""
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
action == constants.HOTPLUG_ACTION_ADD and not fdsend):
raise errors.HotplugError("Cannot hot-add NIC."
" fdsend python module is missing.")
action == constants.HOTPLUG_ACTION_ADD and not fdsend):
raise errors.HotplugError("Cannot hot-add NIC."
" fdsend python module is missing.")
def _CallHotplugCommand(self, name, cmd):
output = self._CallMonitorCommand(name, cmd)
def _CallHotplugCommand(self, name, cmd):
output = self._CallMonitorCommand(name, cmd)
"""
raise HypervisorError("Migration is not supported by the LXC hypervisor")
"""
raise HypervisorError("Migration is not supported by the LXC hypervisor")
-
- def HotplugSupported(self, instance, action, dev_type):
- """Whether hotplug is supported.
-
- """
- raise HypervisorError("Hotplug not supported by the LXC hypervisor")
finally:
utils.RunCmd([constants.XEN_CMD, "debug", "R"])
finally:
utils.RunCmd([constants.XEN_CMD, "debug", "R"])
- def HotplugSupported(self, instance, action, dev_type):
- """Whether hotplug is supported.
-
- """
- raise errors.HypervisorError("Hotplug not supported by the xen hypervisor")
-
class XenPvmHypervisor(XenHypervisor):
"""Xen PVM hypervisor interface"""
class XenPvmHypervisor(XenHypervisor):
"""Xen PVM hypervisor interface"""