WIP: HA updates, includes network partition
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index f45ad08..55a5c0e 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -68,10 +68,8 @@
main.log.error( self.name + ": " + self.handle.before )
main.cleanup()
main.exit()
- except:
- main.log.info( self.name + ":" * 30 )
- main.log.error( traceback.print_exc() )
- main.log.info( ":" * 30 )
+ except Exception as e:
+ main.log.exception( "Uncaught exception!" )
main.cleanup()
main.exit()
@@ -1494,8 +1492,8 @@
main.cleanup()
main.exit()
- def setIpTables( self, ip, port='', action='add', packet_type='tcp',
- direction='INPUT', rule='DROP' ):
+ def setIpTables( self, ip, port='', action='add', packet_type='',
+ direction='INPUT', rule='DROP', states=True ):
'''
Description:
add or remove iptables rule to DROP (default) packets from
@@ -1509,6 +1507,8 @@
* optional packet type to block (default tcp)
* optional iptables rule (default DROP)
* optional direction to block (default 'INPUT')
+ * States boolean toggles adding all supported tcp states to the
+ firewall rule
Returns:
main.TRUE on success or
main.FALSE if given invalid input or
@@ -1529,7 +1529,7 @@
# registered to the instance. If you are calling this function
# multiple times this sleep will prevent any errors.
# DO NOT REMOVE
- time.sleep( 5 )
+ # time.sleep( 5 )
try:
# input validation
action_type = action.lower()
@@ -1559,10 +1559,16 @@
self.handle.expect( "\$" )
cmd = "sudo iptables " + actionFlag + " " +\
direction +\
- " -p " + str( packet_type ) +\
" -s " + str( ip )
+ # " -p " + str( packet_type ) +\
+ if packet_type:
+ cmd += " -p " + str( packet_type )
if port:
cmd += " --dport " + str( port )
+ if states:
+ cmd += " -m state --state="
+ #FIXME- Allow user to configure which states to block
+ cmd += "INVALID,ESTABLISHED,NEW,RELATED,UNTRACKED"
cmd += " -j " + str( rule )
self.handle.sendline( cmd )