137
138
klass, hdict[host], host, what)
138
139
content += template.serviceClose
139
140
content += self.getFooter(resultMessage)
142
143
class RunningConfig(BasePage):
147
def getPage(self, request):
151
request.setHeader('Content-type', 'text/plain')
153
conf = self.parent.director.conf
154
doc = minidom.Document()
155
top = doc.createElement("pdconfig")
157
for service in conf.getServices():
158
top.appendChild(doc.createTextNode("\n "))
159
serv = doc.createElement("service")
160
serv.setAttribute('name', service.name)
161
top.appendChild(serv)
162
for l in service.listen:
163
serv.appendChild(doc.createTextNode("\n "))
164
lobj = doc.createElement("listen")
165
lobj.setAttribute('ip', l)
166
serv.appendChild(lobj)
167
groups = service.getGroups()
169
serv.appendChild(doc.createTextNode("\n "))
170
sch = self.parent.director.getScheduler(service.name, group.name)
171
xg = doc.createElement("group")
172
xg.setAttribute('name', group.name)
173
xg.setAttribute('scheduler', sch.schedulerName)
175
stats = sch.getStats(verbose=verbose)
176
hosts = group.getHosts()
177
hdict = sch.getHostNames()
178
counts = stats['open']
179
ahosts = counts.keys() # ahosts is now a list of active hosts
180
# now add disabled hosts.
181
for k in stats['bad'].keys():
182
ahosts.append('%s:%s'%k)
185
xg.appendChild(doc.createTextNode("\n "))
186
xh = doc.createElement("host")
187
xh.setAttribute('name', hdict[h])
188
xh.setAttribute('ip', h)
190
xg.appendChild(doc.createTextNode("\n "))
191
serv.appendChild(doc.createTextNode("\n "))
192
eg = service.getEnabledGroup()
193
xeg = doc.createElement("enable")
194
xeg.setAttribute("group", eg.name)
195
serv.appendChild(xeg)
196
serv.appendChild(doc.createTextNode("\n "))
197
top.appendChild(doc.createTextNode("\n "))
198
# now the admin block
199
admin = self.parent.director.conf.admin
200
if admin is not None:
201
xa = doc.createElement("admin")
202
xa.setAttribute("listen", "%s:%s"%admin.listen)
204
for user in admin.getUsers():
205
xa.appendChild(doc.createTextNode("\n "))
206
xu = doc.createElement("user")
207
xu.setAttribute("name", user.name)
208
xu.setAttribute("password", user.password)
209
xu.setAttribute("access", user.access)
211
xa.appendChild(doc.createTextNode("\n "))
212
top.appendChild(doc.createTextNode("\n "))
213
# finally, the logging section (if set)
214
#if logger.logfile is not None:
215
# xl = doc.createElement("logging")
216
# xl.setAttribute("file", logger.logfile)
217
# top.appendChild(xl)
219
top.appendChild(doc.createTextNode("\n"))
220
# and spit out the XML
147
223
class StoredConfig(BasePage):