diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-08-11 16:51:02 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-08-11 16:51:02 +0100 |
commit | 87122426932d27d494110515af31c676eccc77dc (patch) | |
tree | 769dc15d8043498de88fe18a338da807f6eac3a5 | |
parent | f1c9b3b6c14abda28089fb13196dbbe09b6c8b0f (diff) | |
download | xen-87122426932d27d494110515af31c676eccc77dc.tar.gz xen-87122426932d27d494110515af31c676eccc77dc.tar.bz2 xen-87122426932d27d494110515af31c676eccc77dc.zip |
xend/xenapi: Initialize a VLAN PIF's record with the MAC and MTU size
of the created network interface
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
-rw-r--r-- | tools/python/xen/xend/XendPIF.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/python/xen/xend/XendPIF.py b/tools/python/xen/xend/XendPIF.py index ee39ec5413..2a2e78acc2 100644 --- a/tools/python/xen/xend/XendPIF.py +++ b/tools/python/xen/xend/XendPIF.py @@ -95,6 +95,22 @@ def linux_set_mtu(iface, mtu): except ValueError: return False +def linux_get_mtu(device): + return _linux_get_pif_param(device, 'mtu') + +def linux_get_mac(device): + return _linux_get_pif_param(device, 'link/ether') + +def _linux_get_pif_parm(device, param_name): + ip_get_dev_data = 'ip link show %s' % device + rc, output = commands.getstatusoutput(ip_get_dev_data) + if rc == 0: + params = output.split(' ') + for i in xrange(len(params)): + if params[i] == param_name: + return params[i+1] + return '' + def _create_VLAN(dev, vlan): rc, _ = commands.getstatusoutput('vconfig add %s %d' % (dev, vlan)) @@ -259,8 +275,8 @@ class XendPIF(XendBase): # Create the record record = { "device": device, - "MAC": '', - "MTU": '', + "MAC": linux_get_mac('%s.%d' % (device, vlan)), + "MTU": linux_get_mtu('%s.%d' % (device, vlan)), "network": network_uuid, "VLAN": vlan } |