#!/usr/bin/python
#
-# Copyright (c) Citrix Systems 2008. All rights reserved.
+# Copyright (c) 2008,2009 Citrix Systems, Inc. All rights reserved.
# Copyright (c) 2009 Nicira Networks.
#
"""Usage:
def get_netdev_by_mac(mac):
maybe = None
for device in os.listdir("/sys/class/net"):
- dev_mac = get_netdev_by_mac(device)
+ dev_mac = get_netdev_mac(device)
if dev_mac and mac.lower() == dev_mac.lower():
if get_netdev_tx_queue_len(device):
return device
else:
raise Error("Unknown IP-configuration-mode %s" % pifrec['ip_configuration_mode'])
- oc = {}
- if pifrec.has_key('other_config'):
- oc = pifrec['other_config']
- if oc.has_key('mtu'):
+ oc = pifrec['other_config']
+ if oc.has_key('mtu'):
+ try:
int(oc['mtu']) # Check that the value is an integer
ifconfig_argv += ['mtu', oc['mtu']]
+ except ValueError, x:
+ log("Invalid value for mtu = %s" % mtu)
run_command(ifconfig_argv)
argv = ['--del-match=bonding.%s.[!0-9]*' % interface]
argv += ["--add=bonding.%s.slave=%s" % (interface, slave)
for slave in physdevs]
+ argv += ['--add=bonding.%s.fake-iface=true']
if pifrec['MAC'] != "":
argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]