From: Stefan Berger Subject: [PATCH] [Xend/Xen-API] Initialize a VLAN PIF's record with the MAC and MTU size of the created network interface Date: Mon, 11 Aug 2008 11:31:47 -0400 Message-ID: <1218468707.3349.7.camel@gsal-3.watson.ibm.com> Reply-To: stefanb@us.ibm.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-BealcQfFeEbstpYbPlZR" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-BealcQfFeEbstpYbPlZR Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch initializes a physical network interface created for a VLAN with the MAC address and MTU size of the created network interface. Signed-off-by: Stefan Berger --=-BealcQfFeEbstpYbPlZR Content-Disposition: attachment; filename=pif_init_record_with_mtu_mac.diff Content-Type: text/x-patch; name=pif_init_record_with_mtu_mac.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/tools/python/xen/xend/XendPIF.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/XendPIF.py +++ root/xen-unstable.hg/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 } --=-BealcQfFeEbstpYbPlZR Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-BealcQfFeEbstpYbPlZR--