Merge branch 'master' of https://github.com/OPENNETWORKINGLAB/ONLabTest
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index d7f57d3..d2761f0 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -337,8 +337,68 @@
main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
main.cleanup()
main.exit()
+#**********************************************************************************************
+#**********************************************************************************************
+# The purpose of comp_intents is to find if the high level intents have changed. preIntents
+# and postIntents should be the output of curl of the intents. preIntents being the original
+# and postIntents being the later. We are looking at the intents with the same id from both
+# and comparing the dst and src DPIDs and macs, and the state. If any of these are changed
+# we print that there are changes, then return a list of the intents that have changes`
+#**********************************************************************************************
+#**********************************************************************************************
+ def comp_intents(self,preIntents,postIntents):
+ import json
+ preDecoded = json.loads(preIntents)
+ postDecoded = json.loads(postIntents)
+ changes = []
+ if not preDecoded:
+ if postDecoded:
+ print "THERE ARE CHANGES TO THE HIGH LEVEL INTENTS!!!!"
+ return postDecoded
+ for k in preDecoded:
+ for l in postDecoded:
+ if l['id']==k['id']:
+ if k['dstSwitchDpid']==l['dstSwitchDpid'] and k['srcMac']==l['srcMac'] and k['dstMac']==l['dstMac'] and k['srcSwitchDpid']==l['srcSwitchDpid'] and k['state']==l['state']:
+ postDecoded.remove(l)
+ else:
+ changes.append(k)
+ print ("THERE ARE CHANGES TO THE HIGH LEVEL INTENTS!!!")
+ return changes
-
+#**********************************************************************************************
+#**********************************************************************************************
+# the purpose of comp_low is to find if the low level intents have changed. The main idea
+# is to determine if the path has changed. Again, like with the comp_intents function, the
+# pre and post Intents variables are the json dumps of wm/onos/intent/low. The variables
+# that will be compared are the state, and the path.
+#**********************************************************************************************
+#**********************************************************************************************
+ def comp_low(self, preIntents,postIntents):
+ import json
+ preDecoded = json.loads(preIntents)
+ postDecoded = json.loads(postIntents)
+ changes = []
+ if not preDecoded:
+ if postDecoded:
+ print "THERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!"
+ return postDecoded
+ for k in preDecoded:
+ for l in postDecoded:
+ if l['id']==k['id']:
+ if l['path']!=k['path']:
+ changes.append(l)
+ print "\n\n\n\nTHERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!"
+ else:
+ if k['state']!=l['state']:
+ changes.append(l)
+ print "\n\n\n\nTHERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!"
+ else:
+ print "NO CHANGES SO FAR\n\n\n"
+
+
+ return changes
+
+
def rest_stop(self):
'''
Runs ./start-rest.sh stop to stop ONOS rest server
@@ -1278,6 +1338,7 @@
i = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT],timeout=120)
#main.log.warn("third expect response: " +str(i))
response = self.handle.before
+ print response
count = 0
print response
for line in response.splitlines():
diff --git a/TestON/drivers/common/cli/zookeeperclidriver.py b/TestON/drivers/common/cli/zookeeperclidriver.py
index 5d9396e..736a5a1 100644
--- a/TestON/drivers/common/cli/zookeeperclidriver.py
+++ b/TestON/drivers/common/cli/zookeeperclidriver.py
@@ -131,28 +131,27 @@
main.log.error(self.name + ": Connection failed to the host")
response = main.FALSE
return response
-
- def findMaster(self, switchDPID, ip="localhost"):
+
+#**********************************************************************************************
+#**********************************************************************************************
+# findMaster is used to determine the master controller of a switch.
+# it uses the switchList which is a json dict, and finds the first controller of
+# each switch
+#**********************************************************************************************
+#**********************************************************************************************
+
+
+ def findMaster(self, switchDPID, switchList,ip="localhost"):
import json
- time.sleep(1)
- command = "curl "+ip+":8080/wm/onos/registry/switches/json > master.txt"
- response = self.execute(cmd=command,prompt="\$",timeout=10)
- self.handle.sendline("cat master.txt")
- response = self.execute(cmd=command,prompt="\$",timeout=10)
- self.handle.expect(["cat master.txt",pexpect.EOF,pexpect.TIMEOUT])
- self.handle.expect(["admin",pexpect.EOF,pexpect.TIMEOUT])
- response = self.handle.before
- decoded = json.loads(response)
+ decoded = json.loads(switchList)
for k in decoded.iteritems():
k2 = json.dumps(k)
if re.search(switchDPID,k2):
k3 = k2.split(',')
k4 = k3[1].split()
k5 = k4[1].split('"')
- print k5[1]
return k5[1]
- else:
- return "NO SWITCH WITH THIS DPID!"
+ return "NO SWITCH FOUND"
def isup(self):
'''