Created
September 11, 2017 15:03
-
-
Save remyleone/ea9c49d15d604ec8f1cbbff378bee6ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import uuid | |
| import pika | |
| import requests | |
| AMQP_URL = "amqp://guest:guest@localhost/" | |
| AMQP_EXCHANGE = "amq.topic" | |
| AMQP_QUEUE_NAME = "armour_bridge" | |
| # First we create a session using the REST API of the orchestrator | |
| # Reference: http://doc.f-interop.eu/#create-a-new-session | |
| # Support on slack #general @ f-interop.slack.com | |
| session_id = str(uuid.uuid1()) | |
| r = requests.put("http://orchestrator.f-interop.eu/sessions/%s" % session_id, | |
| json={ | |
| "users": [ | |
| "u1", | |
| "f-interop" | |
| ], | |
| "iuts": [], | |
| "testing_tools": "f-interop/6tisch", | |
| "tests": [ | |
| { | |
| "testcase_ref": "http://doc.f-interop.eu/tests/TD_6TiSCH_6P_01_v01", | |
| "settings": {} | |
| } | |
| ] | |
| }) | |
| print(r) | |
| assert r.ok | |
| # Then we connect an AMQP consumer that will send all messages on | |
| # F-interop bus to the ARMOUR MQTT broker | |
| def amqp_callback(ch, method, properties, body): | |
| print("received from AMQP: %s" % body) | |
| ch.basic_ack(delivery_tag=method.delivery_tag) | |
| with pika.BlockingConnection(pika.URLParameters(AMQP_URL)) as connection: | |
| channel = connection.channel() | |
| channel.queue_declare(queue=AMQP_QUEUE_NAME) | |
| channel.queue_bind(queue=AMQP_QUEUE_NAME, | |
| routing_key="*", | |
| exchange=AMQP_EXCHANGE) | |
| channel.basic_consume(amqp_callback, | |
| queue=AMQP_QUEUE_NAME) | |
| print(' [*] Waiting for messages. To exit press CTRL+C') | |
| channel.start_consuming() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment