def _send(self, template, wait_results, timeout): """Send a message over the MQ interface.""" msg_id = template.get('ID', uuid.uuid4().hex) if wait_results: event = eventlet.event.Event() listener = self._environment['agentListener'] listener().subscribe(msg_id, event) msg = self._prepare_message(template, msg_id) with common.create_rmq_client(self._environment) as client: client.send(message=msg, key=self._queue) if wait_results: try: with eventlet.Timeout(timeout): result = event.wait() except eventlet.Timeout: listener().unsubscribe(msg_id) raise exceptions.TimeoutException( 'The murano-agent did not respond ' 'within {0} seconds'.format(timeout)) if not result: return None if result.get('FormatVersion', '1.0.0').startswith('1.'): return self._process_v1_result(result) else: return self._process_v2_result(result) else: return None
def _send(self, template, wait_results, timeout): """Send a message over the MQ interface.""" msg_id = template.get('ID', uuid.uuid4().hex) if wait_results: event = eventlet.event.Event() listener = self._environment['agentListener'] listener().subscribe(msg_id, event) msg = self._prepare_message(template, msg_id) with common.create_rmq_client() as client: client.send(message=msg, key=self._queue) if wait_results: try: with eventlet.Timeout(timeout): result = event.wait() except eventlet.Timeout: listener().unsubscribe(msg_id) raise exceptions.TimeoutException( 'The murano-agent did not respond ' 'within {0} seconds'.format(timeout)) if not result: return None if result.get('FormatVersion', '1.0.0').startswith('1.'): return self._process_v1_result(result) else: return self._process_v2_result(result) else: return None
def _send(self, template, wait_results): msg_id = template.get('ID', uuid.uuid4().hex) if wait_results: event = eventlet.event.Event() listener = self._environment.agentListener listener.subscribe(msg_id, event) listener.start() msg = messaging.Message() msg.body = template msg.id = msg_id with common.create_rmq_client() as client: client.declare(self._queue, enable_ha=True, ttl=86400000) client.send(message=msg, key=self._queue) if wait_results: result = event.wait() if not result: return None if result.get('FormatVersion', '1.0.0').startswith('1.'): return self._process_v1_result(result) else: return self._process_v2_result(result) else: return None
def _send(self, template, wait_results, timeout, _context): """Send a message over the MQ interface.""" msg_id = template.get("ID", uuid.uuid4().hex) if wait_results: event = eventlet.event.Event() listener = self._environment.agentListener listener.subscribe(msg_id, event, _context) msg = self._prepare_message(template, msg_id) with common.create_rmq_client() as client: client.send(message=msg, key=self._queue) if wait_results: try: with eventlet.Timeout(timeout): result = event.wait() except eventlet.Timeout: listener.unsubscribe(msg_id) raise exceptions.TimeoutException("The Agent does not respond" "within {0} seconds".format(timeout)) if not result: return None if result.get("FormatVersion", "1.0.0").startswith("1."): return self._process_v1_result(result) else: return self._process_v2_result(result) else: return None
def _send(self, template, wait_results): """Send a message over the MQ interface.""" msg_id = template.get('ID', uuid.uuid4().hex) if wait_results: event = eventlet.event.Event() listener = self._environment.agentListener listener.subscribe(msg_id, event) listener.start() msg = messaging.Message() msg.body = template msg.id = msg_id with common.create_rmq_client() as client: client.send(message=msg, key=self._queue) if wait_results: result = event.wait() if not result: return None if result.get('FormatVersion', '1.0.0').startswith('1.'): return self._process_v1_result(result) else: return self._process_v2_result(result) else: return None
def prepare(self): # (sjmc7) - turn this into a no-op if agents are disabled if config.CONF.engine.disable_murano_agent: LOG.debug("Use of murano-agent is disallowed " "by the server configuration") return with common.create_rmq_client() as client: client.declare(self._queue, enable_ha=True, ttl=86400000)
def prepare(self): # (sjmc7) - turn this into a no-op if agents are disabled if config.CONF.engine.disable_murano_agent: LOG.debug("murano-agent is disabled by the server") return with common.create_rmq_client() as client: client.declare(self._queue, enable_ha=True, ttl=86400000)
def prepare(self): # (sjmc7) - turn this into a no-op if agents are disabled if CONF.engine.disable_murano_agent: LOG.debug('Use of murano-agent is disallowed ' 'by the server configuration') return region = dsl.MuranoObjectInterface.create(self._host().getRegion()) with common.create_rmq_client(region) as client: client.declare(self._queue, enable_ha=True, ttl=86400000)
def _receive(self): with common.create_rmq_client() as client: client.declare(self._results_queue, enable_ha=True, ttl=86400000) with client.open(self._results_queue) as subscription: while True: msg = subscription.get_message() if not msg: continue msg.ack() msg_id = msg.body.get('SourceID', msg.id) LOG.debug("Got execution result: id '{0}'" " body '{1}'".format(msg_id, msg.body)) if msg_id in self._subscriptions: event = self._subscriptions.pop(msg_id) event.send(msg.body)