blob: b419ca166eb5a8eb2a1955287c01e60c203502d8 [file] [log] [blame]
Ray Milkey92370672017-02-21 10:30:43 -08001#!/usr/bin/env python
2
3# -----------------------------------------------------------------------------
4# Invokes the ONOS CLI and looks for a 'maps' entry with the given name
5# -----------------------------------------------------------------------------
6
7import subprocess
8import json
9import sys
10
11if len(sys.argv) != 4:
12 print "usage: onos-find-and-check-map onos-node map-name should-be-zero"
13 sys.exit(1)
14
15node = sys.argv[1]
16mapName = sys.argv[2]
17shouldBeZero = sys.argv[3]
18
19cli = subprocess.Popen(["onos", node, "maps", "-j"], stdout=subprocess.PIPE)
20json = json.loads(cli.communicate()[0])
21
22for map in json:
23 foundMapName = map["name"]
24 foundMapSize = map["size"]
25
26 print foundMapName
27 print foundMapSize
28
29 if foundMapName == mapName:
30 if (shouldBeZero == 'yes' and foundMapSize == 0) or \
31 (shouldBeZero != 'yes' and foundMapSize != 0):
32 sys.exit(0)
33 else:
34 sys.exit(1)
35
36sys.exit(1)