blob: 031e276ad29e15e30ede9fdb42c26e00327d3cff [file] [log] [blame]
Andrea Campanella6d774232018-12-21 12:18:21 +01001#! /usr/bin/env python
2
3import requests
4import sys
5import tapiHelper
6
7from requests.auth import HTTPBasicAuth
8
9if len(sys.argv) < 4:
10 print "usage: execute-tapi-post-call onos-node context empty uuid. Uuid is optional and defaults to empty"
11 sys.exit(1)
12
13node = sys.argv[1]
14context = sys.argv[2]
15empty = sys.argv[3]
16
17if len(sys.argv) == 4:
18 uuid = ""
19else:
20 uuid = sys.argv[4]
21
22if "get-connectivity-service-list" in context:
23 connectivity_request = 'http://' + node + ':8181/onos/restconf/operations/' + context
24 tapi_connection = tapiHelper.get_connection(connectivity_request, uuid)
25 tapi_connection_json = tapi_connection.json()
26 print tapi_connection_json
27 if not tapi_connection_json["tapi-connectivity:output"] and empty != "empty":
28 print "No connection was established"
29 sys.exit(1)
30 #TODO verify empty connection if uuid is empty
31 #TODO verify correct connection if uuid is not empty
32 sys.exit(0)
33
34if "create-connectivity-service" in context:
35 context_request = 'http://' + node + ':8181/onos/restconf/data/tapi-common:context'
36 connectivity_request = 'http://' + node + ':8181/onos/restconf/operations/' + context
37 tapi_connection = tapiHelper.create_connection(context_request, connectivity_request)
38 print context
39 print tapi_connection.json()
40 sys.exit(0)
41
42sys.exit(1)
43
44
45
46