From d4197b44015f046e4624e3df965e1927b4966c31 Mon Sep 17 00:00:00 2001 From: Darius Stefan Date: Wed, 20 Nov 2024 13:37:46 +0200 Subject: [PATCH] Fix b2b_trigger_scenario array params --- b2b/02.marketing/scenario.yml | 2 +- b2b/02.marketing/scripts/place_call.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 b2b/02.marketing/scripts/place_call.py diff --git a/b2b/02.marketing/scenario.yml b/b2b/02.marketing/scenario.yml index 7cfc677..dbab908 100644 --- a/b2b/02.marketing/scenario.yml +++ b/b2b/02.marketing/scenario.yml @@ -29,8 +29,8 @@ tasks: - name: Place Call type: opensips-mi + script: scripts/place_call.py args: - - b2b_trigger_scenario - marketing - customer,sip:customer@{{ caller_ip }}:{{ caller_port }} - media,sip:announcement@{{ media_ip }}:{{ media_port }} diff --git a/b2b/02.marketing/scripts/place_call.py b/b2b/02.marketing/scripts/place_call.py new file mode 100644 index 0000000..1b845c6 --- /dev/null +++ b/b2b/02.marketing/scripts/place_call.py @@ -0,0 +1,24 @@ +from opensips.mi import OpenSIPSMI, OpenSIPSMIException +import sys +import os + +mi_type = os.getenv('MI_TYPE', 'http') +mi_ip = os.getenv('MI_IP', '127.0.0.1') +mi_port = os.getenv('MI_PORT', '8888') + +if mi_type == 'http': + handler = OpenSIPSMI(conn='http', url='http://{}:{}/mi'.format(mi_ip, mi_port)) +elif mi_type == 'datagram': + handler = OpenSIPSMI(conn='datagram', datagram_ip=mi_ip, datagram_port=mi_port) +else: + sys.exit(1) + +if len(sys.argv) < 5: + sys.exit(1) + +try: + handler.execute("b2b_trigger_scenario", + [sys.argv[1], sys.argv[2], sys.argv[3], [sys.argv[4]]]) +except OpenSIPSMIException as e: + print(e) + sys.exit(1)