From 1dc6c806b32044420bf17d3076dd712185b7ac07 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 5 Dec 2012 23:13:37 +0000 Subject: Fix handling of unimplemented host actions Fixes bug #1060884 Host actions like enable/disable, maintenance mode and power management are not implemented in most virt drivers. In the case of set_host_enabled() in the libvirt driver, we have a no-op implementation. In other cases we have an implementation which raises NotImplementedError. Since the default implementation is to do this, we should just remove the redundant methods from the drivers which don't actually implement these actions. This ensures NotImplementedError is consistently raised. On the API side, rather than looking at the return value of these methods to determine whether they're implemented, we should just catch NotImplementedError and return a sensible error message. In order to do this, we need to ensure the NotImplementedError is properly deserialized from the RemoteError which will encapsualte it. The fix for bug #1086798 ensures this happens. Finally, add some tests to make sure we properly respond with 501 when the virt driver doesn't implement these actions. Change-Id: I2d4fc51a4b16d5230e61bde75915142ea450557d --- nova/virt/hyperv/driver.py | 4 ---- nova/virt/libvirt/driver.py | 13 ------------- nova/virt/vmwareapi/driver.py | 13 ------------- 3 files changed, 30 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/hyperv/driver.py b/nova/virt/hyperv/driver.py index 3b0539159..d1b9904c4 100644 --- a/nova/virt/hyperv/driver.py +++ b/nova/virt/hyperv/driver.py @@ -131,10 +131,6 @@ class HyperVDriver(driver.ComputeDriver): def host_power_action(self, host, action): return self._hostops.host_power_action(host, action) - def set_host_enabled(self, host, enabled): - """Sets the specified host's ability to accept new instances.""" - pass - def snapshot(self, context, instance, name): self._snapshotops.snapshot(context, instance, name) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 750ffb0a2..c3b6c4244 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2819,19 +2819,6 @@ class LibvirtDriver(driver.ComputeDriver): If 'refresh' is True, run update the stats first.""" return self.host_state.get_host_stats(refresh=refresh) - def host_power_action(self, host, action): - """Reboots, shuts down or powers up the host.""" - raise NotImplementedError() - - def host_maintenance_mode(self, host, mode): - """Start/Stop host maintenance window. On start, it triggers - guest VMs evacuation.""" - raise NotImplementedError() - - def set_host_enabled(self, host, enabled): - """Sets the specified host's ability to accept new instances.""" - pass - def get_host_uptime(self, host): """Returns the result of calling "uptime".""" #NOTE(dprince): host seems to be ignored for this call and in diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py index ee97416ec..f6aa91e85 100644 --- a/nova/virt/vmwareapi/driver.py +++ b/nova/virt/vmwareapi/driver.py @@ -199,19 +199,6 @@ class VMWareESXDriver(driver.ComputeDriver): """This method is supported only by libvirt.""" return - def host_power_action(self, host, action): - """Reboots, shuts down or powers up the host.""" - raise NotImplementedError() - - def host_maintenance_mode(self, host, mode): - """Start/Stop host maintenance window. On start, it triggers - guest VMs evacuation.""" - raise NotImplementedError() - - def set_host_enabled(self, host, enabled): - """Sets the specified host's ability to accept new instances.""" - raise NotImplementedError() - def plug_vifs(self, instance, network_info): """Plug VIFs into networks.""" self._vmops.plug_vifs(instance, network_info) -- cgit