Check host status that disable the host service if host is down
Check host status that disable the host service if host is down Change-Id: I241262e3bf055821cde96a52bfbefa3018cb7b27 Closes-Bug: #1498369
This commit is contained in:
parent
d0be0b27d7
commit
8b6a7a3544
|
@ -40,6 +40,23 @@ class PVCHypervisorManager(hypervisors.HypervisorManager):
|
||||||
feature to get/set the hypervisor status and maintenance mode.
|
feature to get/set the hypervisor status and maintenance mode.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_hypervisor_state(self, hostname):
|
||||||
|
"""Get the hypervisor_state by hostname
|
||||||
|
"""
|
||||||
|
hypervisors = self.search(hostname)
|
||||||
|
|
||||||
|
if not hypervisors[0] or not self.get(hypervisors[0]):
|
||||||
|
raise exc.HTTPNotFound(_("No hypervisor matching '%s' could be"
|
||||||
|
" found.") % hostname)
|
||||||
|
|
||||||
|
try:
|
||||||
|
hypervisor = self.get(hypervisors[0])
|
||||||
|
except Exception as ex:
|
||||||
|
raise exc.HTTPNotFound(explanation=six.text_type(ex))
|
||||||
|
|
||||||
|
hypervisor_state = getattr(hypervisor, "hypervisor_state", "operating")
|
||||||
|
return hypervisor_state
|
||||||
|
|
||||||
def get_host_maintenance_mode(self, hostname):
|
def get_host_maintenance_mode(self, hostname):
|
||||||
"""Get host maintenance mode by host name from PowerVC driver
|
"""Get host maintenance mode by host name from PowerVC driver
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -188,16 +188,27 @@ class ComputeServiceManager(object):
|
||||||
to the remote_service. This method assumes the local
|
to the remote_service. This method assumes the local
|
||||||
service already exists.
|
service already exists.
|
||||||
"""
|
"""
|
||||||
local_service = self.services[remote_service.host]
|
hostname = remote_service.host
|
||||||
|
local_service = self.services[hostname]
|
||||||
if local_service is None:
|
if local_service is None:
|
||||||
LOG.debug("local service not found for %s" % remote_service.host)
|
LOG.debug("local service not found for %s" % hostname)
|
||||||
return
|
return
|
||||||
if remote_service.state == "down" and local_service.started:
|
hypervisor_state = self._get_hypervisor_state_by_hostname(hostname)
|
||||||
LOG.debug("Stopping remote service %s" % local_service.host)
|
if (remote_service.state == "down" or hypervisor_state != "operating")\
|
||||||
|
and local_service.started:
|
||||||
|
LOG.info("Stopping remote service %s, as hypervisor state is %s,"
|
||||||
|
"service state is %s." % (local_service.host,
|
||||||
|
hypervisor_state,
|
||||||
|
remote_service.state))
|
||||||
local_service.stop()
|
local_service.stop()
|
||||||
return
|
return
|
||||||
if remote_service.state == "up" and not local_service.started:
|
if (remote_service.state == "up" and hypervisor_state == "operating")\
|
||||||
|
and not local_service.started:
|
||||||
LOG.debug("Starting remote service %s" % local_service.host)
|
LOG.debug("Starting remote service %s" % local_service.host)
|
||||||
|
LOG.info("Starting remote service %s, as hypervisor state is %s,"
|
||||||
|
"service state is %s." % (local_service.host,
|
||||||
|
hypervisor_state,
|
||||||
|
remote_service.state))
|
||||||
local_service.start()
|
local_service.start()
|
||||||
|
|
||||||
def _stop_local_services(self):
|
def _stop_local_services(self):
|
||||||
|
@ -238,3 +249,10 @@ class ComputeServiceManager(object):
|
||||||
filtered_services.append(remote_service)
|
filtered_services.append(remote_service)
|
||||||
|
|
||||||
return filtered_services
|
return filtered_services
|
||||||
|
|
||||||
|
def _get_hypervisor_state_by_hostname(self, hostname):
|
||||||
|
hypervisor_state = self.driver._service._client.\
|
||||||
|
hypervisors.get_hypervisor_state(hostname)
|
||||||
|
LOG.info("Get hypervisor state of '%s' is : '%s'." %
|
||||||
|
(hostname, hypervisor_state))
|
||||||
|
return hypervisor_state
|
||||||
|
|
Loading…
Reference in New Issue