SRBridging test (CASE-6) Paired-leaf pod
Change-Id: I452cb1619e9d433142626c95c95ed0794b4b749a
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index c2ce59e..7027408 100755
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -72,12 +72,14 @@
A formatted string for printing or None on error
"""
try:
+ if not jsonObject:
+ return None
if isinstance( jsonObject, str ):
jsonObject = json.loads( jsonObject )
return json.dumps( jsonObject, sort_keys=True,
indent=4, separators=( ',', ': ' ) )
except ( TypeError, ValueError ):
- main.log.exception( "Error parsing jsonObject" )
+ main.log.exception( "Error parsing jsonObject %s" % repr(jsonObject) )
return None
def send( self, url, ip = "DEFAULT", port = "DEFAULT", base="/onos/v1", method="GET",
diff --git a/TestON/drivers/common/cli/emulator/scapyclidriver.py b/TestON/drivers/common/cli/emulator/scapyclidriver.py
index db4a721..e5d2deb 100644
--- a/TestON/drivers/common/cli/emulator/scapyclidriver.py
+++ b/TestON/drivers/common/cli/emulator/scapyclidriver.py
@@ -168,7 +168,7 @@
i = self.handle.expect( [ "not found", "password for", self.scapyPrompt ] )
if i == 1:
main.log.debug( "Sudo asking for password" )
- main.log.sendline( self.pwd )
+ self.handle.sendline( self.pwd )
i = self.handle.expect( [ "not found", self.scapyPrompt ] )
if i == 0:
output = self.handle.before + self.handle.after
@@ -283,7 +283,7 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def buildIP( self, **kwargs ):
+ def buildIP( self, vlan=False, **kwargs ):
"""
Build an IP frame
@@ -326,7 +326,10 @@
# KeyError, SyntaxError, ...
main.log.error( "Error in sending command: " + response )
return main.FALSE
- self.handle.sendline( "packet = ether/ip" )
+ if vlan:
+ self.handle.sendline( "packet = ether/vlan/ip" )
+ else:
+ self.handle.sendline( "packet = ether/ip" )
self.handle.expect( self.scapyPrompt )
response = self.cleanOutput( self.handle.before )
if "Traceback" in response:
@@ -366,7 +369,7 @@
# KeyError, SyntaxError, ...
main.log.error( "Error in sending command: " + response )
return main.FALSE
- self.handle.sendline( "packet = ether/ip/vlan" )
+ self.handle.sendline( "packet = ether/vlan" )
self.handle.expect( self.scapyPrompt )
response = self.cleanOutput( self.handle.before )
if "Traceback" in response:
@@ -384,7 +387,7 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def buildIPv6( self, **kwargs ):
+ def buildIPv6( self, vlan=False, **kwargs ):
"""
Build an IPv6 frame
@@ -422,7 +425,10 @@
# KeyError, SyntaxError, ...
main.log.error( "Error in sending command: " + response )
return main.FALSE
- self.handle.sendline( "packet = ether/ipv6" )
+ if vlan:
+ self.handle.sendline( "packet = ether/vlan/ipv6" )
+ else:
+ self.handle.sendline( "packet = ether/ipv6" )
self.handle.expect( self.scapyPrompt )
response = self.cleanOutput( self.handle.before )
if "Traceback" in response:
@@ -704,7 +710,7 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def buildICMP( self, ipVersion=4, **kwargs ):
+ def buildICMP( self, ipVersion=4, vlan=False, **kwargs ):
"""
Build an ICMP frame
@@ -750,14 +756,20 @@
# KeyError, SyntaxError, ...
main.log.error( "Error in sending command: " + response )
return main.FALSE
-
- if str( ipVersion ) is '4':
- self.handle.sendline( "packet = ether/ip/icmp" )
- elif str( ipVersion ) is '6':
- self.handle.sendline( "packet = ether/ipv6/icmp6" )
+ if vlan:
+ if str( ipVersion ) is '4':
+ self.handle.sendline( "packet = ether/vlan/ip/icmp" )
+ elif str( ipVersion ) is '6':
+ self.handle.sendline( "packet = ether/vlan/ipv6/icmp6" )
else:
- main.log.error( "Unrecognized option for ipVersion, given " +
+ if str( ipVersion ) is '4':
+ self.handle.sendline( "packet = ether/ip/icmp" )
+ elif str( ipVersion ) is '6':
+ self.handle.sendline( "packet = ether/ipv6/icmp6" )
+ else:
+ main.log.error( "Unrecognized option for ipVersion, given " +
repr( ipVersion ) )
+
return main.FALSE
self.handle.expect( self.scapyPrompt )
response = self.cleanOutput( self.handle.before )
diff --git a/TestON/drivers/common/cli/networkdriver.py b/TestON/drivers/common/cli/networkdriver.py
index 6b02e09..b1dfd78 100755
--- a/TestON/drivers/common/cli/networkdriver.py
+++ b/TestON/drivers/common/cli/networkdriver.py
@@ -529,17 +529,28 @@
main.log.debug( "Pinging from " + str( hostPair[ 0 ].shortName ) + " to " + str( hostPair[ 1 ].shortName ) )
srcIPs = hostPair[ 0 ].interfaces[0].get( 'ips' )
dstIPs = hostPair[ 1 ].interfaces[0].get( 'ips' )
+ srcVLANs = hostPair[0].interfaces[0].get( 'vlan' )
+ if srcVLANs:
+ VLAN = srcVLANs[0]
+ else:
+ VLAN=None
+ dstVLANs = hostPair[1].interfaces[0].get( 'vlan' )
# Use scapy to send and recieve packets
hostPair[ 1 ].startScapy( ifaceName=dstIface )
hostPair[ 1 ].addRoutes()
- hostPair[ 1 ].startFilter( ifaceName=dstIface, pktFilter="ether src host %s and ip src host %s" % ( srcMac, srcIPs[0] ) )
-
+ filters = []
+ if srcMac:
+ filters.append( "ether src host %s" % srcMac )
+ if srcIPs[0]:
+ filters.append( "ip src host %s" % srcIPs[0] )
+ hostPair[ 1 ].startFilter( ifaceName=dstIface, pktFilter=" and ".join(filters) )
hostPair[ 0 ].startScapy( ifaceName=srcIface )
hostPair[ 0 ].addRoutes()
hostPair[ 0 ].buildEther( src=srcMac, dst=dstMac )
+ if VLAN:
+ hostPair[ 0 ].buildVLAN( vlan=VLAN )
hostPair[ 0 ].buildIP( src=srcIPs[0], dst=dstIPs[0] )
- hostPair[ 0 ].buildVLAN( vlan=[102, 103] )
- hostPair[ 0 ].buildICMP( )
+ hostPair[ 0 ].buildICMP( vlan=VLAN )
hostPair[ 0 ].sendPacket( iface=srcIface )
waiting = not hostPair[ 1 ].checkFilter()