예제 #1
0
 def get_config(self, key):
     """ Try to get the config over the MQ. If value is None, get the default value
     """
     if self._client_config == None:
         self._client_config = Query(self.zmq, self.log)
     value = self._client_config.query(self._type, self._name, key)
     if value == None or value == 'None':
         self.log.info(u"Value for '{0}' is None or 'None' : trying to get the default value instead...".format(key))
         value = self.get_config_default_value(key)
     self.log.info(u"Value for '{0}' is : {1}".format(key, value))
     return self.cast_config_value(key, value)
예제 #2
0
 def check_configured(self):
     """ For a client only
         To be call in the client __init__()
         Check in database (over queryconfig) if the key 'configured' is set to True for the client
         if not, stop the client and log this
     """
     self._client_config = Query(self.zmq, self.log)
     configured = self._client_config.query(self._type, self._name, 'configured')
     if configured == '1':
         configured = True
     if configured != True:
         self.log.error(u"The client is not configured (configured = '{0}'. Stopping the client...".format(configured))
         self.force_leave(status = STATUS_NOT_CONFIGURED)
         return False
     self.log.info(u"The client is configured. Continuing (hoping that the user applied the appropriate configuration ;)")
     return True