[test-API][PATCH] Add extra optional arguments for spice graphics type for installation test

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

 



Added options for 2 cases: graphtype, image, jpeg, zlib,
                           playback, streaming, clipboard
    * repos/domain/install_linux_cdrom.py
    * repos/domain/install_linux_net.py
---
 repos/domain/blkstats.py              |  103 ---------------------------------
 repos/domain/install_linux_cdrom.py   |   17 +++++-
 repos/domain/install_linux_net.py     |   18 ++++++-
 repos/domain/install_windows_cdrom.py |   17 +++++-
 utils/Python/xmlbuilder.py            |    9 +++-
 utils/Python/xmlgenerator.py          |   51 +++++++++++++++-
 6 files changed, 105 insertions(+), 110 deletions(-)
 delete mode 100644 repos/domain/blkstats.py

diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py
deleted file mode 100644
index 67592f0..0000000
--- a/repos/domain/blkstats.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/evn python
-"""this test case is used for testing domain block
-   device statistics
-   mandatory arguments: guestname
-"""
-
-__author__ = 'Alex Jia: ajia@xxxxxxxxxx'
-__date__ = 'Wed Jan 27, 2010'
-__version__ = '0.1.0'
-__credits__ = 'Copyright (C) 2009 Red Hat, Inc.'
-__all__ = ['usage', 'check_guest_status', 'check_blkstats',
-           'blkstats']
-
-import os
-import sys
-import time
-
-dir = os.path.dirname(sys.modules[__name__].__file__)
-absdir = os.path.abspath(dir)
-rootdir = os.path.split(os.path.split(absdir)[0])[0]
-sys.path.append(rootdir)
-
-import exception
-from lib import connectAPI
-from lib import domainAPI
-from utils.Python import utils
-
-def usage(params):
-    """Verify inputing parameter dictionary"""
-    logger = params['logger']
-    keys = ['guestname']
-    for key in keys:
-        if key not in params:
-            logger.error("%s is required" %key)
-            return 1
-
-def check_guest_status(guestname, domobj):
-    """Check guest current status"""
-    state = domobj.get_state(guestname)
-    if state == "shutoff" or state == "shutdown":
-    # add check function
-        return False
-    else:
-        return True
-
-def check_blkstats():
-    """Check block device statistic result"""
-    pass
-
-def blkstats(params):
-    """Domain block device statistic"""
-    # Initiate and check parameters
-    usage(params)
-    logger = params['logger']
-    guestname = params['guestname']
-    test_result = False
-
-    # Connect to local hypervisor connection URI
-    util = utils.Utils()
-    uri = util.get_uri('127.0.0.1')
-    conn = connectAPI.ConnectAPI()
-    virconn = conn.open(uri)
-
-    caps = conn.get_caps()
-    logger.debug(caps)
-
-    # Check domain block status
-    domobj = domainAPI.DomainAPI(virconn)
-    if check_guest_status(guestname, domobj):
-        pass
-    else:
-        domobj.start(guestname)
-        time.sleep(90)
-    try:
-        try:
-            (blkstats, path) = domobj.get_block_stats(guestname)
-        except exception.LibvirtAPI, e:
-            logger.error("libvirt error: error code - %s; error message - %s" %(e.code, e.message))
-            return 1;
-    finally:
-        conn.close()
-        logger.info("closed hypervisor connection")
-
-    if blkstats:
-        # check_blkstats()
-        logger.debug(blkstats)
-        logger.info("%s rd_req %s" %(path, blkstats[0]))
-        logger.info("%s rd_bytes %s" %(path, blkstats[1]))
-        logger.info("%s wr_req %s" %(path, blkstats[2]))
-        logger.info("%s wr_bytes %s" %(path, blkstats[3]))
-        test_result = True
-    else:
-        logger.error("fail to get domain block statistics\n")
-        test_result = False
-
-    if test_result:
-        return 0
-    else:
-        return 1
-
-def blkstats_clean(params):
-    """ clean testing environment """
-    pass
diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py
index 8d21797..29cda26 100644
--- a/repos/domain/install_linux_cdrom.py
+++ b/repos/domain/install_linux_cdrom.py
@@ -17,6 +17,13 @@
                        source
                        volumepath
                        type: define|create
