Get 'weight' value from API server message.

Now that the worker supports server weighting, we should,
you know, actually use it if it is given in the request.

Change-Id: I7b0af9b8fc57ff17e5457b81290a474821b0d932
This commit is contained in:
David Shrewsbury 2013-02-06 11:21:01 -05:00
parent 53fedfca2a
commit 18c0c6bf6d
2 changed files with 8 additions and 2 deletions

View File

@ -163,7 +163,7 @@ class LBaaSController(object):
return self.msg return self.msg
for lb_node in current_lb['nodes']: for lb_node in current_lb['nodes']:
port, address = None, None port, address, weight = None, None, None
if 'port' in lb_node: if 'port' in lb_node:
port = lb_node['port'] port = lb_node['port']
@ -175,10 +175,14 @@ class LBaaSController(object):
else: else:
return BadRequest("Missing 'address' element.").to_json() return BadRequest("Missing 'address' element.").to_json()
if 'weight' in lb_node:
weight = lb_node['weight']
try: try:
self.driver.add_server(current_lb['protocol'], self.driver.add_server(current_lb['protocol'],
address, address,
port) port,
weight)
except NotImplementedError: except NotImplementedError:
self.logger.error( self.logger.error(
"Selected driver does not support adding a server." "Selected driver does not support adding a server."

View File

@ -125,6 +125,8 @@ class HAProxyDriver(LoadBalancerDriver):
def add_server(self, protocol, host, port, weight=1): def add_server(self, protocol, host, port, weight=1):
proto = protocol.lower() proto = protocol.lower()
if weight is None:
weight = 1
try: try:
weight = int(weight) weight = int(weight)