def __initializeTables(self):
        '''Read the topology from ZIMon and (re-)construct
        the tables for metrics, keys, key elements (tag keys)
        and key values (tag values)'''

        self.__qh = QueryHandler(self.server, self.port, self.logger,
                                 self.apiKeyName, self.apiKeyValue)
        self.__sensorsConf = SensorConfig.readSensorsConfigFromMMSDRFS(
            self.logger)
        tstart = timer()
        self.__metaData = Topo(self.qh.getTopology())
        tend = timer()
        if not (self.metaData and self.metaData.topo):
            raise ValueError(MSG['NoData'])
        foundItems = len(self.metaData.allParents) - 1
        sensors = self.metaData.sensorsSpec.keys()
        self.logger.info(MSG['MetaSuccess'])
        self.logger.details(MSG['ReceivAttrValues'].format(
            'parents totally', foundItems))
        self.logger.debug(MSG['ReceivAttrValues'].format(
            'parents', ", ".join(self.metaData.allParents)))
        self.logger.info(MSG['ReceivAttrValues'].format(
            'sensors', ", ".join(sensors)))
        self.logger.details(MSG['TimerInfo'].format('Metadata',
                                                    str(tend - tstart)))
Example #2
0
    def __initializeTables(self):
        '''Read the topology from ZIMon and (re-)construct
        the tables for metrics, keys, key elements (tag keys)
        and key values (tag values)'''

        self.__qh = QueryHandler(self.server, self.port, self.logger, self.apiKeyName, self.apiKeyValue)
        self.__sensorsConf = SensorConfig.readSensorsConfigFromMMSDRFS(self.logger)
        MAX_ATTEMPTS_COUNT = 3
        for attempt in range(1, MAX_ATTEMPTS_COUNT + 1):
            tstart = timer()
            self.__metaData = Topo(self.qh.getTopology())
            tend = timer()
            if not (self.metaData and self.metaData.topo):
                if attempt > MAX_ATTEMPTS_COUNT:
                    break
                # if no data returned because of the REST HTTP server is still starting, sleep and retry (max 3 times)
                self.logger.warning(MSG['NoDataStartNextAttempt'].format(attempt, MAX_ATTEMPTS_COUNT))
                sleep(self.sleepTime)
            else:
                foundItems = len(self.metaData.allParents) - 1
                sensors = self.metaData.sensorsSpec.keys()
                self.logger.info(MSG['MetaSuccess'])
                self.logger.details(MSG['ReceivAttrValues'].format('parents totally', foundItems))
                self.logger.debug(MSG['ReceivAttrValues'].format('parents', ", ".join(self.metaData.allParents)))
                self.logger.info(MSG['ReceivAttrValues'].format('sensors', ", ".join(sensors)))
                self.logger.details(MSG['TimerInfo'].format('Metadata', str(tend - tstart)))
                return
        raise ValueError(MSG['NoData'])
 def qh(self):
     if not self.__qh:
         self.__qh = QueryHandler(self.server, self.port, self.logger,
                                  self.apiKeyName, self.apiKeyValue)
     return self.__qh
Example #4
0
 def qh(self):
     if not self.__qh:
         self.__qh = QueryHandler(self.server, self.port, self.logger)
     return self.__qh