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:
David Shrewsbury
2012-10-29 15:10:36 -04:00
parent 5f23c3f60b
commit 22b53f22c8
5 changed files with 21 additions and 30 deletions

View File

@@ -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:

View File

@@ -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()

View File

@@ -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()

View File

@@ -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)

View File

@@ -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):