ia64/xen-unstable

changeset 18312:8b1ebe5e8fd7

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>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Aug 11 16:51:02 2008 +0100 (2008-08-11)
parents f9062ba4c54f
children 96d0a48e87ee
files tools/python/xen/xend/XendPIF.py
line diff
     1.1 --- a/tools/python/xen/xend/XendPIF.py	Mon Aug 11 15:44:47 2008 +0100
     1.2 +++ b/tools/python/xen/xend/XendPIF.py	Mon Aug 11 16:51:02 2008 +0100
     1.3 @@ -95,6 +95,22 @@ def linux_set_mtu(iface, mtu):
     1.4      except ValueError:
     1.5          return False
     1.6  
     1.7 +def linux_get_mtu(device):
     1.8 +    return _linux_get_pif_param(device, 'mtu')
     1.9 +
    1.10 +def linux_get_mac(device):
    1.11 +    return _linux_get_pif_param(device, 'link/ether')
    1.12 +
    1.13 +def _linux_get_pif_parm(device, param_name):
    1.14 +    ip_get_dev_data = 'ip link show %s' % device
    1.15 +    rc, output = commands.getstatusoutput(ip_get_dev_data)
    1.16 +    if rc == 0:
    1.17 +        params = output.split(' ')
    1.18 +        for i in xrange(len(params)):
    1.19 +            if params[i] == param_name:
    1.20 +                return params[i+1]
    1.21 +    return ''
    1.22 +
    1.23  def _create_VLAN(dev, vlan):
    1.24      rc, _ = commands.getstatusoutput('vconfig add %s %d' %
    1.25                                       (dev, vlan))
    1.26 @@ -259,8 +275,8 @@ class XendPIF(XendBase):
    1.27          # Create the record
    1.28          record = {
    1.29              "device":  device,
    1.30 -            "MAC":     '',
    1.31 -            "MTU":     '',
    1.32 +            "MAC":     linux_get_mac('%s.%d' % (device, vlan)),
    1.33 +            "MTU":     linux_get_mtu('%s.%d' % (device, vlan)),
    1.34              "network": network_uuid,
    1.35              "VLAN":    vlan
    1.36              }