Index: trunk/pybal/ipvs.py |
— | — | @@ -134,9 +134,10 @@ |
135 | 135 | SVC_PROTOS = ('tcp', 'udp') |
136 | 136 | SVC_SCHEDULERS = ('rr', 'wrr', 'lc', 'wlc', 'lblc', 'lblcr', 'dh', 'sh', 'sed', 'nq') |
137 | 137 | |
138 | | - def __init__(self, (protocol, ip, port, scheduler), servers={}): |
| 138 | + def __init__(self, name, (protocol, ip, port, scheduler), servers={}): |
139 | 139 | """Constructor""" |
140 | 140 | |
| 141 | + self.name = name |
141 | 142 | self.servers = servers |
142 | 143 | |
143 | 144 | if (protocol not in self.SVC_PROTOS |
Index: trunk/pybal/pybal.py |
— | — | @@ -86,17 +86,18 @@ |
87 | 87 | for a single LVS instance |
88 | 88 | """ |
89 | 89 | |
90 | | - serverConfigURL = 'file:///etc/pybal/squids' # FIXME |
| 90 | + serverConfigURL = 'file:///etc/pybal/squids' |
91 | 91 | |
92 | 92 | intvLoadServers = 60 |
93 | 93 | |
94 | | - def __init__(self, lvsservice): |
| 94 | + def __init__(self, lvsservice, configURL): |
95 | 95 | """Constructor""" |
96 | 96 | |
97 | 97 | self.lvsservice = lvsservice |
98 | 98 | self.servers = {} |
99 | 99 | self.pooledDownServers = [] |
100 | 100 | self.configHash = None |
| 101 | + self.serverConfigURL = configURL |
101 | 102 | |
102 | 103 | # Start a periodic server list update task |
103 | 104 | from twisted.internet import task |
— | — | @@ -265,7 +266,7 @@ |
266 | 267 | if not newServer.enabled and server.enabled: |
267 | 268 | server.removeMonitors() |
268 | 269 | elif newServer.enabled and not server.enabled: |
269 | | - setupMonitoring.append(server) |
| 270 | + setupMonitoring.append(newServer) |
270 | 271 | |
271 | 272 | server.merge(newServer) |
272 | 273 | else: |
— | — | @@ -285,16 +286,29 @@ |
286 | 287 | |
287 | 288 | def main(): |
288 | 289 | from twisted.internet import reactor |
| 290 | + from ConfigParser import SafeConfigParser |
289 | 291 | |
290 | 292 | # Read the configuration file |
291 | 293 | configFile = '/etc/pybal/pybal.conf' |
292 | | - cfgvars = {} |
293 | | - execfile(configFile, globals(), cfgvars) |
294 | 294 | |
295 | | - lvsservice = ipvs.LVSService( |
296 | | - (cfgvars['protocol'], cfgvars['ip'], cfgvars['port'], cfgvars['scheduler'])) |
297 | | - crd = Coordinator(lvsservice) |
| 295 | + config = SafeConfigParser() |
| 296 | + config.read(configFile) |
298 | 297 | |
| 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 | + |
299 | 313 | reactor.run() |
300 | 314 | |
301 | 315 | if __name__ == '__main__': |