testing link stuff

This commit is contained in:
cody burkard
2014-08-01 11:00:07 -07:00
parent f67a7b64c8
commit c1934706bb
4 changed files with 35 additions and 9 deletions
+22 -4
View File
@@ -86,6 +86,7 @@ class Intf( object ):
def updateMAC( self ):
"Return updated MAC address based on ifconfig"
#heres where we send the unecessary ifconfigs
ifconfig = self.ifconfig()
macs = self._macMatchRegex.findall( ifconfig )
self.mac = macs[ 0 ] if macs else None
@@ -102,8 +103,13 @@ class Intf( object ):
def isUp( self, setUp=False ):
"Return whether interface is up"
if setUp:
self.ifconfig( 'up' )
return "UP" in self.ifconfig()
r = self.ifconfig( 'up' )
if r:
return False
else:
return True
else:
return "UP" in self.ifconfig()
def rename( self, newname ):
"Rename interface"
@@ -138,6 +144,16 @@ class Intf( object ):
results[ name ] = result
return result
def updateAddr( self ):
"instead of updating ip and mac separately, use one ifconfig call to do it simultaneously"
ifconfig = self.ifconfig()
print ifconfig
ips = self._ipMatchRegex.findall( ifconfig )
macs = self._macMatchRegex.findall( ifconfig )
self.ip = ips[ 0 ] if ips else None
self.mac = macs[ 0 ] if macs else None
return self.ip, self.mac
def config( self, mac=None, ip=None, ifconfig=None,
up=True, **_params ):
"""Configure Node according to (optional) parameters:
@@ -154,8 +170,10 @@ class Intf( object ):
self.setParam( r, 'setIP', ip=ip )
self.setParam( r, 'isUp', up=up )
self.setParam( r, 'ifconfig', ifconfig=ifconfig )
self.updateIP()
self.updateMAC()
#should combine these next two operations into one. this is unecessary
#self.updateAddr()
#self.updateIP()
#self.updateMAC()
return r
def delete( self ):