+                       graphtype
+                       image
+                       jpeg
+                       zlib
+                       playback
+                       streaming
+                       clipboard
 """
 
 import os
@@ -80,6 +87,13 @@ def usage():
                            source
                            volumepath
                            type: define|create
+                           graphtype
+                           image
+                           jpeg
+                           zlib
+                           playback
+                           streaming
+                           clipboard
           '''
 
 def check_params(params):
@@ -88,7 +102,8 @@ def check_params(params):
     mandatory_args = ['guestname', 'guesttype', 'guestos', 'guestarch']
     optional_args = ['memory', 'vcpu', 'disksize', 'imagepath', 'hdmodel',
                      'nicmodel', 'macaddr', 'ifacetype', 'source', 'type',
-                     'volumepath', 'imagetype']
+                     'volumepath', 'imagetype', 'graphtype', 'image',
+                     'jpeg', 'zlib', 'playback', 'streaming', 'clipboard']
 
     for arg in mandatory_args:
         if arg not in params_given.keys():
diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py
index 1b0470e..a9a5861 100644
--- a/repos/domain/install_linux_net.py
+++ b/repos/domain/install_linux_net.py
@@ -16,6 +16,13 @@
                        ifacetype
                        source
                        type: define|create
+                       graphtype
+                       image
+                       jpeg
+                       zlib
+                       playback
+                       streaming
+                       clipboard
 """
 
 __author__ = "Guannan Ren <gren@xxxxxxxxxx>"
@@ -80,6 +87,13 @@ def usage():
                            ifacetype
                            source
                            type: define|create
+                           graphtype
+                           image
+                           jpeg
+                           zlib
+                           playback
+                           streaming
+                           clipboard
           '''
 
 def check_params(params):
@@ -91,7 +105,9 @@ def check_params(params):
 
     optional_args = ['memory', 'vcpu', 'disksize', 'imagepath',
                      'hdmodel', 'nicmodel', 'ifacetype',
-                     'imagetype', 'source', 'type']
+                     'imagetype', 'source', 'type', 'graphtype',
+                     'image', 'jpeg', 'zlib', 'playback',
+                     'steaming', 'clipboard']
 
     for arg in mandatory_args:
         if arg not in params_given.keys():
diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py
index b8333e2..a2229ea 100644
--- a/repos/domain/install_windows_cdrom.py
+++ b/repos/domain/install_windows_cdrom.py
@@ -17,6 +17,13 @@
                        source
                        volumepath
                        type: define|create
+                       graphtype
+                       image
+                       jpeg
+                       zlib
+                       playback
+                       streaming
+                       clipboard
 """
 
 import os
@@ -78,6 +85,13 @@ def usage():
                            source
                            volumepath
                            type: define|create
+                           graphtype
+                           image
+                           jpeg
+                           zlib
+                           playback
+                           streaming
+                           clipboard
           '''
 
 def return_close(conn, logger, ret):
@@ -91,7 +105,8 @@ def check_params(params):
     mandatory_args = ['guestname', 'guesttype', 'guestos', 'guestarch']
     optional_args = ['memory', 'vcpu', 'disksize', 'imagepath', 'hdmodel',
                      'nicmodel', 'macaddr', 'ifacetype', 'source', 'type',
-                     'volumepath', 'imagetype']
+                     'volumepath', 'imagetype', 'graphtype', 'image',
+                     'jpeg', 'zlib', 'playback', 'streaming', 'clipboard']
 
     for arg in mandatory_args:
         if arg not in params_given.keys():
