Add support for SUSPEND/ENABLE to HAProxy driver.
SUSPEND just stops HAProxy, and ENABLE starts it. Added code to catch exceptions if either of these actions fail.
This commit is contained in:
parent
754af827f9
commit
983eb4a06b
@ -98,8 +98,7 @@ class LBaaSController(object):
|
|||||||
lb_node['condition'] = self.NODE_ERR
|
lb_node['condition'] = self.NODE_ERR
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error("Failure activating changes: %s, %s" %
|
self.logger.error("CREATE failed: %s, %s" % (e.__class__, e))
|
||||||
(e.__class__, e))
|
|
||||||
for lb_node in self.msg['nodes']:
|
for lb_node in self.msg['nodes']:
|
||||||
lb_node['condition'] = self.NODE_ERR
|
lb_node['condition'] = self.NODE_ERR
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
@ -125,6 +124,9 @@ class LBaaSController(object):
|
|||||||
"Selected driver does not support SUSPEND action."
|
"Selected driver does not support SUSPEND action."
|
||||||
)
|
)
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error("SUSPEND failed: %s, %s" % (e.__class__, e))
|
||||||
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
else:
|
else:
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
||||||
return self.msg
|
return self.msg
|
||||||
@ -138,6 +140,9 @@ class LBaaSController(object):
|
|||||||
"Selected driver does not support ENABLE action."
|
"Selected driver does not support ENABLE action."
|
||||||
)
|
)
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error("ENABLE failed: %s, %s" % (e.__class__, e))
|
||||||
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
else:
|
else:
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
||||||
return self.msg
|
return self.msg
|
||||||
@ -151,6 +156,9 @@ class LBaaSController(object):
|
|||||||
"Selected driver does not support DELETE action."
|
"Selected driver does not support DELETE action."
|
||||||
)
|
)
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error("DELETE failed: %s, %s" % (e.__class__, e))
|
||||||
|
self.msg['hpcs_response'] = self.RESPONSE_FAILURE
|
||||||
else:
|
else:
|
||||||
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
self.msg['hpcs_response'] = self.RESPONSE_SUCCESS
|
||||||
return self.msg
|
return self.msg
|
||||||
|
@ -103,6 +103,24 @@ class HAProxyDriver(LoadBalancerDriver):
|
|||||||
raise Exception("Failed to restart HAProxy service: %s" %
|
raise Exception("Failed to restart HAProxy service: %s" %
|
||||||
e.output.rstrip('\n'))
|
e.output.rstrip('\n'))
|
||||||
|
|
||||||
|
def _stop(self):
|
||||||
|
""" Stop the HAProxy service on the local machine. """
|
||||||
|
cmd = '/usr/bin/sudo /usr/sbin/service haproxy stop'
|
||||||
|
try:
|
||||||
|
subprocess.check_output(cmd.split())
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
raise Exception("Failed to stop HAProxy service: %s" %
|
||||||
|
e.output.rstrip('\n'))
|
||||||
|
|
||||||
|
def _start(self):
|
||||||
|
""" Start the HAProxy service on the local machine. """
|
||||||
|
cmd = '/usr/bin/sudo /usr/sbin/service haproxy start'
|
||||||
|
try:
|
||||||
|
subprocess.check_output(cmd.split())
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
raise Exception("Failed to start HAProxy service: %s" %
|
||||||
|
e.output.rstrip('\n'))
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Driver API Methods
|
# Driver API Methods
|
||||||
####################
|
####################
|
||||||
@ -119,3 +137,9 @@ class HAProxyDriver(LoadBalancerDriver):
|
|||||||
def create(self):
|
def create(self):
|
||||||
self._write_config()
|
self._write_config()
|
||||||
self._restart()
|
self._restart()
|
||||||
|
|
||||||
|
def suspend(self):
|
||||||
|
self._stop()
|
||||||
|
|
||||||
|
def enable(self):
|
||||||
|
self._start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user