Pass HAProxy config to OS services driver.
Bug fix. We weren't passing the HAProxy config as a string down to the OS service module. Also remove the service_restart() method since it was unused. Also set a default balancing algorithm. Change-Id: I8db025488099fed5015d62e0bf9c73c6e6795483
This commit is contained in:
@@ -125,6 +125,8 @@ class LBaaSController(object):
|
||||
self.logger.error("Invalid algorithm: %s" % algo)
|
||||
self.msg[self.RESPONSE_FIELD] = self.RESPONSE_FAILURE
|
||||
return self.msg
|
||||
else:
|
||||
algo = LoadBalancerDriver.ROUNDROBIN
|
||||
|
||||
try:
|
||||
self.driver.set_algorithm(current_lb['protocol'], algo)
|
||||
@@ -183,7 +185,7 @@ class LBaaSController(object):
|
||||
self.msg[self.RESPONSE_FIELD] = self.RESPONSE_FAILURE
|
||||
except Exception as e:
|
||||
self.logger.error("CREATE failed: %s, %s" % (e.__class__, e))
|
||||
for lb_node in self.msg['nodes']:
|
||||
for lb_node in current_lb['nodes']:
|
||||
lb_node['condition'] = self.NODE_ERR
|
||||
self.msg[self.RESPONSE_FIELD] = self.RESPONSE_FAILURE
|
||||
else:
|
||||
|
||||
@@ -121,7 +121,7 @@ class HAProxyDriver(LoadBalancerDriver):
|
||||
raise Exception('Invalid algorithm: %s' % protocol)
|
||||
|
||||
def create(self):
|
||||
self.ossvc.write_config()
|
||||
self.ossvc.write_config(self._config_to_string())
|
||||
self.ossvc.service_stop()
|
||||
self.ossvc.service_start()
|
||||
|
||||
|
||||
@@ -34,11 +34,7 @@ class ServicesBase:
|
||||
""" Start the HAProxy service. """
|
||||
return NotImplementedError()
|
||||
|
||||
def service_restart(self):
|
||||
""" Restart the HAProxy service. """
|
||||
return NotImplementedError()
|
||||
|
||||
def write_config(self):
|
||||
def write_config(self, config_str):
|
||||
""" Write the HAProxy configuration file. """
|
||||
return NotImplementedError()
|
||||
|
||||
|
||||
@@ -50,10 +50,7 @@ class UbuntuServices(ServicesBase):
|
||||
raise Exception("%s does not exist. Start failed." %
|
||||
self._haproxy_pid)
|
||||
|
||||
def service_restart(self):
|
||||
return NotImplementedError()
|
||||
|
||||
def write_config(self):
|
||||
def write_config(self, config_str):
|
||||
"""
|
||||
Generate the new config and replace the current config file.
|
||||
|
||||
@@ -61,7 +58,6 @@ class UbuntuServices(ServicesBase):
|
||||
the production config file, then rename the temporary config to the
|
||||
production config.
|
||||
"""
|
||||
config_str = self._config_to_string()
|
||||
tmpfile = '/tmp/haproxy.cfg'
|
||||
fh = open(tmpfile, 'w')
|
||||
fh.write(config_str)
|
||||
|
||||
@@ -19,10 +19,7 @@ class FakeOSServices(ServicesBase):
|
||||
def service_start(self):
|
||||
pass
|
||||
|
||||
def service_restart(self):
|
||||
pass
|
||||
|
||||
def write_config(self):
|
||||
def write_config(self, config_str):
|
||||
pass
|
||||
|
||||
def remove_configs(self):
|
||||
|
||||
Reference in New Issue
Block a user