Add host maintenance mode support for PowerVC Driver

As a cloud admin, it is able to set the host managed by PowerVC to
"maintenance mode" and disable the "maintenance mode" support, through
PowerVC Driver.
1. If set maintenance mode to "true" it responses: "on_maintenance"
2. If set maintenance mode to "false" it responses: "off_maintenance"
3. If set maintenance mode to "true" when the host is already in
maintenance mode, it will report the error message from PowerVC to user.

Change-Id: I59ef830244202a4337ad72292e6341406b8464d3
Closes-Bug: #1363912
This commit is contained in:
Jerry Cai 2014-09-01 17:34:54 +08:00
parent a2971dff90
commit 1c7474486f
3 changed files with 26 additions and 1 deletions

View File

@ -290,6 +290,16 @@ class PVCServerManager(servers.ServerManager):
_resp, body = self.api.client.get(url)
return body
def set_host_maintenance_mode(self, host, mode):
url = "/ego/prs/hypervisor_maintenance/%s" % host
if mode:
status = "enable"
else:
status = "disable"
body = {"status": status,
"migrate": "none"}
return self._update(url, body)
class StorageConnectivityGroup(client_base.Resource):
"""

View File

@ -1021,7 +1021,18 @@ class PowerVCDriver(driver.ComputeDriver):
"""Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.
"""
raise NotImplementedError()
try:
self._service.set_host_maintenance_mode(host, mode)
except Exception as e:
# return powervc error message to uplayer
LOG.error(_("Set host maintenance mode failed: %s"), e)
return e.message
# return 'on_maintenance' or 'off_maintenance' string
# to nova-api response if pvc performed with no Exception
if mode:
return 'on_maintenance'
else:
return 'off_maintenance'
def set_host_enabled(self, host, enabled):
"""Sets the specified host's ability to accept new instances."""

View File

@ -59,6 +59,10 @@ class PowerVCService(object):
self.longrun_initial_delay = CONF.powervc.longrun_initial_delay
# Add version checking as required
def set_host_maintenance_mode(self, host, mode):
resp = self._manager.set_host_maintenance_mode(host, mode)
return resp
def list_instances(self):
"""Return the names of all the instances known to the virtualization
layer, as a list.