Change in vdsm[master]: Return the result directly instead of generator when getting...

mhuntxu at gmail.com mhuntxu at gmail.com
Fri Feb 22 10:32:11 UTC 2013


Hunt Xu has posted comments on this change.

Change subject: Return the result directly instead of generator when getting network for interface
......................................................................


Patch Set 2: (1 inline comment)

....................................................
File vdsm/netinfo.py
Line 476:         network = self.getBridgelessNetworkForIface(iface)
Line 477:         if network is not None:
Line 478:             return network
Line 479:         else:
Line 480:             return self.getBridgedNetworkForIface(iface)
I don't think we really need to iterate the self.network dict twice though I have no idea about how much it affects the performance.

IMO we could move the iteration here(unpep8ed):

def getNetworkForIface(self, iface):
    for network, netdict in self.networks.iteritems():
        if (not netdict['bridged'] and iface == netdict['iface']) or (netdict['bridged'] and iface in netdict['ports']):
            return network

Or even to simplify the if statement to:
  if iface == netdict['iface'] or 'ports' in netdict and iface in netdict['ports']

Thus whether to remove getBridge{d,less}NetworkForIface depends on whether we are keeping them for future usage.
Line 481: 
Line 482:     def getBridgelessNetworks(self):
Line 483:         """ Return all bridgless networks."""
Line 484:         for network, netdict in self.networks.iteritems():


--
To view, visit http://gerrit.ovirt.org/9737
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I80c47d0f0df70de73993ef0c09f69cbf882f6629
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Hunt Xu <mhuntxu at gmail.com>
Gerrit-Reviewer: Igor Lvovsky <ilvovsky at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list