diff --git a/utils/Python/xmlbuilder.py b/utils/Python/xmlbuilder.py
index 5a0f8c8..3dbe576 100644
--- a/utils/Python/xmlbuilder.py
+++ b/utils/Python/xmlbuilder.py
@@ -297,6 +297,13 @@ if __name__ == "__main__":
     params['memory'] = '1048576'
     params['vcpu'] = '2'
     params['inputbus'] = 'usb'
+    params['graphtype'] = 'spice'
+    params['image'] = 'auto_glz'
+    params['jpeg'] = 'auto'
+    params['zlib'] = 'auto'
+    params['playback'] = 'on'
+    params['streaming'] = 'filter'
+    params['clipboard'] = 'no'
     params['sound'] = 'ac97'
     params['bootcd'] = '/iso/rhel5.iso'
 
@@ -367,7 +374,7 @@ if __name__ == "__main__":
     #----------------------------------------
     # get domain snapshot xml string
     #----------------------------------------
-    params['name'] = 'hello'
+    params['snapshotname'] = 'hello'
     params['description'] = 'hello snapshot'
     snapshot_xml = xmlobj.build_domain_snapshot(params)
 
diff --git a/utils/Python/xmlgenerator.py b/utils/Python/xmlgenerator.py
index d57dd33..b61ceb1 100644
--- a/utils/Python/xmlgenerator.py
+++ b/utils/Python/xmlgenerator.py
@@ -235,9 +235,54 @@ def domain_xml(params, install = False):
 
     # <graphics>
     graphics_element = domain.createElement('graphics')
-    graphics_element.setAttribute('type', 'vnc')
-    graphics_element.setAttribute('port', '-1')
-    graphics_element.setAttribute('keymap', 'en-us')
+    if not params.has_key('graphtype'):
+        params['graphtype'] == 'vnc'
+
+    graphics_element.setAttribute('type', params['graphtype'])
+    if params['graphtype'] == 'vnc':
+        graphics_element.setAttribute('port', '-1')
+        graphics_element.setAttribute('keymap', 'en-us')
+    elif params['graphtype'] == 'spice':
+        graphics_element.setAttribute('autoport', 'yes')
+        if params.has_key('image'):
+            image_element = domain.createElement('image')
+            # image to set image compression (accepts 
+            # auto_glz, auto_lz, quic, glz, lz, off)
+            image_element.setAttribute('compression', params['image'])
+            graphics_element.appendChild(image_element)
+        if params.has_key('jpeg'):
+            jpeg_element = domain.createElement('jpeg')
+            # jpeg for JPEG compression for images over wan (accepts 
+            # auto, never, always)
+            jpeg_element.setAttribute('compression', params['jpeg'])
+            graphics_element.appendChild(jpeg_element)
+        if params.has_key('zlib'):
+            zlib_element = domain.createElement('zlib')
+            # zlib for configuring wan image compression (accepts 
+            # auto, never, always)
+            zlib_element.setAttribute('compression', params['zlib'])
+            graphics_element.appendChild(zlib_element)
+        if params.has_key('playback'):
+            playback_element = domain.createElement('playback')
+            # playback for enabling audio stream compression (accepts on or off)
+            playback_element.setAttribute('compression', params['playback'])
+            graphics_element.appendChild(playback_element)
+        if params.has_key('streaming'):
+            streaming_element = domain.createElement('streaming')
+            # streamming for settings it's mode attribute to one of 
+            # filter, all or off
+            streaming_element.setAttribute('mode', params['streaming'])
+            graphics_element.appendChild(streaming_element)
+        if params.has_key('clipboard'):
+            clipboard_element = domain.createElement('clipboard')
+            # Copy & Paste functionality is enabled by default, and can 
+            # be disabled by setting the copypaste property to no
+            clipboard_element.setAttribute('copypaste', params['clipboard'])
+            graphics_element.appendChild(clipboard_element)
+    else:
+        print 'Wrong graphics type was specified.'
+        sys.exit(1)
+
     devices_element.appendChild(graphics_element)
     domain_element.appendChild(devices_element)
 
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]