1
2
3
4
5
6
7
8
9
10 from Products import Zuul
11 from Products.Zuul.routers import TreeRouter
12 from Products.ZenUtils.Ext import DirectResponse
13
14
16 """
17 A JSON/ExtDirect interface to retrieve model data from Solr
18 """
19
21 self.context = context
22 self.request = request
23 self.api = Zuul.getFacade('modelquery')
24 super(ModelQueryRouter, self).__init__(context, request)
25
26
29
30
31 - def getDevices(self, limit=200, params=None, fields=None):
32 """
33 Retrieves a list of devices.
34 @type limit: integer
35 @param limit: (optional) Number of items to return
36
37 @type params: dictionary
38 @param params: (optional) Key-value pair of filters for this search
39 e.g. params={'name': 'localhost'}
40
41 @type fields: list of strings
42 @param fields: (optional) list of indexed fields to retrieve, if None
43 then attempts to retrive values for all indexes we have in SOLR.
44 e.g. fields=["name", "osModel", "productionState"]
45 """
46
47 devices, totalCount = self.api.getDevices(limit=limit, params=params, fields=fields)
48 return DirectResponse(devices=devices, totalCount=totalCount)
49
50
52
53 """
54 Return list of dicts where each dict represents
55 list of indexes for a particular object
56 """
57
58 indexes = self.api.getIndexInfo()
59 return DirectResponse(indexes=indexes)
60