From 908f572b34805c77b40c3890f2caa370561f8867 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Fri, 27 Apr 2012 16:44:11 -0400 Subject: [PATCH] Finish necessary changes related to jeos_create move As a result of moving jeos_create, the code is now used during test execution. The library libxml2 which was previously being used is not available in pip, so lxml has been swapped instead. Signed-off-by: Jeff Peeler --- bin/heat | 2 +- heat/utils.py | 12 +++++------- tools/pip-requires | 7 +++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/heat b/bin/heat index 51f112d..6c81229 100755 --- a/bin/heat +++ b/bin/heat @@ -270,7 +270,7 @@ def jeos_create(options, arguments): The command must be run as root in order for libvirt to have permissions to create virtual machines and read the raw DVDs. ''' - utils.jeos_create(options, arguments) + utils.jeos_create(options, arguments, jeos_path, cfntools_path) def get_client(options): diff --git a/heat/utils.py b/heat/utils.py index 5d7e153..0691d24 100644 --- a/heat/utils.py +++ b/heat/utils.py @@ -17,7 +17,7 @@ import functools import os import sys import base64 -import libxml2 +from lxml import etree import re import logging @@ -59,7 +59,7 @@ def catch_error(action): @catch_error('jeos_create') -def jeos_create(options, arguments): +def jeos_create(options, arguments, jeos_path, cfntools_path): ''' Create a new JEOS (Just Enough Operating System) image. @@ -74,8 +74,6 @@ def jeos_create(options, arguments): The command must be run as root in order for libvirt to have permissions to create virtual machines and read the raw DVDs. ''' - global jeos_path - global cfntools_path # if not running as root, return EPERM to command line if os.geteuid() != 0: @@ -136,7 +134,7 @@ def jeos_create(options, arguments): # Load the cfntools into the cfntool image by encoding them in base64 # and injecting them into the TDL at the appropriate place if instance_type == 'cfntools': - tdl_xml = libxml2.parseFile(tdl_path) + tdl_xml = etree.parse(tdl_path) cfn_tools = ['cfn-init', 'cfn-hup', 'cfn-signal', \ 'cfn-get-metadata', 'cfn_helper.py'] for cfnname in cfn_tools: @@ -144,10 +142,10 @@ def jeos_create(options, arguments): cfscript_e64 = base64.b64encode(f.read()) f.close() cfnpath = "/template/files/file[@name='/opt/aws/bin/%s']" % cfnname - tdl_xml.xpathEval(cfnpath)[0].setContent(cfscript_e64) + tdl_xml.xpath(cfnpath)[0].text = cfscript_e64 # TODO(sdake) INSECURE - tdl_xml.saveFormatFile('/tmp/tdl', format=1) + tdl_xml.write('/tmp/tdl', xml_declaration=True) tdl_path = '/tmp/tdl' dsk_filename = '%s/%s-%s-%s-jeos.dsk' % (images_dir, distro, diff --git a/tools/pip-requires b/tools/pip-requires index 4e4802e..a364bcf 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -16,3 +16,10 @@ httplib2 kombu iso8601>=0.1.4 python-novaclient +glance + +# Note you will need gcc buildtools installed and must +# have installed libxml headers for lxml to be successfully +# installed using pip, therefore you will need to install the +# libxml2-dev(el) and libxslt-dev(el) packages. +lxml