[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [test-API PATCH] use global variable domain_cache_folder to as cache folder for guest install



---
 global.cfg                          |   15 +++++++++------
 repos/domain/install_linux_cdrom.py |   22 ++++++++++------------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/global.cfg b/global.cfg
index 6cfdcac..7b7b7cb 100644
--- a/global.cfg
+++ b/global.cfg
@@ -142,6 +143,8 @@ defaultnic = virtio
 static_uuid = 05867c1a-afeb-300e-e55e-2673391ae080
 # path to a disk image containing a preinstalled guest for testing
 testfullimagepath = /var/lib/libvirt/images/f14.img
+# path to store temporary iso and kickstart file
+domain_cache_folder = /var/cache/libvirt-test-api
 
 ################################################################
 #
diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py
index 60d12a7..f70ebc3 100644
--- a/repos/domain/install_linux_cdrom.py
+++ b/repos/domain/install_linux_cdrom.py
@@ -36,18 +36,16 @@ VM_STAT = "virsh --quiet list --all| grep \"\\b%s\\b\"|grep off"
 VM_DESTROY = "virsh destroy %s"
 VM_UNDEFINE = "virsh undefine %s"
 
-BOOT_DIR = "/var/lib/libvirt/boot/"
 HOME_PATH = os.getcwd()
 
-def prepare_cdrom(*args):
+def prepare_cdrom(ostree, ks, guestname, cache_folder, logger):
     """ to customize boot.iso file to add kickstart
         file into it for automatic guest installation
     """
-    ostree, ks, guestname, logger = args
     ks_name = os.path.basename(ks)
 
-    new_dir = os.path.join(HOME_PATH, guestname)
-    logger.info("creating a new folder for customizing custom.iso file in it")
+    new_dir = os.path.join(cache_folder, guestname)
+    logger.info("creating a workshop folder for customizing custom.iso file")
 
     if os.path.exists(new_dir):
         logger.info("the folder exists, remove it")
@@ -68,7 +66,7 @@ def prepare_cdrom(*args):
     shutil.copy('utils/ksiso.sh', new_dir)
     src_path = os.getcwd()
 
-    logger.info("enter into the workshop folder: %s" % new_dir)
+    logger.debug("enter folder: %s" % new_dir)
     os.chdir(new_dir)
     shell_cmd = 'sh ksiso.sh %s' % ks_name
 
@@ -76,8 +74,8 @@ def prepare_cdrom(*args):
     (status, text) = commands.getstatusoutput(shell_cmd)
 
     logger.debug(text)
-    logger.info("make custom.iso file, change to original directory: %s" %
-                src_path)
+
+    logger.debug("go back to original directory: %s" % src_path)
     os.chdir(src_path)
 
 def prepare_boot_guest(domobj, xmlstr, guestname, installtype, logger):
@@ -194,13 +192,13 @@ def install_linux_cdrom(params):
     logger.debug('kisckstart file: \n    %s' % ks)
 
     logger.info('prepare installation...')
+    cache_folder = envparser.get_value("variables", "domain_cache_folder")
 
-    bootcd = '%s/custom.iso' % \
-                       (os.path.join(HOME_PATH, guestname))
-    logger.debug("the bootcd path is %s" % bootcd)
     logger.info("begin to customize the custom.iso file")
-    prepare_cdrom(ostree, ks, guestname, logger)
+    prepare_cdrom(ostree, ks, guestname, cache_folder, logger)
 
+    bootcd = '%s/custom.iso' % \
+                       (os.path.join(cache_folder, guestname))
     xmlstr = xmlstr.replace('CUSTOMISO', bootcd)
 
     logger.debug('dump installation guest xml:\n%s' % xmlstr)
-- 
1.7.7.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]