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 <jpeeler@redhat.com>
This commit is contained in:
Jeff Peeler 2012-04-27 16:44:11 -04:00
parent 4fa77a658c
commit 908f572b34
3 changed files with 13 additions and 8 deletions

View File

@ -270,7 +270,7 @@ def jeos_create(options, arguments):
The command must be run as root in order for libvirt to have permissions The command must be run as root in order for libvirt to have permissions
to create virtual machines and read the raw DVDs. 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): def get_client(options):

View File

@ -17,7 +17,7 @@ import functools
import os import os
import sys import sys
import base64 import base64
import libxml2 from lxml import etree
import re import re
import logging import logging
@ -59,7 +59,7 @@ def catch_error(action):
@catch_error('jeos_create') @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. 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 The command must be run as root in order for libvirt to have permissions
to create virtual machines and read the raw DVDs. 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 not running as root, return EPERM to command line
if os.geteuid() != 0: 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 # Load the cfntools into the cfntool image by encoding them in base64
# and injecting them into the TDL at the appropriate place # and injecting them into the TDL at the appropriate place
if instance_type == 'cfntools': 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_tools = ['cfn-init', 'cfn-hup', 'cfn-signal', \
'cfn-get-metadata', 'cfn_helper.py'] 'cfn-get-metadata', 'cfn_helper.py']
for cfnname in cfn_tools: for cfnname in cfn_tools:
@ -144,10 +142,10 @@ def jeos_create(options, arguments):
cfscript_e64 = base64.b64encode(f.read()) cfscript_e64 = base64.b64encode(f.read())
f.close() f.close()
cfnpath = "/template/files/file[@name='/opt/aws/bin/%s']" % cfnname 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 # TODO(sdake) INSECURE
tdl_xml.saveFormatFile('/tmp/tdl', format=1) tdl_xml.write('/tmp/tdl', xml_declaration=True)
tdl_path = '/tmp/tdl' tdl_path = '/tmp/tdl'
dsk_filename = '%s/%s-%s-%s-jeos.dsk' % (images_dir, distro, dsk_filename = '%s/%s-%s-%s-jeos.dsk' % (images_dir, distro,

View File

@ -16,3 +16,10 @@ httplib2
kombu kombu
iso8601>=0.1.4 iso8601>=0.1.4
python-novaclient 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