blob: 95cff90ca1424aa45681dfc9db1fb2f5cf39d9d0 [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) < 3:
10 print "usage: execute-tapi-context-get-call onos-node state"
11 sys.exit(1)
12
13node = sys.argv[1]
14state = sys.argv[2] #if empty tapi context must be empty, if full it needs to contain all devices and ports
15
16if state != "empty" and len(sys.argv) == 3:
17 print "usage: execute-tapi-context-get-call onos-node full devices links ports"
18 sys.exit(1)
19
20request = 'http://' + node + ':8181/onos/restconf/data/tapi-common:context'
21tapiContext = tapiHelper.get_context(request)
22
23if state == "empty":
24 uuid = tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['uuid']
25 if uuid == "":
26 print "empty uuid"
27 sys.exit(1)
28 print "@stc tapi topology uuid=" + uuid
29 sys.exit(0)
30
31if state == "full":
32 devices = sys.argv[3]
33 links = sys.argv[4]
34 ports = sys.argv[5]
35 #TODO parse reply for number of devices, links and ports
36 print "Parsing for given topology not yet implemented"
37 sys.exit(0)
38
39sys.exit(1)
40
41
42
43