def __init__(self, momconf): if not _momAvailable: raise MomNotAvailableError() self.log = logging.getLogger("MOM") self.log.info("Starting up MOM") self._mom = mom.MOM(momconf) threading.Thread.__init__(self, target=self._mom.run, name="MOM") self.start()
def __init__(self, momconf, conf_overrides=None): if not _momAvailable: raise MomNotAvailableError() self.log = logging.getLogger("MOM") self.log.info("Preparing MOM interface") # MOM instance is needed to load the config file and get the RPC port _mom = mom.MOM(momconf, conf_overrides) port = _mom.config.get('main', 'rpc-port') if port == "-1": self.log.error("MOM's RPC interface is disabled") raise MomNotAvailableError() self.log.info("Using named unix socket " + port) self._mom = unixrpc.UnixXmlRpcClient(port) self._policy = {}
def start_mom(config=None): if not config: config = ConfigParser.SafeConfigParser() config.add_section('logging') config.set('logging', 'verbosity', 'error') mom_instance = mom.MOM("", config) t = threading.Thread(target=mom_instance.run) t.setDaemon(True) t.start() while True: if not t.isAlive(): return None try: mom_instance.setVerbosity('critical') break except AttributeError: time.sleep(1) return mom_instance