- def __init__(self, name, alias, status, webname):
+ def __init__(self, name, alias, status, webname, vhost):
- def parse_hosts(cls, payload):
- parsed = [cls.parse(p) for p in json.loads(payload)]
+ def parse_hosts(cls, payload, vhost):
+ parsed = filter(lambda x: x.vhost == vhost, [cls.parse(p) for p in json.loads(payload)])
- return cls(payload[0], payload[1], HOST_STATUS[payload[2]], payload[3].get("WEBSTATUS_NAME"))
+ return cls(payload[0], payload[1], HOST_STATUS[payload[2]], payload[3].get("WEBSTATUS_NAME"), payload[3].get("WEBSTATUS_VHOST"))
answer = get_lq("""GET hosts
Filter: groups >= webstatus-hosts
Columns: name alias state custom_variables
OutputFormat: json
""")
answer = get_lq("""GET hosts
Filter: groups >= webstatus-hosts
Columns: name alias state custom_variables
OutputFormat: json
""")
def fill_services(self, services):
self.services = [service for service in services if service.host == self.name]
def fill_services(self, services):
self.services = [service for service in services if service.host == self.name]
- def fill_services(self, services):
- self.services = [service for service in services if any([group == self.name for group in service.groups])]
+ def fill_services(self, services, hosts):
+ self.services = [service for service in services if any([group == self.name for group in service.groups]) and service.host in hosts]
servicegroups = ServiceGroup.query()
services = Service.query()
for host in hosts:
hosts[host].fill_services(services)
for group in servicegroups:
servicegroups = ServiceGroup.query()
services = Service.query()
for host in hosts:
hosts[host].fill_services(services)
for group in servicegroups:
return (hosts, servicegroups, services)
TEMPLATE='''<?xml version="1.0" encoding="UTF-8"?>
return (hosts, servicegroups, services)
TEMPLATE='''<?xml version="1.0" encoding="UTF-8"?>
resp = make_response(render_template_string(TEMPLATE, hosts=hosts, servicegroups=servicegroups))
resp.content_type = "text/html"
return resp
resp = make_response(render_template_string(TEMPLATE, hosts=hosts, servicegroups=servicegroups))
resp.content_type = "text/html"
return resp