Fix setDefaultRoute to work with passed parameters.

This commit is contained in:
Bob Lantz
2013-06-25 12:51:43 -07:00
parent 9aaf87c19b
commit 12758046e1
+4 -8
View File
@@ -371,7 +371,7 @@ class Node( object ):
""" """
if not intf: if not intf:
return self.defaultIntf() return self.defaultIntf()
elif type( intf) is str: elif type( intf ) is str:
return self.nameToIntf[ intf ] return self.nameToIntf[ intf ]
else: else:
return intf return intf
@@ -420,16 +420,12 @@ class Node( object ):
"""Set the default route to go through intf. """Set the default route to go through intf.
intf: Intf or {dev <intfname> via <gw-ip> ...}""" intf: Intf or {dev <intfname> via <gw-ip> ...}"""
# Note setParam won't call us if intf is none # Note setParam won't call us if intf is none
# See if interface is an actual interface if type( intf ) is str and ' ' in intf:
intf = self.intf( intf )
if intf in self.ports:
params = 'dev %s' % intf
elif type( intf ) is str:
params = intf params = intf
else: else:
raise ValueError( 'intf or param string required' ) params = 'dev %s' % intf
self.cmd( 'ip route del default' ) self.cmd( 'ip route del default' )
return self.cmd( 'ip route add default dev %s' % intf ) return self.cmd( 'ip route add default', params )
# Convenience and configuration methods # Convenience and configuration methods