pingallHosts - allows users to specify hosts and pingtype to ping between all hosts to check for reachability
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index ad50b9c..d843fb7 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -367,6 +367,64 @@
main.log.info( self.name + ": \n---\n" + response )
return main.FALSE
+ def pingallHosts( self, hostList, pingType='ipv4' ):
+ """
+ Ping all specified hosts with a specific ping type
+
+ Acceptable pingTypes:
+ - 'ipv4'
+ - 'ipv6'
+ - 'udp'
+
+ Acceptable hostList:
+ - ['h1','h2','h3','h4']
+
+ Returns main.TRUE if all hosts specified can reach
+ each other
+
+ Returns main.FALSE if one or more of hosts specified
+ cannot reach each other"""
+
+ if pingType == "ipv4":
+ cmd = " ping -c 1 -i 1 -W 8 "
+ elif pingType == "ipv6":
+ cmd = " ping6 -c 1 -i 1 -W 8 "
+ elif pingType == "udp":
+ cmd = " ping -u -c 1 -i 1 -W 8 "
+ else:
+ main.log.warn( "Invalid pingType specified" )
+ return
+
+ try:
+ main.log.info( "Testing reachability between specified hosts" )
+
+ for host in hostList:
+ listIndex = hostList.index(host)
+ # List of hosts to ping other than itself
+ pingList = hostList[:listIndex] + hostList[(listIndex+1):]
+
+ for temp in pingList:
+ # Current host pings all other hosts specified
+ pingCmd = str(host) + cmd + str(temp)
+ self.handle.sendline( pingCmd )
+ i = self.handle.expect( [ pingCmd, pexpect.TIMEOUT ] )
+ j = self.handle.expect( [ "mininet>", pexpect.TIMEOUT ] )
+ response = self.handle.before
+ if re.search( ',\s0\%\spacket\sloss', response ):
+ main.log.info( str(host) + " -> " + str(temp) )
+ else:
+ main.log.info( str(host) + " -> X ("+str(temp)+") "
+ " Destination Unreachable" )
+ return main.FALSE
+
+ return main.TRUE
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+
def pingHost( self, **pingParams ):
"""
Ping from one mininet host to another