[ovs-discuss] [nic19-2 v2] xenserver: Fix "brctl show" compatibility by introducing "brctl" wrapper.

Ben Pfaff blp at nicira.com
Wed Aug 19 21:15:06 UTC 2009


Justin Pettit <jpettit at nicira.com> writes:

> On Aug 19, 2009, at 1:53 PM, Ben Pfaff wrote:
>
>> +# Returns a bridge ID constructed from the MAC address of network
>> device
>> +# 'netdev', in the format "8000.000102030405".
>> +def get_bridge_id(netdev):
>> +    try:
>> +        hwaddr = read_first_line_of_file("/sys/class/net/%s/
>> address" % netdev)
>> +        return "8000.%s" % (hwaddr.replace(":", ""))
>> +    except IOError, e:
>> +        return "8000.002320ffffff"
>
> I'm probably overly paranoid, but it's possible for
> read_first_line_of_file() to return None if the file is empty.  

When does the None come from?  file.readline() returns "" if it
hits EOF immediately, according to the library reference.

> What about just making it a general "except", so that it's not
> specific to IO exceptions?

I suppose that couldn't hurt.  OK, I made that change.




More information about the discuss mailing list