Beispiel #1
0
    def get_cache(self, path, params, request_type):
        # TODO quick and dirty way to take query parameters
        # into account when caching data
        if params:
            index = "%s.%s.%s" % (path,
                                  json.dumps(params.dict_of_lists(),
                                             sort_keys=True), request_type)
        else:
            index = "%s.%s" % (path, request_type)
        result = self.cache.get(index)
        if result:
            return result

        zk = self.nodepool.getZK()

        if path == '/image-list':
            results = status.image_list(zk)
        elif path == '/dib-image-list':
            results = status.dib_image_list(zk)
        elif path == '/node-list':
            results = status.node_list(zk, node_id=params.get('node_id'))
        elif path == '/request-list':
            results = status.request_list(zk)
        elif path == '/label-list':
            results = status.label_list(zk)
        else:
            return None

        fields = None
        if params.get('fields'):
            fields = params.get('fields').split(',')

        output = status.output(results, request_type, fields)
        return self.cache.put(index, output)
Beispiel #2
0
 def get_cache(self, path, params):
     # TODO quick and dirty way to take query parameters
     # into account when caching data
     if params:
         index = path + json.dumps(params.dict_of_lists(), sort_keys=True)
     else:
         index = path
     result = self.cache.get(index)
     if result:
         return result
     if path == '/image-list':
         output = status.image_list(self.nodepool.getZK(), format='pretty')
     elif path == '/image-list.json':
         output = status.image_list(self.nodepool.getZK(), format='json')
     elif path == '/dib-image-list':
         output = status.dib_image_list(self.nodepool.getZK(),
                                        format='pretty')
     elif path == '/dib-image-list.json':
         output = status.dib_image_list(self.nodepool.getZK(),
                                        format='json')
     elif path == '/node-list':
         output = status.node_list(self.nodepool.getZK(),
                                   format='pretty',
                                   node_id=params.get('node_id'))
     elif path == '/node-list.json':
         output = status.node_list(self.nodepool.getZK(),
                                   format='json',
                                   node_id=params.get('node_id'))
     elif path == '/label-list':
         output = status.label_list(self.nodepool.getZK(), format='pretty')
     elif path == '/label-list.json':
         output = status.label_list(self.nodepool.getZK(), format='json')
     elif path == '/request-list':
         output = status.request_list(self.nodepool.getZK(),
                                      format='pretty')
     elif path == '/request-list.json':
         output = status.request_list(self.nodepool.getZK(), format='json')
     else:
         return None
     return self.cache.put(index, output)
Beispiel #3
0
 def get_cache(self, path):
     result = self.cache.get(path)
     if result:
         return result
     if path == '/image-list':
         output = status.image_list(self.nodepool.getZK())
     elif path == '/dib-image-list':
         output = status.dib_image_list(self.nodepool.getZK())
     elif path == '/dib-image-list.json':
         output = status.dib_image_list_json(self.nodepool.getZK())
     elif path == '/node-list':
         output = status.node_list(self.nodepool.getZK())
     elif path == '/node-list.json':
         output = status.node_list_json(self.nodepool.getZK())
     else:
         return None
     return self.cache.put(path, output)
Beispiel #4
0
    def get_cache(self, path, params, request_type):
        # TODO quick and dirty way to take query parameters
        # into account when caching data
        if params:
            index = "%s.%s.%s" % (path,
                                  json.dumps(params.dict_of_lists(),
                                             sort_keys=True),
                                  request_type)
        else:
            index = "%s.%s" % (path, request_type)
        result = self.cache.get(index)
        if result:
            return result

        zk = self.nodepool.getZK()

        if path == '/image-list':
            results = status.image_list(zk)
        elif path == '/dib-image-list':
            results = status.dib_image_list(zk)
        elif path == '/node-list':
            results = status.node_list(zk,
                                       node_id=params.get('node_id'))
        elif path == '/request-list':
            results = status.request_list(zk)
        elif path == '/label-list':
            results = status.label_list(zk)
        else:
            return None

        fields = None
        if params.get('fields'):
            fields = params.get('fields').split(',')

        output = status.output(results, request_type, fields)
        return self.cache.put(index, output)
Beispiel #5
0
 def image_list(self):
     results = status.image_list(self.zk)
     print(status.output(results, 'pretty'))
Beispiel #6
0
 def image_list(self):
     print status.image_list(self.pool.getDB())
Beispiel #7
0
 def image_list(self):
     print status.image_list(self.zk)
 def image_list(self):
     results = status.image_list(self.zk)
     print(status.output(results, 'pretty'))