Revision c1934706 mininet/link.py

View differences:

mininet/link.py
86 86

  
87 87
    def updateMAC( self ):
88 88
        "Return updated MAC address based on ifconfig"
89
        #heres where we send the unecessary ifconfigs
89 90
        ifconfig = self.ifconfig()
90 91
        macs = self._macMatchRegex.findall( ifconfig )
91 92
        self.mac = macs[ 0 ] if macs else None
......
102 103
    def isUp( self, setUp=False ):
103 104
        "Return whether interface is up"
104 105
        if setUp:
105
            self.ifconfig( 'up' )
106
        return "UP" in self.ifconfig()
106
            r = self.ifconfig( 'up' )
107
            if r:
108
                return False
109
            else:
110
                return True
111
        else:
112
            return "UP" in self.ifconfig()
107 113

  
108 114
    def rename( self, newname ):
109 115
        "Rename interface"
......
138 144
        results[ name ] = result
139 145
        return result
140 146

  
147
    def updateAddr( self ):
148
        "instead of updating ip and mac separately, use one ifconfig call to do it simultaneously"
149
        ifconfig = self.ifconfig()
150
        print ifconfig
151
        ips = self._ipMatchRegex.findall( ifconfig )
152
        macs = self._macMatchRegex.findall( ifconfig )
153
        self.ip = ips[ 0 ] if ips else None
154
        self.mac = macs[ 0 ] if macs else None
155
        return self.ip, self.mac
156

  
141 157
    def config( self, mac=None, ip=None, ifconfig=None,
142 158
                up=True, **_params ):
143 159
        """Configure Node according to (optional) parameters:
......
154 170
        self.setParam( r, 'setIP', ip=ip )
155 171
        self.setParam( r, 'isUp', up=up )
156 172
        self.setParam( r, 'ifconfig', ifconfig=ifconfig )
157
        self.updateIP()
158
        self.updateMAC()
173
        #should combine these next two operations into one. this is unecessary
174
        #self.updateAddr()
175
        #self.updateIP()
176
        #self.updateMAC()
159 177
        return r
160 178

  
161 179
    def delete( self ):

Also available in: Unified diff