@@ -50,20 +50,29 @@ def add_route(self, dev, address):
5050 """ Wrapper method that adds table name and device to route statement """
5151 # ip route add dev eth1 table Table_eth1 10.0.2.0/24
5252 table = self .get_tablename (dev )
53- logging .info ("Adding route: dev " + dev + " table: " +
54- table + " network: " + address + " if not present" )
55- cmd = "dev %s table %s %s" % (dev , table , address )
56- cmd = "default via %s table %s proto static" % (address , table )
57- self .set_route (cmd )
53+
54+ if not table or not address :
55+ empty_param = "table" if not table else "address"
56+ logging .info ("Empty parameter received %s while trying to add route, skipping" % empty_param )
57+ else :
58+ logging .info ("Adding route: dev " + dev + " table: " +
59+ table + " network: " + address + " if not present" )
60+ cmd = "default via %s table %s proto static" % (address , table )
61+ self .set_route (cmd )
5862
5963 def add_network_route (self , dev , address ):
6064 """ Wrapper method that adds table name and device to route statement """
6165 # ip route add dev eth1 table Table_eth1 10.0.2.0/24
6266 table = self .get_tablename (dev )
63- logging .info ("Adding route: dev " + dev + " table: " +
64- table + " network: " + address + " if not present" )
65- cmd = "throw %s table %s proto static" % (address , table )
66- self .set_route (cmd )
67+
68+ if not table or not address :
69+ empty_param = "table" if not table else "address"
70+ logging .info ("Empty parameter received %s while trying to add network route, skipping" % empty_param )
71+ else :
72+ logging .info ("Adding route: dev " + dev + " table: " +
73+ table + " network: " + address + " if not present" )
74+ cmd = "throw %s table %s proto static" % (address , table )
75+ self .set_route (cmd )
6776
6877 def set_route (self , cmd , method = "add" ):
6978 """ Add a route if it is not already defined """
0 commit comments