From 9f29146f773a3b85401a6fec4a198b9f1be9c0fa Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 11 Apr 2012 23:54:18 +0200 Subject: [PATCH] check for the xml template first thing, show filename if missing --- sliver_lxc.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sliver_lxc.py b/sliver_lxc.py index 4f78d39..8e936fb 100644 --- a/sliver_lxc.py +++ b/sliver_lxc.py @@ -47,6 +47,16 @@ class Sliver_LXC(lv.Sliver_Libvirt): logger.log('sliver_lxc: %s: ERROR ctd expected reference image in %s'%(name,refImgDir)) return + # Template for libvirt sliver configuration + template_filename = Sliver_LXC.REF_IMG_BASE_DIR + '/config_template.xml' + try: + with open(template_filename) as f: + template = Template(f.read()) + xml = template.substitute(name=name, xid=xid) + except IOError: + logger.log('Cannot find XML template file %s'%template_filename) + return + # Snapshot the reference image fs (assume the reference image is in its own # subvolume) command = ['btrfs', 'subvolume', 'snapshot', refImgDir, containerDir] @@ -89,15 +99,6 @@ class Sliver_LXC(lv.Sliver_Libvirt): # can get the correct xid based on the name of the slice xid = bwlimit.get_xid(name) - # Template for libvirt sliver configuration - try: - with open(Sliver_LXC.REF_IMG_BASE_DIR + '/config_template.xml') as f: - template = Template(f.read()) - xml = template.substitute(name=name, xid=xid) - except IOError: - logger.log('Cannot find XML template file') - return - # Lookup for the sliver before actually # defining it, just in case it was already defined. try: -- 2.43.0