def __init__(self, app, **conf): self.notifier = notify.Notifier( messaging.get_transport(cfg.CONF, conf.get('url')), publisher_id=conf.get('publisher_id', os.path.basename(sys.argv[0]))) self.service_name = conf.get('service_name') self.ignore_req_list = [x.upper().strip() for x in conf.get('ignore_req_list', '').split(',')] super(RequestNotifier, self).__init__(app)
def notifier(_id, transport, messages, wait_after_msg, timeout): n1 = notify.Notifier( transport, topic="n-t1").prepare(publisher_id='publisher-%d' % _id) msg = 0 for i in range(0, messages): msg = 1 + msg ctxt = {} payload = dict(msg=msg, vm='test', otherdata='ahah') LOG.info("send msg") LOG.info(payload) n1.info(ctxt, 'compute.start1', payload) if wait_after_msg > 0: time.sleep(wait_after_msg)
def get_notifier(): global __NOTIFIER if not __NOTIFIER: service = cfg.CONF.notification_service host = cfg.CONF.default_publisher_id or socket.gethostname() publisher_id = '{}.{}'.format(service, host) __NOTIFIER = notify.Notifier(transport.get_transport(cfg.CONF), publisher_id, serializer=RequestContextSerializer( JsonPayloadSerializer())) return __NOTIFIER