r14219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14218‎ | r14219 | r14220 >
Date:16:30, 14 May 2006
Author:mark
Status:old
Tags:
Comment:
Support multiple LVS service instances. Change the config file format to INI file format to support this
Fix a bug where reenabled servers were not readded to monitoring
Modified paths:
  • /trunk/pybal/ipvs.py (modified) (history)
  • /trunk/pybal/pybal.py (modified) (history)

Diff [purge]

Index: trunk/pybal/ipvs.py
@@ -134,9 +134,10 @@
135135 SVC_PROTOS = ('tcp', 'udp')
136136 SVC_SCHEDULERS = ('rr', 'wrr', 'lc', 'wlc', 'lblc', 'lblcr', 'dh', 'sh', 'sed', 'nq')
137137
138 - def __init__(self, (protocol, ip, port, scheduler), servers={}):
 138+ def __init__(self, name, (protocol, ip, port, scheduler), servers={}):
139139 """Constructor"""
140140
 141+ self.name = name
141142 self.servers = servers
142143
143144 if (protocol not in self.SVC_PROTOS
Index: trunk/pybal/pybal.py
@@ -86,17 +86,18 @@
8787 for a single LVS instance
8888 """
8989
90 - serverConfigURL = 'file:///etc/pybal/squids' # FIXME
 90+ serverConfigURL = 'file:///etc/pybal/squids'
9191
9292 intvLoadServers = 60
9393
94 - def __init__(self, lvsservice):
 94+ def __init__(self, lvsservice, configURL):
9595 """Constructor"""
9696
9797 self.lvsservice = lvsservice
9898 self.servers = {}
9999 self.pooledDownServers = []
100100 self.configHash = None
 101+ self.serverConfigURL = configURL
101102
102103 # Start a periodic server list update task
103104 from twisted.internet import task
@@ -265,7 +266,7 @@
266267 if not newServer.enabled and server.enabled:
267268 server.removeMonitors()
268269 elif newServer.enabled and not server.enabled:
269 - setupMonitoring.append(server)
 270+ setupMonitoring.append(newServer)
270271
271272 server.merge(newServer)
272273 else:
@@ -285,16 +286,29 @@
286287
287288 def main():
288289 from twisted.internet import reactor
 290+ from ConfigParser import SafeConfigParser
289291
290292 # Read the configuration file
291293 configFile = '/etc/pybal/pybal.conf'
292 - cfgvars = {}
293 - execfile(configFile, globals(), cfgvars)
294294
295 - lvsservice = ipvs.LVSService(
296 - (cfgvars['protocol'], cfgvars['ip'], cfgvars['port'], cfgvars['scheduler']))
297 - crd = Coordinator(lvsservice)
 295+ config = SafeConfigParser()
 296+ config.read(configFile)
298297
 298+ services = {}
 299+
 300+ for section in config.sections():
 301+ cfgtuple = (
 302+ config.get(section, 'protocol'),
 303+ config.get(section, 'ip'),
 304+ config.getint(section, 'port'),
 305+ config.get(section, 'scheduler'))
 306+ print cfgtuple
 307+
 308+ services[section] = ipvs.LVSService(section, cfgtuple)
 309+ crd = Coordinator(services[section],
 310+ configURL=config.get(section, 'config'))
 311+ print "Created LVS service '%s'" % section
 312+
299313 reactor.run()
300314
301315 if __name__ == '__main__':

Status & tagging log