blob: 22b1f272d52b1cf2d68a81161696c5ee53fc779b [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":
Boyuan Yand346e262019-02-14 12:04:15 -080032 devices = int(sys.argv[3])
33 links = int(sys.argv[4])
34 ports = int(sys.argv[5])
35 dev_num = len(tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['node'])
36 directed_link_num = len(tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['link'])
37 port_num = 0
38 for x in range(dev_num):
39 port_num=port_num+len(tapiContext['tapi-common:context']['tapi-topology:topology-context']['topology'][0]['node'][x]['owned-node-edge-point'])
40 print "device\tlink\tport\n%i\t%i\t%i" % (dev_num, directed_link_num/2, port_num)
41 assert devices == dev_num
42 assert links == directed_link_num/2
43 assert ports == port_num
44 print "Topology infomation checking passed."
Andrea Campanella6d774232018-12-21 12:18:21 +010045 sys.exit(0)
46
47sys.exit(1)
48
49
50
51