Exemple #1
0
    def _my_get_data(self, request, context, *args, **kwargs):
        # Add data to the context here...

        instances = api.server_list(self.request)
        for i in instances[0]._attrs:
            has = getattr(instances[0], i, "no")
            print "%s? %s" % (i, has)


        context["data"] = []
        for instance in instances:
            whisper_files = utils.get_whisper_files_list(WHISPER_DBS_PREFIX)

            this_instance_files = [x for x in whisper_files if instance.id in x]

            for f in this_instance_files:
                if "cpu" not in f: continue

                fetched = whisper.fetch(f, time.time() - 10)
                times, data = fetched
                context["data"].append((instance.id, data[-1]))

##        prefix = WHISPER_DBS_PREFIX
##        whisper_files = get_whisper_files_list(prefix, domain_filter=instances[0].id)
##
##        # for each whisper file found, query the last 30 seconds of data from
##        # it and format it it into the context
##        context["data"] = []
##        for f in sorted(whisper_files):
##            key = f.replace(prefix + '/', '')
##            
##            this_context = {}
##            this_context["name"] = key
##            
##            fetched = whisper.fetch(f, time.time() - 30)
##            times, data = fetched
##            
##            if len(set(data)) == 1 and None in set(data):
##                continue
##
##            start, end, step = times
##            values = []
##            for tv, val in zip(xrange(start, end, step), data):
##                if val is None:
##                    val = "n/a"
##                values.append({"time": tv, "value": val})
##
##            this_context["items"] = values
##
##            context["data"].append(this_context)
##
##        print "\n\n\n", context, "\n\n\n"
        return context
Exemple #2
0
 def __init__(self, node_id, domain_id):
     self.files = utils.get_whisper_files_list(WHISPER_DBS_PREFIX, node_id, domain_id)
     self.node_id = node_id
     self.domain_id = domain_id