~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
svc/conntrack.in: Maintain config groups in a dictionary.
[tripe]
/
svc
/
conntrack.in
diff --git
a/svc/conntrack.in
b/svc/conntrack.in
index
83b2993
..
b840fc2
100644
(file)
--- a/
svc/conntrack.in
+++ b/
svc/conntrack.in
@@
-207,7
+207,7
@@
class Config (object):
testaddr = TESTADDR
## Scan the configuration file and build the groups structure.
testaddr = TESTADDR
## Scan the configuration file and build the groups structure.
- groups =
[]
+ groups =
{}
for sec in cp.sections():
pats = []
for tag in cp.options(sec):
for sec in cp.sections():
pats = []
for tag in cp.options(sec):
@@
-234,7
+234,7
@@
class Config (object):
(p and not pp) or \
(p == pp and n.withinp(nn)),
pats))
(p and not pp) or \
(p == pp and n.withinp(nn)),
pats))
- groups
.append((sec, pats))
+ groups
[sec] = pats
## Done.
me.testaddr = testaddr
## Done.
me.testaddr = testaddr
@@
-246,15
+246,11
@@
CF = None
def cmd_showconfig():
T.svcinfo('test-addr=%s' % CF.testaddr)
def cmd_showgroups():
def cmd_showconfig():
T.svcinfo('test-addr=%s' % CF.testaddr)
def cmd_showgroups():
- for
sec, pats in CF.groups
:
- T.svcinfo(
sec
)
+ for
g in sorted(CF.groups.iterkeys())
:
+ T.svcinfo(
g
)
def cmd_showgroup(g):
def cmd_showgroup(g):
- for s, p in CF.groups:
- if s == g:
- pats = p
- break
- else:
- raise T.TripeJobError('unknown-group', g)
+ try: pats = CF.groups[g]
+ except KeyError: raise T.TripeJobError('unknown-group', g)
for t, p, n in pats:
T.svcinfo('peer', t,
'target', p and str(p) or '(default)',
for t, p, n in pats:
T.svcinfo('peer', t,
'target', p and str(p) or '(default)',
@@
-340,7
+336,7
@@
def kickpeers():
## Now decide what to do.
changes = []
## Now decide what to do.
changes = []
- for g, pp in CF.groups:
+ for g, pp in CF.groups
.iteritems()
:
if T._debug: print '# check group %s' % g
## Find out which peer in the group ought to be active.
if T._debug: print '# check group %s' % g
## Find out which peer in the group ought to be active.