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

Justin Pettit jpettit at nicira.com
Wed Aug 19 21:09:04 UTC 2009


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.  What  
about just making it a general "except", so that it's not specific to  
IO exceptions?

Otherwise, it looks good to me.

--Justin






More information about the discuss mailing list