Example #1
0
 def get_one(self, idhost):
     # pylint:disable-msg=C0111,R0201
     host = get_host(idhost)
     baseurl = tg.url("/api/v%s/hosts/%s" % (self.apiver, host.idhost))
     result = {"id": host.idhost,
               "name": host.name,
               "href": baseurl,
               "description": host.description,
               "address": host.address,
               "status": {
                   "name": host.state.name.statename,
                   "message": host.state.message,
                   "datetime": host.state.timestamp.isoformat(),
                   "order": host.state.name.order,
                   },
               "tags": [t.name for t in host.tags],
               }
     result["lls"] = baseurl+"/lls/"
     result["perfdatasources"] = baseurl+"/perfdatasources/"
     result["graphs"] = baseurl+"/graphs/"
     groups = []
     for group in host.groups:
         groups.append({
             "id": group.idgroup,
             "name": group.name,
             "href": tg.url("/api/v%s/supitemgroups/%s"
                            % (self.apiver, group.idgroup)),
             })
     result["groups"] = groups
     return dict(host=result)
Example #2
0
 def get_all(self):
     # pylint:disable-msg=C0111,R0201
     idhost = get_parent_id("hosts")
     if idhost is None:
         raise HTTPNotFound("Can't find the host")
     host = get_host(idhost)
     result = []
     for pds in host.perfdatasources:
         result.append({
             "id": pds.idperfdatasource,
             "name": pds.name,
             "href": tg.url("/api/v%s/hosts/%s/perfdatasources/%s"
                        % (self.apiver, host.idhost, pds.idperfdatasource)),
             })
     return dict(perfdatasources=result)
Example #3
0
 def get_all(self):
     # pylint:disable-msg=C0111,R0201
     idhost = get_parent_id("hosts")
     if idhost is not None:
         host = get_host(idhost)
         services = host.services
     else:
         services = get_all_services(self.model_class)
     result = []
     for service in services:
         result.append({
             "id": service.idservice,
             "type": self.type,
             "href": tg.url("/api/v%s/%s/%s"
                         % (self.apiver, self.type, service.idservice)),
             "name": service.servicename,
             })
     return dict(services=result)
Example #4
0
 def get_all(self):
     # pylint:disable-msg=C0111,R0201
     idhost = get_parent_id("hosts")
     if idhost is not None:
         hosts = [get_host(idhost)]
     else:
         hosts = get_all_hosts()
     result = []
     for host in hosts:
         for graph in host.graphs:
             result.append(
                 {
                     "id": graph.idgraph,
                     "href": tg.url("/api/v%s/graphs/%s" % (self.apiver, graph.idgraph)),
                     "name": graph.name,
                 }
             )
     return dict(graphs=result)