From: Ewan Mellor Subject: Re: [PATCH] pypxeboot bootloader Date: Mon, 5 Feb 2007 17:57:53 +0000 Message-ID: <20070205175752.GA6150@leeni.uk.xensource.com> References: <45C7114E.10207@cs.tcd.ie> <20070205173612.GH5181@york.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20070205173612.GH5181@york.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Tim Deegan Cc: xen-devel@lists.xensource.com, Stephen Childs List-Id: xen-devel@lists.xenproject.org On Mon, Feb 05, 2007 at 05:36:12PM +0000, Tim Deegan wrote: > Hi, > > At 11:13 +0000 on 05 Feb (1170673998), Stephen Childs wrote: > > As promised on Friday here is the patch for the pypxeboot bootloader. It > > would be great if someone could try it out and give me some feedback. > > First impressions: this looks really useful but has a few rough edges > that need to be knocked off. (I haven't had a chance to try this on a > real machine yet.) > > > +for line in udhcplines: > > + s = line.strip() > > + f = s.split() > > + > > + if s[0]=='{' and s[-1]=='}': > > + dhcpinfo=eval(s, {"__builtins__" : {}}) > > + for k in dhcpinfo: > > + dhcpinfo[k]=dhcpinfo[k].strip() > > Executing the results of programs scares me. Could you just parse it? > > > +ipaddr=dhcpinfo['ip'] > > +ipaddrlist=ipaddr.split('.') > > +hexip=commands.getstatusoutput("/usr/bin/gethostip -x "+ipaddr)[1] > > This requires syslinux to be installed on the Xen host, and isn't > hard to do by hand: "%2.2x%2.2x%2.2x%2.2x" % tuple(map (int, ipaddrlist)) > (I'm sure more heavyweight python hackers can correct my style.) (4 * "%2.2x") % tuple(map (int, ipaddrlist)) or "".join(["%2.2x" % int(i) for i in ipaddrlist]) Both are pleasingly arcane... Ewan.