removed many of the commands being run to maximize startup performance

This commit is contained in:
cody burkard
2014-08-01 11:00:07 -07:00
parent c1934706bb
commit eba13f0ca8
4 changed files with 46 additions and 22 deletions
+11 -10
View File
@@ -32,7 +32,7 @@ class Intf( object ):
"Basic interface object that can configure itself."
def __init__( self, name, node=None, port=None, link=None, **params ):
def __init__( self, name, node=None, port=None, link=None, mac=None, **params ):
"""name: interface name (e.g. h1-eth0)
node: owning node (where this intf most likely lives)
link: parent link if we're part of a link
@@ -40,7 +40,10 @@ class Intf( object ):
self.node = node
self.name = name
self.link = link
self.mac, self.ip, self.prefixLen = None, None, None
self.mac = mac
self.ip, self.prefixLen = None, None
if self.name == 'lo':
self.ip = '127.0.0.1'
# Add to node (and move ourselves if necessary )
node.addIntf( self, port=port )
# Save params for future reference
@@ -147,7 +150,6 @@ class Intf( object ):
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
@@ -170,7 +172,6 @@ class Intf( object ):
self.setParam( r, 'setIP', ip=ip )
self.setParam( r, 'isUp', up=up )
self.setParam( r, 'ifconfig', ifconfig=ifconfig )
#should combine these next two operations into one. this is unecessary
#self.updateAddr()
#self.updateIP()
#self.updateMAC()
@@ -339,7 +340,7 @@ class Link( object ):
Other types of links could be tunnels, link emulators, etc.."""
def __init__( self, node1, node2, port1=None, port2=None,
intfName1=None, intfName2=None,
intfName1=None, intfName2=None, addr1=None, addr2=None,
intf=Intf, cls1=None, cls2=None, params1=None,
params2=None ):
"""Create veth link to another node, making two new interfaces.
@@ -365,7 +366,7 @@ class Link( object ):
if not intfName2:
intfName2 = self.intfName( node2, port2 )
self.makeIntfPair( intfName1, intfName2 )
self.makeIntfPair( intfName1, intfName2, addr1, addr2 )
if not cls1:
cls1 = intf
@@ -377,9 +378,9 @@ class Link( object ):
params2 = {}
intf1 = cls1( name=intfName1, node=node1, port=port1,
link=self, **params1 )
link=self, mac=addr1, **params1 )
intf2 = cls2( name=intfName2, node=node2, port=port2,
link=self, **params2 )
link=self, mac=addr2, **params2 )
# All we are is dust in the wind, and our two interfaces
self.intf1, self.intf2 = intf1, intf2
@@ -390,13 +391,13 @@ class Link( object ):
return node.name + '-eth' + repr( n )
@classmethod
def makeIntfPair( cls, intf1, intf2 ):
def makeIntfPair( cls, intf1, intf2, addr1=None, addr2=None ):
"""Create pair of interfaces
intf1: name of interface 1
intf2: name of interface 2
(override this class method [and possibly delete()]
to change link type)"""
makeIntfPair( intf1, intf2 )
makeIntfPair( intf1, intf2, addr1, addr2 )
def delete( self ):
"Delete this link"