Intent remove driver function
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 8637c11..f7f4ef4 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -419,16 +419,18 @@
else:
if not grep_str:
self.handle.sendline("devices")
- self.handle.expect("devices")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
else:
self.handle.sendline("devices | grep '"+
str(grep_str)+"'")
- self.handle.expect("devices | grep '"+str(grep_str)+"'")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -442,7 +444,6 @@
main.cleanup()
main.exit()
-
def links(self, json_format=True, grep_str=""):
'''
Lists all core links
@@ -466,16 +467,18 @@
else:
if not grep_str:
self.handle.sendline("links")
- self.handle.expect("links")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
else:
self.handle.sendline("links | grep '"+
str(grep_str)+"'")
- self.handle.expect("links | grep '"+str(grep_str)+"'")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -513,16 +516,18 @@
else:
if not grep_str:
self.handle.sendline("ports")
- self.handle.expect("ports")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
else:
self.handle.sendline("ports | grep '"+
str(grep_str)+"'")
- self.handle.expect("ports | grep '"+str(grep_str)+"'")
+ self.handle.expect("onos>")
+ self.handle.sendline("")
self.handle.expect("onos>")
handle = self.handle.before
- print "handle =",handle
+
return handle
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
@@ -710,6 +715,39 @@
main.cleanup()
main.exit()
+ def remove_intent(self, intent_id):
+ '''
+ Remove intent for specified intent id
+ '''
+ try:
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ self.handle.sendline("remove-intent "+str(intent_id))
+ i = self.handle.expect([
+ "Error",
+ "onos>"])
+
+ handle = self.handle.before
+
+ if i == 0:
+ main.log.error("Error in removing intent")
+ return handle
+ else:
+ return handle
+
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
def intents(self):
'''
Description:
@@ -748,6 +786,50 @@
#a normal driver function, and parse it
#using a wrapper function
+ def get_all_intents_id(self):
+ '''
+ Description:
+ Obtain all intent id's in a list
+ '''
+ try:
+ #Obtain output of intents function
+ intents_str = self.intents()
+ all_intent_list = []
+ intent_id_list = []
+
+ #Parse the intents output for ID's
+ intents_list = [s.strip() for s in intents_str.splitlines()]
+ for intents in intents_list:
+ if "onos>" in intents:
+ continue
+ elif "intents" in intents:
+ continue
+ else:
+ line_list = intents.split(" ")
+ all_intent_list.append(line_list[0])
+
+ all_intent_list = all_intent_list[1:-2]
+
+ for intents in all_intent_list:
+ if not intents:
+ continue
+ else:
+ intent_id_list.append(intents)
+
+ return intent_id_list
+
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info(self.name+" ::::::")
+ main.log.error( traceback.print_exc())
+ main.log.info(self.name+" ::::::")
+ main.cleanup()
+ main.exit()
+
def get_all_devices_id(self):
'''
Use 'devices' function to obtain list of all devices
@@ -763,7 +845,7 @@
'''
try:
#Call devices and store result string
- devices_str = self.devices()
+ devices_str = self.devices(json_format=False)
id_list = []
if not devices_str:
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.py b/TestON/tests/ONOSNextTest/ONOSNextTest.py
index b8b75b4..77847fd 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.py
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.py
@@ -199,7 +199,7 @@
main.Mininet2.handle.expect("mininet>")
#Need to sleep to allow switch add processing
time.sleep(5)
- list_result = main.ONOScli.devices()
+ list_result = main.ONOScli.devices(json_format=False)
main.log.info(list_result)
main.step("Get all devices id")
@@ -230,7 +230,7 @@
devices_id_list[0], node_id_list[0], "master")
main.step("Check devices / role again")
- dev_result = main.ONOScli.devices()
+ dev_result = main.ONOScli.devices(json_format=False)
main.log.info(dev_result)
#Sample steps to push intents ***********
@@ -244,13 +244,19 @@
host_onos_list = main.ONOScli.get_hosts_id(host_list)
main.log.info(host_onos_list)
- main.step("Ensure that reactive forwarding is installed")
- feature_result = main.ONOScli.feature_install("onos-app-fwd")
-
time.sleep(5)
- main.Mininet2.handle.sendline("\r")
- main.Mininet2.handle.sendline("h4 ping h5 -c 1")
+ #We must use ping from hosts we want to add intents from
+ #to make the hosts talk
+ #main.Mininet2.handle.sendline("\r")
+ #main.Mininet2.handle.sendline("h4 ping 10.1.1.1 -c 1 -W 1")
+ #time.sleep(3)
+ #main.Mininet2.handle.sendline("h5 ping 10.1.1.1 -c 1 -W 1")
+ #time.sleep(5)
+
+ main.ONOScli.feature_install("onos-app-fwd")
+
+ main.Mininet2.pingall()
time.sleep(5)
@@ -260,19 +266,37 @@
hosts = main.ONOScli.handle.before
main.log.info(hosts)
- main.step("Install host-to-host-intents between h4 and h5")
- intent_install = main.ONOScli.add_host_intent(
- host_onos_list[3], host_onos_list[4])
- main.log.info(intent_install)
+ main.step("Install host-to-host-intents")
+ intent_install1 = main.ONOScli.add_host_intent(
+ host_onos_list[0], host_onos_list[1])
+ intent_install2 = main.ONOScli.add_host_intent(
+ host_onos_list[2], host_onos_list[3])
+ intent_install3 = main.ONOScli.add_host_intent(
+ host_onos_list[4], host_onos_list[5])
- main.step("Uninstall reactive forwarding to test host-to-host intent")
- main.ONOScli.feature_uninstall("onos-app-fwd")
+ main.log.info(intent_install1)
+ main.log.info(intent_install2)
+ main.log.info(intent_install3)
main.step("Get intents installed on ONOS")
get_intent_result = main.ONOScli.intents()
main.log.info(get_intent_result)
#****************************************
+ #Sample steps to delete intents ********
+ main.step("Get all intent id's")
+ intent_id = main.ONOScli.get_all_intents_id()
+ main.log.info(intent_id)
+
+ main.step("Remove specified intent id: "+str(intent_id[0]))
+ intent_result = main.ONOScli.remove_intent(intent_id[0])
+ main.log.info(intent_result)
+
+ main.step("Check installed intents again")
+ get_intent_result = main.ONOScli.intents()
+ main.log.info(get_intent_result)
+ #***************************************
+
######
#jhall@onlab.us