Add disk format argument to installation test scripts. With them, we
can test snapshot testing. The following is the conf file sample.
domain:install_linux_cdrom
guestname
test-api-guest
...
imagetype
qcow2
...
domain:shutdown
guestname
test-api-guest
snapshot:internal_create
guestname
test-api-guest
---
repos/domain/install_linux_cdrom.py | 23 ++++++++++-----
repos/domain/install_linux_net.py | 50 +++++++++++++++++----------------
repos/domain/install_windows_cdrom.py | 23 ++++++++++-----
3 files changed, 56 insertions(+), 40 deletions(-)
diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py
index 7e8fee9..8d21797 100644
--- a/repos/domain/install_linux_cdrom.py
+++ b/repos/domain/install_linux_cdrom.py
@@ -8,6 +8,7 @@
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -70,6 +71,7 @@ def usage():
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -86,7 +88,7 @@ def check_params(params):
mandatory_args = ['guestname', 'guesttype', 'guestos', 'guestarch']
optional_args = ['memory', 'vcpu', 'disksize', 'imagepath', 'hdmodel',
'nicmodel', 'macaddr', 'ifacetype', 'source', 'type',
- 'volumepath']
+ 'volumepath', 'imagetype']
for arg in mandatory_args:
if arg not in params_given.keys():
@@ -255,7 +257,7 @@ def install_linux_cdrom(params):
logger.debug("the uri to connect is %s" % uri)
if params.has_key('imagepath') and not params.has_key('volumepath'):
- imgfullpath = os.join.path(params.get('imagepath'), guestname)
+ imgfullpath = os.path.join(params.get('imagepath'), guestname)
elif not params.has_key('imagepath') and not params.has_key('volumepath'):
if hypervisor == 'xen':
@@ -280,13 +282,18 @@ def install_linux_cdrom(params):
else:
seeksize = '10'
- logger.info("the size of disk image is %sG" % (seeksize))
- shell_disk_dd = "dd if=/dev/zero of=%s bs=1 count=1 seek=%sG" % \
- (imgfullpath, seeksize)
- logger.debug("the commands line of creating disk images is '%s'" %
- shell_disk_dd)
+ if params.has_key('imagetype'):
+ imagetype = params.get('imagetype')
+ else:
+ imagetype = 'raw'
+
+ logger.info("create disk image with size %sG, format %s" % (seeksize, imagetype))
+ disk_create = "qemu-img create -f %s %s %sG" % \
+ (imagetype, imgfullpath, seeksize)
+ logger.debug("the commands line of creating disk images is '%s'" % \
+ disk_create)
- (status, message) = commands.getstatusoutput(shell_disk_dd)
+ (status, message) = commands.getstatusoutput(disk_create)
if status != 0:
logger.debug(message)
diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py
index 21ae378..1b0470e 100644
--- a/repos/domain/install_linux_net.py
+++ b/repos/domain/install_linux_net.py
@@ -9,6 +9,7 @@
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -72,6 +73,7 @@ def usage():
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -88,7 +90,8 @@ def check_params(params):
'guestarch','netmethod']
optional_args = ['memory', 'vcpu', 'disksize', 'imagepath',
- 'hdmodel', 'nicmodel', 'ifacetype', 'source', 'type']
+ 'hdmodel', 'nicmodel', 'ifacetype',
+ 'imagetype', 'source', 'type']
for arg in mandatory_args:
if arg not in params_given.keys():
@@ -233,7 +236,7 @@ def install_linux_net(params):
logger.debug("the uri to connect is %s" % uri)
if params.has_key('imagepath'):
- fullimagepath = os.join.path(params.get('imagepath'), guestname)
+ fullimagepath = os.path.join(params.get('imagepath'), guestname)
else:
if hypervisor == 'xen':
fullimagepath = os.path.join('/var/lib/xen/images', guestname)
@@ -246,29 +249,28 @@ def install_linux_net(params):
fullimagepath)
if params.has_key('disksize'):
- logger.info("the size of disk image is %sG" % (params.get('disksize')))
- shell_disk_dd = "dd if=/dev/zero of=%s bs=1 count=1 seek=%sG" % \
- (fullimagepath, params.get('disksize'))
- logger.debug("the commands line of creating disk images is '%s'" %
- shell_disk_dd)
-
- (status, message) = commands.getstatusoutput(shell_disk_dd)
- if status != 0:
- logger.debug(message)
- else:
- logger.info("creating disk images file is successful.")
+ seeksize = params.get('disksize')
else:
- logger.info("the size of disk image is 10G")
- shell_disk_dd = "dd if=/dev/zero of=%s bs=1 count=1 seek=10G" % \
- fullimagepath
- logger.debug("the commands line of creating disk images is '%s'" %
- shell_disk_dd)
-
- (status, message) = commands.getstatusoutput(shell_disk_dd)
- if status != 0:
- logger.debug(message)
- else:
- logger.info("creating disk images file is successful.")
+ seeksize = '10'
+
+ if params.has_key('imagetype'):
+ imagetype = params.get('imagetype')
+ else:
+ imagetype = 'raw'
+
+ logger.info("create disk image with size %sG, format %s" % (seeksize, imagetype))
+ disk_create = "qemu-img create -f %s %s %sG" % \
+ (imagetype, fullimagepath, seeksize)
+ logger.debug("the commands line of creating disk images is '%s'" % \
+ disk_create)
+
+ (status, message) = commands.getstatusoutput(disk_create)
+
+ if status != 0:
+ logger.debug(message)
+ else:
+ logger.info("creating disk images file is successful.")
+
logger.info("get system environment information")
envfile = os.path.join(homepath, 'env.cfg')
diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py
index 2ea0ee7..9cf9e3b 100644
--- a/repos/domain/install_windows_cdrom.py
+++ b/repos/domain/install_windows_cdrom.py
@@ -8,6 +8,7 @@
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -68,6 +69,7 @@ def usage():
optional arguments: memory
vcpu
disksize
+ imagetype
imagepath
hdmodel
nicmodel
@@ -89,7 +91,7 @@ def check_params(params):
mandatory_args = ['guestname', 'guesttype', 'guestos', 'guestarch']
optional_args = ['memory', 'vcpu', 'disksize', 'imagepath', 'hdmodel',
'nicmodel', 'macaddr', 'ifacetype', 'source', 'type',
- 'volumepath']
+ 'volumepath', 'imagetype']
for arg in mandatory_args:
if arg not in params_given.keys():
@@ -294,7 +296,7 @@ def install_windows_cdrom(params):
logger.debug("the uri to connect is %s" % uri)
if params.has_key('imagepath') and not params.has_key('volumepath'):
- imgfullpath = os.join.path(params.get('imagepath'), guestname)
+ imgfullpath = os..path.join(params.get('imagepath'), guestname)
elif not params.has_key('imagepath') and not params.has_key('volumepath'):
if hypervisor == 'xen':
imgfullpath = os.path.join('/var/lib/xen/images', guestname)
@@ -318,13 +320,18 @@ def install_windows_cdrom(params):
else:
seeksize = '20'
- logger.info("the size of disk image is %sG" % (seeksize))
- shell_disk_dd = "dd if=/dev/zero of=%s bs=1 count=1 seek=%sG" % \
- (imgfullpath, seeksize)
- logger.debug("the commands line of creating disk images is '%s'" %
- shell_disk_dd)
+ if params.has_key('imagetype'):
+ imagetype = params.get('imagetype')
+ else:
+ imagetype = 'raw'
+
+ logger.info("create disk image with size %sG, format %s" % (seeksize, imagetype))
+ disk_create = "qemu-img create -f %s %s %sG" % \
+ (imagetype, imgfullpath, seeksize)
+ logger.debug("the commands line of creating disk images is '%s'" % \
+ disk_create)
- (status, message) = commands.getstatusoutput(shell_disk_dd)
+ (status, message) = commands.getstatusoutput(disk_create)
if status != 0:
logger.debug(message)