Antoni Segura Puimedon has posted comments on this change.

Change subject: NetReload: netmodels for addNetwork
......................................................................


Patch Set 2: (5 inline comments)

....................................................
File lib/vdsm/netinfo.py
Line 132: 
Line 133:     :param mtu: mtu value
Line 134:     :type mtu: integer
Line 135: 
Line 136:     getMaxMtu return the highest value in a connection tree,
I just moved the method from ifcfg.py here. I did not plan to make changes to 
it. In any case, I'd leave those changes for a follow-up patch.
Line 137:     it check if a vlan, bond that have a higher mtu value
Line 138:     """
Line 139:     for nic in nics:
Line 140:         mtuval = int(getMtu(nic))


Line 139:     for nic in nics:
Line 140:         mtuval = int(getMtu(nic))
Line 141:         if mtuval > mtu:
Line 142:             mtu = mtuval
Line 143:     return mtu
Could you make a follow-up patch for this improvements?
Line 144: 
Line 145: 
Line 146: def bridge_stp_state(bridge):
Line 147:     stp = file('/sys/class/net/%s/bridge/stp_state' % 
bridge).readline()


Line 189:     return addr
Line 190: 
Line 191: 
Line 192: def prefix2netmask(prefix):
Line 193:     if not 0 <= prefix <= 32:
It is unchecked input from the user. I believe that it can happen. What this 
does is raise an exception that will be used to notify the user what the error 
was.
Line 194:         raise ValueError('%s is not a valid prefix value. It must be 
between '
Line 195:                          '0 and 32')
Line 196:     return socket.inet_ntoa(
Line 197:         struct.pack("!I", int('1' * prefix + '0' * (32 - prefix), 2)))


Line 193:     if not 0 <= prefix <= 32:
Line 194:         raise ValueError('%s is not a valid prefix value. It must be 
between '
Line 195:                          '0 and 32')
Line 196:     return socket.inet_ntoa(
Line 197:         struct.pack("!I", int('1' * prefix + '0' * (32 - prefix), 2)))
I did not modify that, but it is not all that obscure. Simply:

Prefix = 24 means:
twenty four '1's followed by eight '0's as a binary integer.
Line 198: 
Line 199: 
Line 200: def netmask2prefix(netmask):
Line 201:     try:


Line 202:         socket.inet_pton(socket.AF_INET, netmask)
Line 203:     except socket.error:
Line 204:         raise ValueError('%s is not a valid netmask.' % netmask)
Line 205:     num = struct.unpack("!I", socket.inet_aton(netmask))[0]
Line 206:     if num & (num - 1) != (num << 1) & 0xffffffff:
It is code moved from already existing validateNetmask code that was on 
configNetworks. It simply checks that the number is a binary made of 1s 
followed by zeroes. I'm not agains of moving it into a method, now that it is 
used in two places (here and in netmodels).
Line 207:         raise ValueError("%s is not a valid netmask." % netmask)
Line 208:     return bin(num)[2:].index('0')
Line 209: 
Line 210: 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iba5c5b84760e27245cbe34c3b290c54e51278e72
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegu...@redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegu...@redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvall...@redhat.com>
Gerrit-Reviewer: Mark Wu <wu...@linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to