Dan Kenigsberg has posted comments on this change.

Change subject: Don't crash on libvirt network re-definition.
......................................................................


Patch Set 2: (3 inline comments)

....................................................
File vdsm/configNetwork.py
Line 403: 
Line 404:     @classmethod
Line 405:     def ifcfgPorts(cls, network):
Line 406:         ports = []
Line 407:         for file_path in glob.glob(netinfo.NET_CONF_PREF + '*'):
iglob is a bit cooler
Line 408:             with open(file_path, 'r') as conf_file:
Line 409:                 if ('BRIDGE=' + 'network') in conf_file.read():
Line 410:                     ports.append(file_path[file_path.rindex('-') + 
1:])
Line 411:         return ports


Line 405:     def ifcfgPorts(cls, network):
Line 406:         ports = []
Line 407:         for file_path in glob.glob(netinfo.NET_CONF_PREF + '*'):
Line 408:             with open(file_path, 'r') as conf_file:
Line 409:                 if ('BRIDGE=' + 'network') in conf_file.read():
using line.startswith() is safer and quicker.
Line 410:                     ports.append(file_path[file_path.rindex('-') + 
1:])
Line 411:         return ports
Line 412: 
Line 413:     def writeConfFile(self, fileName, configuration):


Line 1370:                     # If the network was not in _netinfo but is in 
the networks
Line 1371:                     # returned by libvirt, it means that we are 
dealing with
Line 1372:                     # a broken network.
Line 1373:                     logger.debug('Removing broken network %r' % 
network)
Line 1374:                     # Prepare a custom netinfo instance
the comment is a bit obvious - it would be much more interesting to tell *why* 
you need to fake netinfo for the following delNetwork() call.

Would wrapping this ugly hack in a function called "_delBrokenNetwork" (better 
find a better name...) make it more localized.
Line 1375:                     _customNetinfo = netinfo.NetInfo()
Line 1376:                     _customNetinfo.networks[network] = 
libvirt_nets[network]
Line 1377:                     if _customNetinfo.networks[network]['bridged']:
Line 1378:                         _customNetinfo.networks[network]['ports'] = \


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I76d95e20b7aa99280e604abdb1663c6c5c7dd32e
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Igor Lvovsky <[email protected]>
Gerrit-Reviewer: Livnat Peer <[email protected]>
Gerrit-Reviewer: Mark Wu <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to