Revision 9281719d mininet/net.py

View differences:

mininet/net.py
237 237
    def __iter__( self ):
238 238
        "return iterator over nodes"
239 239
        #or dow we want to iterate of the keys i.e. node.name like a dict
240
        return chain( self.hosts, self.switches, self.controllers )
240
        for node in chain( self.hosts, self.switches, self.controllers ):
241
            yield node.name
241 242

  
242 243
    def __len__( self ):
244
        "returns number of nodes in net"
243 245
        return len( self.hosts ) + len( self.switches ) + len( self.controllers )
244 246

  
245 247
    def __contains__( self, item ):
248
        "returns True if net contains named node"
246 249
        return item in self.keys()
247 250

  
248 251
    def keys( self ):
249
        return [ node.name for node in self.__iter__() ]
252
        "return a list of all node names or net's keys"
253
        return list( self.__iter__() )
250 254

  
251 255
    def values( self ):
252
        return list( self.__iter__() )
256
        "return a list of all nodes or net's values"
257
        return [ self[name] for name in self.__iter__() ]
253 258

  
254 259
    def items( self ):
260
        "return (key,value) tuple list for every node in net"
255 261
        return zip( self.keys(), self.values() )
256 262

  
257 263
    def addLink( self, node1, node2, port1=None, port2=None,

Also available in: Unified diff