Commit d39a1565 authored by Federico Sismondi's avatar Federico Sismondi

CLI appends amqp connection parameters when not present in env var, added also...

CLI appends amqp connection parameters when not present in env var, added also routing key examples for PacketSniffRaw and PacketInjectRaw
parent 5790bd3f
......@@ -46,7 +46,6 @@ DEFAULT_TOPIC_SUBSCRIPTIONS = [
]
MESSAGE_TYPES_NOT_ECHOED = [
MsgPacketInjectRaw,
]
CONNECTION_SETUP_RETRIES = 3
......@@ -179,12 +178,14 @@ def publish_message(message):
for i in range(1, 4):
try:
state_lock.acquire()
state['channel'].basic_publish(
channel = state['connection'].channel()
channel.basic_publish(
exchange=session_profile['amqp_exchange'],
routing_key=message.routing_key,
properties=pika.BasicProperties(**message.get_properties()),
body=message.to_json(),
)
channel.close()
break
except pika.exceptions.ConnectionClosed as err:
......@@ -1246,16 +1247,19 @@ if __name__ == "__main__":
pass # use default
try:
# url = str(os.environ['AMQP_URL'])
url = '%s?%s&%s&%s&%s&%s' % (
str(os.environ['AMQP_URL']),
"heartbeat_interval=600",
"blocked_connection_timeout=300",
"retry_delay=1",
"socket_timeout=1",
"connection_attempts=3"
)
env_url = str(os.environ['AMQP_URL'])
if 'heartbeat_interval' not in env_url:
url = '%s?%s&%s&%s&%s&%s' % (
env_url,
"heartbeat_interval=600",
"blocked_connection_timeout=300",
"retry_delay=1",
"socket_timeout=1",
"connection_attempts=3"
)
else:
url = env_url
session_profile.update({'amqp_url': url})
except KeyError as e:
pass # use default
......
......@@ -707,7 +707,9 @@ class MsgPacketInjectRaw(Message):
Description: TBD
"""
routing_key = None # depends on the agent_id and the agent interface being used, re-write after creation
# (!) r.key depends on the agent_id and the agent interface being used, re-write after creation
routing_key = 'data.tbd.toAgent.tbd'
_msg_data_template = {
"_type": "packet.to_inject.raw",
......@@ -728,7 +730,9 @@ class MsgPacketSniffedRaw(Message):
Description: TBD
"""
routing_key = None # depends on the agent_id and the agent interface being used, re-write after creation
# (!) r.key depends on the agent_id and the agent interface being used, re-write after creation
routing_key = 'data.tbd.fromAgent.tbd'
_msg_data_template = {
"_type": "packet.sniffed.raw",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment