Skip to content

Commit

Permalink
fix(hsdo): iterate on list using items()
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian VAN DER ZWAARD committed May 30, 2023
1 parent 735e3ed commit bf38b18
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/client/haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def backendConfReady(self, stat):
values = backend.split(",")
## Example backend line
## http_back,mywebapp2,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,10,1,0,0,1,330587,0,,1,4,2,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,,,0,0,0,0,,,,Layer4 check passed,,2,3,4,,,,10.14.34.198:80,,http,,,,,,,,0,0,0,,,0,,0,0,0,0,
for backend in backendList:
if len(values) > 80 and values[0] == backend and values[1].startswith(backendList[backend]["baseName"]):
for k,v in self.backendList.items():
if values[0] == k and values[1].startswith(v["baseName"]):
existingBackends += 1
elif self.azLimiter == "true" and len(values) > 80 and values[0] == self.fallbackBackendName and values[1].startswith(self.fallbackBackendBaseName):
fallbackBackendExists = True
if self.azLimiter == "true" and len(values) > 80 and values[0] == self.fallbackBackendName and values[1].startswith(self.fallbackBackendBaseName):
fallbackBackendExists = True
if existingBackends == len(self.backendList):
backendsExist = True

Expand All @@ -86,17 +86,16 @@ def setServer(self, server):
self.sendHaproxyCommand(command)

def prepareServer(self, server):
commands = []
# If --az-limiter option is used
if server.ASG not in self.ASG and self.azLimiter == "true":
commands.extend(self.__addServerInBackend(server, self.fallbackBackendName, self.fallbackBackendBaseName, self.backendServerPort))
else:
for backend in self.backendList:
commands.extend(self.__addServerInBackend(server, backend, self.backendList[backend]["baseName"], self.backendList[backend]["serverPort"]))
if self.optAllServersInFallback == "true":
commands.extend(self.__addServerInBackend(server, self.fallbackBackendName, self.fallbackBackendBaseName))
## If server is disabled
return commands
return self.__addServerInBackend(server, self.fallbackBackendName, self.fallbackBackendBaseName, self.backendServerPort)
# Read backend list
commands = []
for k,v in self.backendList.items():
commands.extend(self.__addServerInBackend(server, k, v["baseName"], v["serverPort"]))
if self.optAllServersInFallback == "true":
commands.extend(self.__addServerInBackend(server, self.fallbackBackendName, self.fallbackBackendBaseName, self.backendServerPort))
return commands

def __addServerInBackend(self, server, bckndName, bckndbsName, bckndServerPort):
commands = []
Expand Down

0 comments on commit bf38b18

Please sign in to comment.