Merge branch 'devl/cleanup' of https://github.com/OPENNETWORKINGLAB/ONLabTest into remotes/origin/devl/cleanup
Conflicts:
TestON/drivers/common/cli/onosclidriver.py
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 32fcc35..aec6122 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -240,8 +240,13 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def sendline(self, cmd_str):
+ '''
+=======
def sendline( self, cmd_str ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Send a completely user specified string to
the onos> prompt. Use this function if you have
a very specific command to send.
@@ -253,6 +258,27 @@
self.handle.sendline( "" )
self.handle.expect( "onos>" )
+<<<<<<< HEAD
+ self.handle.sendline("log:log \"Sending CLI command: '"
+ + cmd_str + "'\"")
+ self.handle.expect("onos>")
+ self.handle.sendline( cmd_str )
+ self.handle.expect( cmd_str )
+ self.handle.expect("onos>")
+
+ handle = self.handle.before
+
+ self.handle.sendline("")
+ self.handle.expect("onos>")
+
+ #handle += self.handle.before
+ #handle += self.handle.after
+
+ main.log.info("Command '" + str( cmd_str ) + "' sent to "
+ + self.name + ".")
+ ansi_escape = re.compile(r'\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+=======
self.handle.sendline( cmd_str )
self.handle.expect( "onos>" )
@@ -267,6 +293,7 @@
main.log.info( "Command sent." )
ansi_escape = re.compile( r'\x1b[^m]*m' )
handle = ansi_escape.sub( '', handle )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
@@ -288,8 +315,13 @@
# onos:links > onos_links
# feature:list > feature_list
+<<<<<<< HEAD
+ def add_node(self, node_id, ONOS_ip, tcp_port=""):
+ '''
+=======
def add_node( self, node_id, ONOS_ip, tcp_port="" ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Adds a new cluster node by ID and address information.
Required:
* node_id
@@ -298,6 +330,14 @@
* tcp_port
"""
try:
+<<<<<<< HEAD
+ cmd_str = "add-node " + str(node_id) + " " +\
+ str(ONOS_ip) + " " + str(tcp_port)
+ handle = self.sendline( cmd_str )
+ if re.search("Error", handle):
+ main.log.error("Error in adding node")
+ main.log.error(handle)
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -319,11 +359,11 @@
if i == 0:
main.log.error( "Error in adding node" )
main.log.error( handle )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.FALSE
else:
main.log.info( "Node " + str( ONOS_ip ) + " added" )
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -344,11 +384,18 @@
* node_id
"""
try:
+<<<<<<< HEAD
+
+ cmd_str = "remove-node " + str(node_id)
+ self.sendline( cmd_str )
+ # TODO: add error checking. Does ONOS give any errors?
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
self.handle.sendline( "remove-node " + str( node_id ) )
self.handle.expect( "onos>" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.TRUE
@@ -371,6 +418,10 @@
Returns: entire handle of list of nodes
"""
try:
+<<<<<<< HEAD
+ cmd_str = "nodes"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -382,8 +433,8 @@
handle = self.handle.before
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -402,6 +453,13 @@
by issusing command: 'onos> onos:topology'
"""
try:
+<<<<<<< HEAD
+ # either onos:topology or 'topology' will work in CLI
+ cmd_str = "onos:topology"
+ handle = self.sendline( cmd_str )
+ main.log.info( "onos:topology returned: " + str( handle ) )
+ return handle
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
# either onos:topology or 'topology' will work in CLI
@@ -415,6 +473,7 @@
return handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -427,20 +486,30 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def feature_install(self, feature_str):
+ '''
+=======
def feature_install( self, feature_str ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Installs a specified feature
by issuing command: 'onos> feature:install <feature_str>'
"""
try:
+<<<<<<< HEAD
+ cmd_str = "feature:install " + str( feature_str )
+ self.sendline( cmd_str )
+ # TODO: Check for possible error responses from karaf
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
self.handle.sendline( "feature:install " + str( feature_str ) )
self.handle.expect( "onos>" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -457,20 +526,30 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def feature_uninstall(self, feature_str):
+ '''
+=======
def feature_uninstall( self, feature_str ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Uninstalls a specified feature
by issuing command: 'onos> feature:uninstall <feature_str>'
"""
try:
+<<<<<<< HEAD
+ cmd_str = "feature:uninstall " + str( feature_str )
+ self.sendline( cmd_str )
+ # TODO: Check for possible error responses from karaf
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
self.handle.sendline( "feature:uninstall " + str( feature_str ) )
self.handle.expect( "onos>" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -490,6 +569,30 @@
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "devices -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the
+ ANSI escape sequences. In json.loads(somestring), this
+ somestring variable is actually repr(somestring) and
+ json.loads would fail with the escape sequence. So we take off
+ that escape sequence using:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+ else:
+ cmd_str = "devices"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -516,6 +619,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -529,20 +633,30 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def balance_masters(self):
+ '''
+=======
def balance_masters( self ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
This balances the devices across all controllers
by issuing command: 'onos> onos:balance-masters'
If required this could be extended to return devices balanced output.
"""
try:
+<<<<<<< HEAD
+ cmd_str = "onos:balance-masters"
+ self.sendline( cmd_str )
+ # TODO: Check for error responses from ONOS
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
self.handle.sendline( "onos:balance-masters" )
self.handle.expect( "onos>" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -562,6 +676,30 @@
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "links -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the ANSI
+ escape sequences. In json.loads(somestring), this somestring
+ variable is actually repr(somestring) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+ else:
+ cmd_str = "links"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -588,6 +726,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -601,13 +740,43 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def ports(self, json_format=True):
+ '''
+=======
def ports( self, json_format=True ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Lists all ports
Optional argument:
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "ports -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the ANSI
+ escape sequences. In json.loads(somestring), this somestring
+ variable is actually repr(somestring) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using the following commads:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+
+ else:
+ cmd_str = "ports"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -637,6 +806,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -657,6 +827,33 @@
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "roles -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the ANSI
+ escape sequences. In json.loads(somestring), this somestring
+ variable is actually repr(somestring) and json.loads would
+ fail with the escape sequence.
+
+ So we take off that escape sequence using the following
+ commads:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+
+ else:
+ cmd_str = "roles"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -690,6 +887,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -703,6 +901,19 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def get_role(self, device_id):
+ '''
+ Given the a string containing the json representation of the "roles"
+ cli command and a partial or whole device id, returns a json object
+ containing the roles output for the first device whose id contains
+ "device_id"
+
+ Returns:
+ A dict of the role assignments for the given device or
+ None if no match
+ '''
+=======
def get_role( self, device_id ):
"""
Given the a string containing the json representation of the "roles" cli command and a
@@ -713,6 +924,7 @@
Dict of the role assignments for the given device or
None if not match
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
try:
import json
if device_id is None:
@@ -775,6 +987,17 @@
Issues command: onos:paths <src> <dst>
"""
try:
+<<<<<<< HEAD
+ cmd_str = "onos:paths " + str(src_id) + " " + str(dst_id)
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ main.log.error("Error in getting paths")
+ return (handle, "Error")
+ else:
+ path = handle.split(";")[0]
+ cost = handle.split(";")[1]
+ return (path, cost)
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -797,6 +1020,7 @@
cost = handle.split( ";" )[ 1 ]
return ( path, cost )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -816,6 +1040,30 @@
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "hosts -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the ANSI
+ escape sequences. In json.loads(somestring), this somestring
+ variable is actually repr(somestring) and json.loads would
+ fail with the escape sequence. So we take off that escape
+ sequence using:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+ else:
+ cmd_str = "hosts"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -842,6 +1090,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -858,7 +1107,10 @@
def get_host( self, mac ):
"""
Return the first host from the hosts api whose 'id' contains 'mac'
- Note: mac must be a colon seperated mac address, but could be a partial mac address
+
+ Note: mac must be a colon seperated mac address, but could be a
+ partial mac address
+
Return None if there is no match
"""
import json
@@ -938,6 +1190,13 @@
specifying the two hosts.
"""
try:
+<<<<<<< HEAD
+ cmd_str = "add-host-intent " + str(host_id_one) +\
+ " " + str(host_id_two)
+ handle = self.sendline( cmd_str )
+ main.log.info("Host intent installed between "+
+ str(host_id_one) + " and " + str(host_id_two))
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -951,8 +1210,8 @@
main.log.info( "Host intent installed between " +
str( host_id_one ) + " and " + str( host_id_two ) )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -972,6 +1231,18 @@
* egress_device: device id of egress device
Optional:
TODO: Still needs to be implemented via dev side
+<<<<<<< HEAD
+ '''
+ try:
+ cmd_str = "add-optical-intent " + str( ingress_device ) +\
+ " " + str( egress_device )
+ handle = self.sendline( cmd_str )
+ #If error, return error message
+ if re.search( "Error", handle ):
+ return handle
+ else:
+ return main.TRUE
+=======
"""
try:
self.handle.sendline( "add-optical-intent " +
@@ -989,6 +1260,7 @@
else:
return main.TRUE
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1001,11 +1273,19 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def add_point_intent(self, ingress_device, egress_device,
+ port_ingress="", port_egress="", ethType="", ethSrc="",
+ ethDst="", bandwidth="", lambda_alloc=False,
+ ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst=""):
+ '''
+=======
def add_point_intent( self, ingress_device, egress_device,
port_ingress="", port_egress="", ethType="", ethSrc="",
ethDst="", bandwidth="", lambda_alloc=False,
ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="" ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Required:
* ingress_device: device id of ingress device
* egress_device: device id of egress device
@@ -1038,6 +1318,10 @@
and not ipProto and not ipSrc and not ipDst \
and not tcpSrc and not tcpDst:
cmd = "add-point-intent"
+<<<<<<< HEAD
+
+=======
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
else:
cmd = "add-point-intent"
@@ -1045,9 +1329,15 @@
if ethType:
cmd += " --ethType " + str( ethType )
if ethSrc:
+<<<<<<< HEAD
+ cmd += " --ethSrc " + str(ethSrc)
+ if ethDst:
+ cmd += " --ethDst " + str(ethDst)
+=======
cmd += " --ethSrc " + str( ethSrc )
if ethDst:
cmd += " --ethDst " + str( ethDst )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if bandwidth:
cmd += " --bandwidth " + str( bandwidth )
if lambda_alloc:
@@ -1063,8 +1353,13 @@
if tcpDst:
cmd += " --tcpDst " + str( tcpDst )
+<<<<<<< HEAD
+ #Check whether the user appended the port
+ #or provided it as an input
+=======
# Check whether the user appended the port
# or provided it as an input
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if "/" in ingress_device:
cmd += " " + str( ingress_device )
else:
@@ -1074,9 +1369,15 @@
# TODO: perhaps more meaningful return
return main.FALSE
+<<<<<<< HEAD
+ cmd += " "+ \
+ str(ingress_device) + "/" +\
+ str(port_ingress) + " "
+=======
cmd += " " + \
str( ingress_device ) + "/" +\
str( port_ingress ) + " "
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if "/" in egress_device:
cmd += " " + str( egress_device )
@@ -1086,6 +1387,15 @@
"the egress port" )
return main.FALSE
+<<<<<<< HEAD
+ cmd += " "+\
+ str(egress_device) + "/" +\
+ str(port_egress)
+
+ handle = self.sendline(cmd)
+ if re.search( "Error", handle ):
+ main.log.error("Error in adding point-to-point intent")
+=======
cmd += " " +\
str( egress_device ) + "/" +\
str( port_egress )
@@ -1099,10 +1409,10 @@
if i == 0:
main.log.error( "Error in adding point-to-point intent" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.FALSE
else:
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1115,15 +1425,26 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+
+ def add_multipoint_to_singlepoint_intent(self, ingress_device1,
+ ingress_device2, egress_device, port_ingress="", port_egress="",
+ ethType="", ethSrc="", ethDst="", bandwidth="", lambda_alloc=False,
+ ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", setEthSrc="",
+ setEthDst=""):
+ '''
+=======
def add_multipoint_to_singlepoint_intent(
self, ingress_device1, ingress_device2, egress_device,
port_ingress="", port_egress="", ethType="", ethSrc="",
ethDst="", bandwidth="", lambda_alloc=False,
ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", setEthSrc="", setEthDst="" ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Note:
- This function assumes that there would be 2 ingress devices and one egress device
- For more number of ingress devices, this function needs to be modified
+ This function assumes that there would be 2 ingress devices and
+ one egress device. For more number of ingress devices, this
+ function needs to be modified
Required:
* ingress_device1: device id of ingress device1
* ingress_device2: device id of ingress device2
@@ -1155,9 +1476,10 @@
# If there are no optional arguments
if not ethType and not ethSrc and not ethDst\
- and not bandwidth and not lambda_alloc \
- and not ipProto and not ipSrc and not ipDst \
- and not tcpSrc and not tcpDst and not setEthSrc and not setEthDst:
+ and not bandwidth and not lambda_alloc\
+ and not ipProto and not ipSrc and not ipDst\
+ and not tcpSrc and not tcpDst and not setEthSrc\
+ and not setEthDst:
cmd = "add-multi-to-single-intent"
else:
@@ -1166,9 +1488,15 @@
if ethType:
cmd += " --ethType " + str( ethType )
if ethSrc:
+<<<<<<< HEAD
+ cmd += " --ethSrc " + str(ethSrc)
+ if ethDst:
+ cmd += " --ethDst " + str(ethDst)
+=======
cmd += " --ethSrc " + str( ethSrc )
if ethDst:
cmd += " --ethDst " + str( ethDst )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if bandwidth:
cmd += " --bandwidth " + str( bandwidth )
if lambda_alloc:
@@ -1188,10 +1516,17 @@
if setEthDst:
cmd += " --setEthDst " + str( setEthDst )
+<<<<<<< HEAD
+ #Check whether the user appended the port
+ #or provided it as an input
+ if "/" in ingress_device1:
+ cmd += " "+str(ingress_device1)
+=======
# Check whether the user appended the port
# or provided it as an input
if "/" in ingress_device1:
cmd += " " + str( ingress_device1 )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
else:
if not port_ingress1:
main.log.error( "You must specify " +
@@ -1199,9 +1534,15 @@
# TODO: perhaps more meaningful return
return main.FALSE
+<<<<<<< HEAD
+ cmd += " "+ \
+ str(ingress_device1) + "/" +\
+ str(port_ingress1) + " "
+=======
cmd += " " + \
str( ingress_device1 ) + "/" +\
str( port_ingress1 ) + " "
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if "/" in ingress_device2:
cmd += " " + str( ingress_device2 )
@@ -1224,6 +1565,15 @@
"the egress port" )
return main.FALSE
+<<<<<<< HEAD
+ cmd += " "+\
+ str(egress_device) + "/" +\
+ str(port_egress)
+ print "cmd= ",cmd
+ handle = self.sendline(cmd)
+ if re.search( "Error", handle ):
+ main.log.error("Error in adding point-to-point intent")
+=======
cmd += " " +\
str( egress_device ) + "/" +\
str( port_egress )
@@ -1237,10 +1587,10 @@
if i == 0:
main.log.error( "Error in adding point-to-point intent" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return self.handle
else:
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1253,6 +1603,25 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def remove_intent(self, intent_id):
+ '''
+ Remove intent for specified intent id
+
+ Returns:
+ main.False on error and
+ cli output otherwise
+ '''
+ try:
+ cmd_str = "remove-intent " + str( intent_id )
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ main.log.error("Error in removing intent")
+ return main.FALSE
+ else:
+ # TODO: Should this be main.TRUE
+ return handle
+=======
def remove_intent( self, intent_id ):
"""
Remove intent for specified intent id
@@ -1274,6 +1643,7 @@
else:
return handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1286,9 +1656,16 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def routes(self, json_format=False):
+ '''
+ NOTE: This method should be used after installing application:
+ onos-app-sdnip
+=======
# This method should be used after installing application: onos-app-sdnip
def routes( self, json_format=False ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Optional:
* json_format: enable output formatting in json
Description:
@@ -1296,6 +1673,15 @@
"""
try:
if json_format:
+<<<<<<< HEAD
+ cmd_str = "routes -j"
+ handle_tmp = self.sendline( cmd_str )
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle_tmp)
+ else:
+ cmd_str = "routes"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "routes -j" )
self.handle.expect( "routes -j" )
self.handle.expect( "onos>" )
@@ -1312,8 +1698,8 @@
self.handle.expect( "onos>" )
handle = self.handle.before
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1332,6 +1718,18 @@
* json_format: enable output formatting in json
Description:
Obtain intents currently installed
+<<<<<<< HEAD
+ '''
+ try:
+ if json_format:
+ cmd_str = "intents -j"
+ handle = self.sendline( cmd_str )
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+ else:
+ cmd_str = "intents"
+ handle = self.sendline( cmd_str )
+=======
"""
try:
if json_format:
@@ -1350,8 +1748,8 @@
self.handle.expect( "onos>" )
handle = self.handle.before
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1370,6 +1768,21 @@
* json_format: enable output formatting in json
Description:
Obtain flows currently installed
+<<<<<<< HEAD
+ '''
+ try:
+ if json_format:
+ cmd_str = "flows -j"
+ handle = self.sendline( cmd_str )
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+ else:
+ cmd_str = "flows"
+ handle = self.sendline( cmd_str )
+ if re.search("Error\sexecuting\scommand:", handle):
+ main.log.error( self.name + ".flows() response: " +
+ str( handle ) )
+=======
"""
try:
if json_format:
@@ -1390,8 +1803,8 @@
main.log.error(
self.name + ".flows() response: " + str( handle ) )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1404,9 +1817,15 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def push_test_intents(self, dpid_src, dpid_dst, num_intents,
+ num_mult="", app_id="", report=True):
+ '''
+=======
def push_test_intents( self, dpid_src, dpid_dst, num_intents,
num_mult="", app_id="", report=True ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Description:
Push a number of intents in a batch format to
a specific point-to-point intent definition
@@ -1422,6 +1841,22 @@
* report: default True, returns latency information
"""
try:
+<<<<<<< HEAD
+ cmd = "push-test-intents "+\
+ str(dpid_src)+" "+str(dpid_dst)+" "+\
+ str(num_intents)
+ if num_mult:
+ cmd += " " + str(num_mult)
+ #If app id is specified, then num_mult
+ #must exist because of the way this command
+ #takes in arguments
+ if app_id:
+ cmd += " " + str(app_id)
+ handle = self.sendline( cmd )
+ #Some color thing that we want to escape
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+=======
cmd = "push-test-intents " +\
str( dpid_src ) + " " + str( dpid_dst ) + " " +\
str( num_intents )
@@ -1444,6 +1879,7 @@
ansi_escape = re.compile( r'\r\r\n\x1b[^m]*m' )
handle = ansi_escape.sub( '', handle )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
if report:
lat_result = []
main.log.info( handle )
@@ -1453,15 +1889,21 @@
newline = newline[ 1: ]
# Some sloppy parsing method to get the latency
for result in newline:
+<<<<<<< HEAD
+ result = result.split(": ")
+ #Append the first result of second parse
+ lat_result.append(result[1].split(" ")[0])
+ main.log.info(lat_result)
+=======
result = result.split( ": " )
# Append the first result of second parse
lat_result.append( result[ 1 ].split( " " )[ 0 ] )
main.log.info( lat_result )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return lat_result
else:
return main.TRUE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1474,14 +1916,30 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def intents_events_metrics(self, json_format=True):
+ '''
+=======
def intents_events_metrics( self, json_format=True ):
"""
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
Description:Returns topology metrics
Optional:
* json_format: enable json formatting of output
"""
try:
if json_format:
+<<<<<<< HEAD
+ cmd_str = "intents-events-metrics -j"
+ handle = self.sendline( cmd_str )
+ # Some color thing that we want to escape
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+ else:
+ cmd_str = "intents-events-metrics"
+ handle = self.sendline( cmd_str )
+ return handle
+=======
self.handle.sendline( "intents-events-metrics -j" )
self.handle.expect( "intents-events-metrics -j" )
self.handle.expect( "onos>" )
@@ -1501,6 +1959,7 @@
return handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1521,6 +1980,17 @@
"""
try:
if json_format:
+<<<<<<< HEAD
+ cmd_str = "topology-events-metrics -j"
+ handle = self.sendline( cmd_str )
+ #Some color thing that we want to escape
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle = ansi_escape.sub('', handle)
+ else:
+ cmd_str = "topology-events-metrics"
+ handle = self.sendline( cmd_str )
+ return handle
+=======
self.handle.sendline( "topology-events-metrics -j" )
self.handle.expect( "topology-events-metrics -j" )
self.handle.expect( "onos>" )
@@ -1540,6 +2010,7 @@
return handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1786,6 +2257,27 @@
onos_node is the ip of one of the onos nodes in the cluster
role must be either master, standby, or none
+<<<<<<< HEAD
+ Returns:
+ main.TRUE or main.FALSE based on argument verification and
+ main.ERROR if command returns and error
+ '''
+ try:
+ if role.lower() == "master" or role.lower() == "standby" or\
+ role.lower() == "none":
+ cmd_str = "device-role " +\
+ str(device_id) + " " +\
+ str(onos_node) + " " +\
+ str(role)
+ handle = self.sendline( cmd_str )
+ if re.search( "Error", handle ):
+ # end color output to escape any colours
+ # from the cli
+ main.log.error( self.name + ": " +\
+ handle + '\033[0m' )
+ return main.ERROR
+ return main.TRUE
+=======
Returns main.TRUE or main.FALSE based on argument verification.
When device-role supports errors this should be extended to
support that output
@@ -1814,9 +2306,11 @@
self.handle.sendline( "" )
self.handle.expect( "onos>" )
return main.TRUE
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
else:
+ main.log.error("Invalid 'role' given to device_role(). " +
+ "Value was '" + str( role ) + "'.")
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1836,6 +2330,30 @@
* json_format - boolean indicating if you want output in json
"""
try:
+<<<<<<< HEAD
+ if json_format:
+ cmd_str = "clusters -j"
+ handle = self.sendline( cmd_str )
+ '''
+ handle variable here contains some ANSI escape color code
+ sequences at the end which are invisible in the print command
+ output. To make that escape sequence visible, use repr()
+ function. The repr(handle) output when printed shows the ANSI
+ escape sequences. In json.loads(somestring), this somestring
+ variable is actually repr(somestring) and json.loads would fail
+ with the escape sequence. So we take off that escape sequence
+ using:
+
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ '''
+ ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+ handle1 = ansi_escape.sub('', handle)
+ return handle1
+ else:
+ cmd_str = "clusters"
+ handle = self.sendline( cmd_str )
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -1865,6 +2383,7 @@
self.handle.expect( "onos>" )
handle = self.handle.before
# print "handle =",handle
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return handle
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
@@ -1878,6 +2397,46 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def election_test_leader(self):
+ '''
+ CLI command to get the current leader for the Election test application
+ NOTE: Requires installation of the onos-app-election feature
+ Returns: Node IP of the leader if one exists
+ None if none exists
+ Main.FALSE on error
+ '''
+ try:
+ cmd_str = "election-test-leader"
+ response = self.sendline( cmd_str )
+ # Leader
+ leaderPattern = "The\scurrent\sleader\sfor\sthe\sElection\s" +\
+ "app\sis\s(?P<node>.+)\."
+ node_search = re.search(leaderPattern, response)
+ if node_search:
+ node = node_search.group('node')
+ main.log.info( "Election-test-leader on " + str( self.name ) +
+ " found " + node + " as the leader" )
+ return node
+ # no leader
+ nullPattern = "There\sis\scurrently\sno\sleader\selected\sfor\s" +\
+ "the\sElection\sapp"
+ null_search = re.search(nullPattern, response)
+ if null_search:
+ main.log.info( "Election-test-leader found no leader on " +
+ self.name )
+ return None
+ #error
+ errorPattern = "Command\snot\sfound"
+ if re.search(errorPattern, response):
+ main.log.error("Election app is not loaded on " + self.name)
+ # TODO: Should this be main.ERROR?
+ return main.FALSE
+ else:
+ main.log.error("Error in election_test_leader: " +
+ "unexpected response")
+ main.log.error( repr(response) )
+=======
def election_test_leader( self ):
"""
* CLI command to get the current leader for the Election test application.
@@ -1917,8 +2476,8 @@
main.log.error(
"Error in election_test_leader: unexpected response" )
main.log.error( repr( response ) )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1931,6 +2490,34 @@
main.cleanup()
main.exit()
+<<<<<<< HEAD
+ def election_test_run(self):
+ '''
+ CLI command to run for leadership of the Election test application.
+ NOTE: Requires installation of the onos-app-election feature
+ Returns: Main.TRUE on success
+ Main.FALSE on error
+ '''
+ try:
+ cmd_str = "election-test-run"
+ response = self.sendline( cmd_str )
+ #success
+ successPattern = "Entering\sleadership\selections\sfor\sthe\s" +\
+ "Election\sapp."
+ search = re.search( successPattern, response )
+ if search:
+ main.log.info( self.name + " entering leadership elections " +
+ "for the Election app." )
+ return main.TRUE
+ #error
+ errorPattern = "Command\snot\sfound"
+ if re.search( errorPattern, response ):
+ main.log.error( "Election app is not loaded on " + self.name )
+ return main.FALSE
+ else:
+ main.log.error( "Error in election_test_run: " +
+ "unexpected response" )
+=======
def election_test_run( self ):
"""
* CLI command to run for leadership of the Election test application.
@@ -1959,9 +2546,9 @@
else:
main.log.error(
"Error in election_test_run: unexpected response" )
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
main.log.error( repr( response ) )
return main.FALSE
-
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1983,6 +2570,27 @@
Main.FALSE on error
"""
try:
+<<<<<<< HEAD
+ cmd_str = "election-test-withdraw"
+ response = self.sendline( cmd_str )
+ #success
+ successPattern = "Withdrawing\sfrom\sleadership\selections\sfor" +\
+ "\sthe\sElection\sapp."
+ if re.search( successPattern, response ):
+ main.log.info( self.name + " withdrawing from leadership " +
+ "elections for the Election app." )
+ return main.TRUE
+ #error
+ errorPattern = "Command\snot\sfound"
+ if re.search( errorPattern, response ):
+ main.log.error( "Election app is not loaded on " + self.name )
+ return main.FALSE
+ else:
+ main.log.error( "Error in election_test_withdraw: " +
+ "unexpected response" )
+ main.log.error( repr( response ) )
+ return main.FALSE
+=======
self.handle.sendline( "election-test-withdraw" )
self.handle.expect( "election-test-withdraw" )
self.handle.expect( "onos>" )
@@ -2006,6 +2614,7 @@
main.log.error( repr( response ) )
return main.FALSE
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -2025,6 +2634,15 @@
"""
try:
dpid = str( dpid )
+<<<<<<< HEAD
+ cmd_str = "onos:ports -e " + dpid + " | wc -l"
+ output = self.sendline( cmd_str )
+ if re.search( "No such device", output ):
+ main.log.error( "Error in getting ports" )
+ return ( output, "Error" )
+ else:
+ return output
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -2045,6 +2663,7 @@
result = output
return result
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -2062,6 +2681,16 @@
Get the count of all enabled ports on a particular device/switch
"""
try:
+<<<<<<< HEAD
+ dpid = str(dpid)
+ cmd_str = "onos:links " + dpid + " | grep ACTIVE | wc -l"
+ output = self.sendline( cmd_str )
+ if re.search( "No such device", output ):
+ main.log.error( "Error in getting ports ")
+ return ( output, "Error ")
+ else:
+ return output
+=======
dpid = str( dpid )
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -2083,6 +2712,7 @@
result = output
return result
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -2100,6 +2730,15 @@
Return a list of all Intent IDs
"""
try:
+<<<<<<< HEAD
+ cmd_str = "onos:intents | grep id="
+ output = self.sendline( cmd_str )
+ if re.search( "Error", output ):
+ main.log.error( "Error in getting ports" )
+ return ( output, "Error" )
+ else:
+ return output
+=======
self.handle.sendline( "" )
self.handle.expect( "onos>" )
@@ -2117,6 +2756,7 @@
result = output
return result
+>>>>>>> 8ec71447cf6f890345b6b3c29368d5bd3c29dd54
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )