[libvirt] [test-API PATCH 0/4]testcases will use xml file directly

Right now, for testcases that needs xml to define domain or storage, etc they call module *utils/xmlbuilder.py utils/xmlgenerator.py* to get back a string of xml. These two module create xml string by "xml.dom.minidom" This approach is hard to maintain and not easy to use. So we will depreciate it in near furture. The new way is to use xml file directly. There will be a new folder named 'xmls' in path repos/*/xmls, testcases will use the xmlfile in the foler directly. For example: domain:define required_params = ('guestname', 'diskpath',) optional_params = {'memory': 1048576, 'vcpu': 1, 'hddriver' : 'virtio', 'nicdriver': 'virtio', 'macaddr': '52:54:00:97:e4:28', 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', 'username': None, 'password': None, 'guesttype': 'kvm', 'xml': 'xmls/kvm_guest_define.xml' } The define.py will get the xml string of "xmls/kvm_guest_define.xml" and define it directly. The framework takes the charge of getting the content of the file, replacing some TEXT in it and passing the string to define.py for use. The define.py supports any file in absolute path if the xml option is given in testcase file like domain:eventhandler guestname fedoraVM diskpath /var/lib/libvirt/images/fedoraVM xml /PATH/TO/FILE

src/testcasexml.py: the function will be called just before calling main function in testcase. The purpose of it is to replace the opition(if present) 'xml = file_path' with 'xml = xmlstring' and pass it into testcase after replacing keywords in the xml file based on the opitional_params in testcase --- src/testcasexml.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 0 deletions(-) create mode 100644 src/testcasexml.py diff --git a/src/testcasexml.py b/src/testcasexml.py new file mode 100644 index 0000000..742116b --- /dev/null +++ b/src/testcasexml.py @@ -0,0 +1,61 @@ + + +import os +import exception + +def xml_file_to_str(proxy_obj, mod_case, case_params): + """ get xml string from xml file in case_params + return a new case_params with the string in it + """ + + optional_params = proxy_obj.get_testcase_params(mod_case)[1] + + if case_params.has_key('xml'): + file_name = case_params.pop('xml') + elif optional_params.has_key('xml'): + file_name = optional_params.pop('xml') + else: + return None + + # If file_name is not absolute path, that means + # the file is in repos/*/xmls/ + # if it is absolute use it directly + if not os.path.isabs(file_name): + mod = mod_case.split(':')[0] + file_path = os.path.join('repos', mod, file_name) + else: + file_path = file_name + + text = '' + if os.path.exists(file_path): + fh = open(file_path,'r') + text = fh.read() + fh.close() + else: + raise exception.FileDoesNotExist("xml file %s doesn't exist" % xml_file_path) + + optional_params = proxy_obj.get_testcase_params(mod_case)[1] + + # replace the params that in testcase.conf first + for (key, value) in case_params.items(): + + if key == 'logger': + continue + + key = key.upper() + text = text.replace(key, value) + + # relace the optional params that defined in testcase.py + for (key, value) in optional_params.items(): + + if key == 'xml': + continue + + key = key.upper() + if value == None: + value = '' + + text = text.replace(key, str(value)) + + case_params['xml'] = text + return case_params -- 1.7.7.5

libvirt-test-api: pass proxy_obj to generator, and support dict type of optional_params src/generator.py: call xml_file_to_str() src/proxy.py: get the optional_params of a testcase --- libvirt-test-api | 3 ++- src/generator.py | 7 ++++++- src/proxy.py | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libvirt-test-api b/libvirt-test-api index 373e5c6..a7c9138 100644 --- a/libvirt-test-api +++ b/libvirt-test-api @@ -147,6 +147,7 @@ class Main(object): logfile = os.path.join('log/%s' % testrunid, logname) procs.append(generator.FuncGen(cases_func_ref_dict, cases_checkfunc_ref_dict, + proxy_obj, activity, logfile, testrunid, @@ -244,7 +245,7 @@ class Main(object): string += " " * 8 + p.upper() + "\n" for p in optional_params: string += " " * 4 + "[" + p + "]\n" - string += " " * 8 + p.upper() + "\n" + string += " " * 8 + optional_params[p] + "\n" if proxy_obj.has_clean_function(key): string += "clean\n" diff --git a/src/generator.py b/src/generator.py index e3bc344..5d7bc96 100644 --- a/src/generator.py +++ b/src/generator.py @@ -25,6 +25,7 @@ import os import traceback from src import mapper +from src.testcasexml import xml_file_to_str from utils import log from utils import format from utils import env_parser @@ -41,12 +42,14 @@ class FuncGen(object): """ To generate a callable testcase""" def __init__(self, cases_func_ref_dict, cases_checkfunc_ref_dict, + proxy_obj, activity, logfile, testrunid, testid, log_xml_parser, lockfile, loglevel): self.cases_func_ref_dict = cases_func_ref_dict self.cases_checkfunc_ref_dict = cases_checkfunc_ref_dict + self.proxy_obj = proxy_obj self.logfile = logfile self.testrunid = testrunid self.testid = testid @@ -131,7 +134,7 @@ class FuncGen(object): case_start_time = time.strftime("%Y-%m-%d %H:%M:%S") - ret = 0 + ret = 1 try: try: if mod_case_func == 'sleep': @@ -140,6 +143,8 @@ class FuncGen(object): time.sleep(int(sleepsecs)) ret = 0 else: + xml_file_to_str(self.proxy_obj, mod_case, case_params) + ret = self.cases_func_ref_dict[mod_case_func](case_params) # In the case where testcase return -1 on error if ret < 0: ret = 1 diff --git a/src/proxy.py b/src/proxy.py index 623fa43..fe50fff 100644 --- a/src/proxy.py +++ b/src/proxy.py @@ -130,6 +130,23 @@ class Proxy(object): ("required_params or optional_params not found in %s" % modcase) return case_params + def get_testcase_params(self, modcase): + """ Return a pair of required_params and optional_params + for a testcase + """ + if not modcase: + return None + + casemod_ref = self.testcase_ref_dict[modcase] + var_func_names = dir(casemod_ref) + + if 'required_params' not in var_func_names \ + or 'optional_params' not in var_func_names: + raise exception.TestCaseError\ + ("required_params or optional_params not found in %s" % modcase) + + return [casemod_ref.required_params, casemod_ref.optional_params] + def has_clean_function(self, testcase_name): """ Return true if the testcase have clean function """ -- 1.7.7.5

repos/domain/define.py repos/domain/xmls/kvm_guest_define.xml: the define.py will use the kvm_guest_define.xml by default. it also support a file given by user. --- repos/domain/define.py | 50 ++++++++++++++----------------- repos/domain/xmls/kvm_guest_define.xml | 47 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 repos/domain/xmls/kvm_guest_define.xml diff --git a/repos/domain/define.py b/repos/domain/define.py index c8fe20e..18e87ac 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -14,21 +14,21 @@ from src import sharedmod from utils import utils from utils import xmlbuilder -required_params = ('guestname', 'guesttype',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'disksize', - 'fullimagepath', - 'imagetype', - 'hdmodel', - 'nicmodel', - 'macaddr', - 'ifacetype', - 'source',) +required_params = ('guestname', 'diskpath',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + 'xml': 'xmls/kvm_guest_define.xml' + } def check_define_domain(guestname, guesttype, hostname, username, \ - password, util, logger): + password, logger): """Check define domain result, if define domain is successful, guestname.xml will exist under /etc/libvirt/qemu/ and can use virt-xml-validate tool to check the file validity @@ -59,29 +59,25 @@ def define(params): """Define a domain from xml""" logger = params['logger'] guestname = params['guestname'] - guesttype = params['guesttype'] + + xmlstr = params['xml'] + logger.debug("domain xml:\n%s" % xmlstr) + conn = sharedmod.libvirtobj['conn'] uri = conn.getURI() - hostname = utils.parser_uri(uri)[1] + hostname = utils.parse_uri(uri)[1] + username = params.get('username', '') + password = params.get('password', '') + guesttype = params.get('guesttype', 'kvm') - username = params['username'] - password = params['password'] logger.info("define domain on %s" % uri) - # Generate damain xml - xml_obj = xmlbuilder.XmlBuilder() - domain = xml_obj.add_domain(params) - xml_obj.add_disk(params, domain) - xml_obj.add_interface(params, domain) - dom_xml = xml_obj.build_domain(domain) - logger.debug("domain xml:\n%s" %dom_xml) - # Define domain from xml try: - conn.defineXML(dom_xml) + conn.defineXML(xmlstr) if check_define_domain(guestname, guesttype, hostname, \ - username, password, util, logger): + username, password, logger): logger.info("define a domain form xml is successful") else: logger.error("fail to check define domain") diff --git a/repos/domain/xmls/kvm_guest_define.xml b/repos/domain/xmls/kvm_guest_define.xml new file mode 100644 index 0000000..385ec66 --- /dev/null +++ b/repos/domain/xmls/kvm_guest_define.xml @@ -0,0 +1,47 @@ +<domain type='kvm'> + <name>GUESTNAME</name> + <uuid>UUID</uuid> + <memory unit='KiB'>MEMORY</memory> + <currentMemory unit='KiB'>MEMORY</currentMemory> + <vcpu>VCPU</vcpu> + <os> + <type arch='x86_64' machine='pc-0.14'>hvm</type> + <boot dev='hd'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='DISKPATH'/> + <target dev='vda' bus='HDDRIVER'/> + </disk> + <interface type='network'> + <mac address='MACADDR'/> + <model type='NICDRIVER'/> + <source network='default'/> + </interface> + <serial type='pty'> + <target port='0'/> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'/> + <sound model='ich6'> + </sound> + <video> + <model type='cirrus' vram='9216' heads='1'/> + </video> + <memballoon model='virtio'> + </memballoon> + </devices> +</domain> -- 1.7.7.5

The dictionary could support the string replacement in xml file. --- repos/domain/attach_disk.py | 2 +- repos/domain/attach_interface.py | 2 +- repos/domain/autostart.py | 2 +- repos/domain/balloon_memory.py | 2 +- repos/domain/blkstats.py | 2 +- repos/domain/console_io.py | 7 ++++- repos/domain/console_mutex.py | 2 +- repos/domain/cpu_affinity.py | 2 +- repos/domain/cpu_topology.py | 2 +- repos/domain/create.py | 24 ++++++++++-------- repos/domain/destroy.py | 2 +- repos/domain/detach_disk.py | 2 +- repos/domain/detach_interface.py | 2 +- repos/domain/domain_blkinfo.py | 2 +- repos/domain/domain_id.py | 2 +- repos/domain/domain_list.py | 2 +- repos/domain/domain_name.py | 2 +- repos/domain/domain_uuid.py | 2 +- repos/domain/domblkinfo.py | 2 +- repos/domain/dump.py | 2 +- repos/domain/eventhandler.py | 2 +- repos/domain/hostname.py | 2 +- repos/domain/ifstats.py | 2 +- repos/domain/install_image.py | 20 ++++++++++----- repos/domain/install_linux_cdrom.py | 26 ++++++++++---------- repos/domain/install_linux_check.py | 10 +------- repos/domain/install_linux_net.py | 24 ++++++++++-------- repos/domain/install_windows_cdrom.py | 26 ++++++++++---------- repos/domain/migrate.py | 2 +- repos/domain/ownership_test.py | 2 +- repos/domain/reboot.py | 2 +- repos/domain/restore.py | 2 +- repos/domain/resume.py | 2 +- repos/domain/save.py | 2 +- repos/domain/sched_params.py | 2 +- repos/domain/screenshot.py | 2 +- repos/domain/shutdown.py | 2 +- repos/domain/start.py | 2 +- repos/domain/suspend.py | 2 +- repos/domain/undefine.py | 2 +- repos/domain/update_devflag.py | 2 +- repos/domain/xmls/replace.py | 7 +++++ repos/interface/create.py | 2 +- repos/interface/define.py | 2 +- repos/interface/destroy.py | 2 +- repos/interface/iface_list.py | 2 +- repos/interface/iface_mac.py | 2 +- repos/interface/iface_name.py | 2 +- repos/interface/undefine.py | 2 +- repos/libvirtd/qemu_hang.py | 2 +- repos/libvirtd/restart.py | 2 +- repos/libvirtd/upstart.py | 2 +- repos/network/autostart.py | 2 +- repos/network/create.py | 2 +- repos/network/define.py | 2 +- repos/network/destroy.py | 2 +- repos/network/network_list.py | 2 +- repos/network/network_name.py | 2 +- repos/network/network_uuid.py | 2 +- repos/network/start.py | 2 +- repos/network/undefine.py | 2 +- repos/nodedevice/detach.py | 2 +- repos/nodedevice/reattach.py | 2 +- repos/nodedevice/reset.py | 2 +- repos/npiv/create_virtual_hba.py | 2 +- .../multiple_thread_block_on_domain_create.py | 2 +- repos/remoteAccess/tcp_setup.py | 2 +- repos/remoteAccess/tls_setup.py | 2 +- repos/remoteAccess/unix_perm_sasl.py | 2 +- repos/sVirt/domain_nfs_start.py | 2 +- repos/snapshot/delete.py | 2 +- repos/snapshot/file_flag.py | 2 +- repos/snapshot/flag_check.py | 2 +- repos/snapshot/internal_create.py | 2 +- repos/snapshot/revert.py | 2 +- repos/snapshot/snapshot_list.py | 2 +- repos/storage/activate_pool.py | 2 +- repos/storage/build_dir_pool.py | 2 +- repos/storage/build_disk_pool.py | 2 +- repos/storage/build_logical_pool.py | 2 +- repos/storage/build_netfs_pool.py | 2 +- repos/storage/create_dir_pool.py | 2 +- repos/storage/create_dir_volume.py | 2 +- repos/storage/create_fs_pool.py | 2 +- repos/storage/create_iscsi_pool.py | 2 +- repos/storage/create_logical_volume.py | 2 +- repos/storage/create_netfs_pool.py | 2 +- repos/storage/create_netfs_volume.py | 2 +- repos/storage/create_partition_volume.py | 2 +- repos/storage/define_dir_pool.py | 2 +- repos/storage/define_disk_pool.py | 4 ++- repos/storage/define_iscsi_pool.py | 2 +- repos/storage/define_logical_pool.py | 2 +- repos/storage/define_mpath_pool.py | 2 +- repos/storage/define_netfs_pool.py | 2 +- repos/storage/define_scsi_pool.py | 2 +- repos/storage/delete_dir_volume.py | 2 +- repos/storage/delete_logical_pool.py | 2 +- repos/storage/delete_logical_volume.py | 2 +- repos/storage/delete_netfs_volume.py | 2 +- repos/storage/delete_partition_volume.py | 2 +- repos/storage/destroy_pool.py | 2 +- repos/storage/pool_name.py | 2 +- repos/storage/pool_uuid.py | 2 +- repos/storage/undefine_pool.py | 2 +- 105 files changed, 178 insertions(+), 162 deletions(-) create mode 100644 repos/domain/xmls/replace.py diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index d68d87b..de5defe 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -19,7 +19,7 @@ required_params = ('guestname', 'imagename', 'imagesize', 'hdmodel',) -optional_params = () +optional_params = {} def create_image(name, size, logger): """Create a image file""" diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py index 5c9c507..bed8bf4 100644 --- a/repos/domain/attach_interface.py +++ b/repos/domain/attach_interface.py @@ -13,7 +13,7 @@ from utils import utils from utils import xmlbuilder required_params = ('guestname', 'ifacetype', 'source',) -optional_params = ('hdmodel',) +optional_params = {} def check_guest_status(guestname, domobj): """Check guest current status""" diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index da428c2..f0b91c2 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -11,7 +11,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname', 'autostart',) -optional_params = () +optional_params = {} def check_guest_autostart(*args): """Check domain start automatically result, if setting domain is diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index f5beae4..7fe95f0 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -16,7 +16,7 @@ from utils import utils from utils import check required_params = ('guestname', 'memorypair',) -optional_params = () +optional_params = {} def get_mem_size(ip): """ get current memory size in guest virtual machine""" diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index 31bd37f..0254922 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname',) -optional_params = () +optional_params = {} def check_guest_status(domobj): """Check guest current status""" diff --git a/repos/domain/console_io.py b/repos/domain/console_io.py index 266b020..d160ca4 100644 --- a/repos/domain/console_io.py +++ b/repos/domain/console_io.py @@ -14,7 +14,12 @@ from exception import TestError from src import sharedmod required_params = ('guestname',) -optional_params = ('device', 'timeout', 'input', 'output', 'expect',) +optional_params = {'device': 'serial0', + 'timeout':5, + 'input': None, + 'output': None, + 'expect': None + } def alarm_handler(signum, frame): raise TestError("Timed out while waiting for console") diff --git a/repos/domain/console_mutex.py b/repos/domain/console_mutex.py index bc8cb68..f09d0c8 100644 --- a/repos/domain/console_mutex.py +++ b/repos/domain/console_mutex.py @@ -8,7 +8,7 @@ from exception import TestError from src import sharedmod required_params = ('guestname',) -optional_params = ('device',) +optional_params = {'device' : 'serial0'} def console_mutex(params): """Attach to console""" diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index afc0f9b..8b65e2f 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -16,7 +16,7 @@ from src import sharedmod from utils import utils required_params = ('guestname', 'vcpu',) -optional_params = () +optional_params = {} def redefine_vcpu_number(domobj, domain_name, vcpu): """dump domain xml description to change the vcpu number, diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 5dbe27b..120273a 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -19,7 +19,7 @@ required_params = ('guestname', 'sockets', 'cores', 'threads',) -optional_params = () +optional_params = {} def check_domain_running(conn, guestname, logger): """check if the domain exists""" diff --git a/repos/domain/create.py b/repos/domain/create.py index 703ec3e..863f512 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -17,17 +17,19 @@ NONE = 0 START_PAUSED = 1 required_params = ('guestname', 'guesttype',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'disksize', - 'imagepath', - 'imagetype', - 'hdmodel', - 'nicmodel', - 'ifacetype', - 'source', - 'flag',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'disksize' : 20 + 'diskpath' : '/var/lib/libvirt/images' + 'imagetype' : 'raw' + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + } def create(params): """create a domain from xml""" diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 89de3e2..91e83ea 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = ('flags',) +optional_params = {'flags' : 'noping'} def destroy(params): """destroy domain diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index 2ebf66e..78166ee 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -14,7 +14,7 @@ from utils import utils from utils import xmlbuilder required_params = ('guestname', 'guesttype', 'imagename', 'hdmodel',) -optional_params = () +optional_params = {} def check_guest_status(domobj): """Check guest current status""" diff --git a/repos/domain/detach_interface.py b/repos/domain/detach_interface.py index c444b68..d572934 100644 --- a/repos/domain/detach_interface.py +++ b/repos/domain/detach_interface.py @@ -14,7 +14,7 @@ from utils import utils from utils import xmlbuilder required_params = ('guestname', 'ifacetype', 'source', 'nicmodel',) -optional_params = () +optional_params = {} def check_guest_status(domobj): """Check guest current status""" diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index 9aaecb2..6b65e23 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -17,7 +17,7 @@ GET_PHYSICAL_K = " du -B K %s | awk '{print $1}'" VIRSH_DOMBLKINFO = "virsh domblkinfo %s %s" required_params = ('guestname', 'blockdev',) -optional_params = () +optional_params = {} def get_output(command, logger): """execute shell command diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index ff246ad..bc573f9 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -10,7 +10,7 @@ import libvirt from src import sharedmod required_params = () -optional_params = ('guestname',) +optional_params = {'guestname': ''} VIRSH_DOMID = "virsh domid" VIRSH_IDS = "virsh --quiet list |awk '{print $1}'" diff --git a/repos/domain/domain_list.py b/repos/domain/domain_list.py index 0250723..3be0131 100644 --- a/repos/domain/domain_list.py +++ b/repos/domain/domain_list.py @@ -7,7 +7,7 @@ import re import commands required_params = ('listopt',) -optional_params = () +optional_params = {} CONFIG_DIR = '/etc/libvirt/qemu' RUNNING_DIR = '/var/run/libvirt/qemu' diff --git a/repos/domain/domain_name.py b/repos/domain/domain_name.py index b9a8e43..0033648 100644 --- a/repos/domain/domain_name.py +++ b/repos/domain/domain_name.py @@ -7,7 +7,7 @@ import re import commands required_params = () -optional_params = () +optional_params = {} VIRSH_DOMNAME = "virsh domname" VIRSH_IDS = "virsh --quiet list |awk '{print $1}'" diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index e66c3ee..d08952d 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -12,7 +12,7 @@ from libvirt import libvirtError import sharemod required_params = () -optional_params = () +optional_params = {} VIRSH_DOMUUID = "virsh domuuid" diff --git a/repos/domain/domblkinfo.py b/repos/domain/domblkinfo.py index b3c3c3e..031ce2f 100644 --- a/repos/domain/domblkinfo.py +++ b/repos/domain/domblkinfo.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname', 'blockdev',) -optional_params = () +optional_params = {} GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'" GET_CAPACITY = "du -b %s | awk '{print $1}'" diff --git a/repos/domain/dump.py b/repos/domain/dump.py index 60c5a91..7f4e626 100644 --- a/repos/domain/dump.py +++ b/repos/domain/dump.py @@ -15,7 +15,7 @@ from utils import utils from utils import check required_params = ('guestname', 'file',) -optional_params = () +optional_params = {} def check_guest_status(*args): """Check guest current status""" diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index 1b0c579..b623310 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -17,7 +17,7 @@ looping = True STATE = None required_params = ('guestname',) -optional_params = () +optional_params = {} def eventToString(event): eventStrings = ( "Defined", diff --git a/repos/domain/hostname.py b/repos/domain/hostname.py index ac809aa..2f357c6 100644 --- a/repos/domain/hostname.py +++ b/repos/domain/hostname.py @@ -7,7 +7,7 @@ import re import commands required_params = () -optional_params = () +optional_params = {} VIRSH_HOSTNAME = "virsh hostname" diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index ec03203..fe5e3b8 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -14,7 +14,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} def check_guest_status(domobj): """Check guest current status""" diff --git a/repos/domain/install_image.py b/repos/domain/install_image.py index 88b35c1..ec5a4fc 100644 --- a/repos/domain/install_image.py +++ b/repos/domain/install_image.py @@ -18,13 +18,19 @@ from utils import xmlbuilder HOME_PATH = os.getcwd() required_params = ('guestname', 'guesttype', 'guestos', 'guestarch',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'imagepath', - 'imagetype', - 'hdmodel', - 'nicmodel',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'disksize' : 20 + 'diskpath' : '/var/lib/libvirt/images' + 'imagetype' : 'raw' + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + } def install_image(params): """ install a new virtual machine """ diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index f5af6db..2f020a7 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -19,19 +19,19 @@ from utils import env_parser from utils import xmlbuilder required_params = ('guestname', 'guesttype', 'guestos', 'guestarch',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'disksize', - 'imagepath', - 'hdmodel', - 'nicmodel', - 'macaddr', - 'ifacetype', - 'source', - 'type', - 'volumepath', - 'imagetype',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'disksize' : 20 + 'diskpath' : '/var/lib/libvirt/images' + 'imagetype' : 'raw' + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + } VIRSH_QUIET_LIST = "virsh --quiet list --all|awk '{print $2}'|grep \"^%s$\"" VM_STAT = "virsh --quiet list --all| grep \"\\b%s\\b\"|grep off" diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index c6d2cb3..5d71ad1 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -17,15 +17,7 @@ from utils import check from utils import env_parser required_params = ('guestname', 'guesttype', 'hdmodel', 'nicmodel',) -optional_params = ('disksize', - 'memory', - 'vcpu', - 'guesttype', - 'imagepath', - 'ifacetype', - 'netmethod', - 'source', - 'type',) +optional_params = {} HOME_PATH = os.getcwd() diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py index 69f3279..433f898 100644 --- a/repos/domain/install_linux_net.py +++ b/repos/domain/install_linux_net.py @@ -19,17 +19,19 @@ from utils import env_parser from utils import xmlbuilder required_params = ('guestname', 'guesttype', 'guestos', 'guestarch','netmethod',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'disksize', - 'imagepath', - 'hdmodel', - 'nicmodel', - 'ifacetype', - 'imagetype', - 'source', - 'type',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'disksize' : 20 + 'diskpath' : '/var/lib/libvirt/images' + 'imagetype' : 'raw' + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + } VIRSH_QUIET_LIST = "virsh --quiet list --all|awk '{print $2}'|grep \"^%s$\"" VM_STAT = "virsh --quiet list --all| grep \"\\b%s\\b\"|grep off" diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py index beeb7dd..b45f6d3 100644 --- a/repos/domain/install_windows_cdrom.py +++ b/repos/domain/install_windows_cdrom.py @@ -27,19 +27,19 @@ ISO_MOUNT_POINT = "/mnt/libvirt_windows" HOME_PATH = os.getcwd() required_params = ('guestname', 'guesttype', 'guestos', 'guestarch',) -optional_params = ('uuid', - 'memory', - 'vcpu', - 'disksize', - 'imagepath', - 'hdmodel', - 'nicmodel', - 'macaddr', - 'ifacetype', - 'source', - 'type', - 'volumepath', - 'imagetype',) +optional_params = {'memory': 1048576, + 'vcpu': 1, + 'disksize' : 20 + 'diskpath' : '/var/lib/libvirt/images' + 'imagetype' : 'raw' + 'hddriver' : 'virtio', + 'nicdriver': 'virtio', + 'macaddr': '52:54:00:97:e4:28', + 'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080', + 'username': None, + 'password': None, + 'guesttype': 'kvm', + } def cleanup(mount): """Clean up a previously used mountpoint. diff --git a/repos/domain/migrate.py b/repos/domain/migrate.py index 2e6b40d..803ac75 100644 --- a/repos/domain/migrate.py +++ b/repos/domain/migrate.py @@ -25,7 +25,7 @@ required_params = ('transport', 'predstconfig', 'postdstconfig', 'flags',) -optional_params = () +optional_params = {} SSH_KEYGEN = "ssh-keygen -t rsa" SSH_COPY_ID = "ssh-copy-id" diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 7e03526..acb56c1 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -15,7 +15,7 @@ from src import sharedmod from utils import utils required_params = ('guestname', 'dynamic_ownership', 'use_nfs',) -optional_params = () +optional_params = {} QEMU_CONF = "/etc/libvirt/qemu.conf" SAVE_FILE = "/mnt/test.save" diff --git a/repos/domain/reboot.py b/repos/domain/reboot.py index afc1e9f..5b59025 100644 --- a/repos/domain/reboot.py +++ b/repos/domain/reboot.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} def reboot(params): """Reboot virtual machine diff --git a/repos/domain/restore.py b/repos/domain/restore.py index fe1b2b2..4ac68be 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname', 'filepath',) -optional_params = () +optional_params = {} def get_guest_ipaddr(*args): """Get guest ip address""" diff --git a/repos/domain/resume.py b/repos/domain/resume.py index f37c4fc..925956a 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} def resume(params): """Resume domain diff --git a/repos/domain/save.py b/repos/domain/save.py index eac39d2..677adb4 100644 --- a/repos/domain/save.py +++ b/repos/domain/save.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname', 'filepath',) -optional_params = () +optional_params = {} def get_guest_ipaddr(*args): """Get guest ip address""" diff --git a/repos/domain/sched_params.py b/repos/domain/sched_params.py index ee21365..786e357 100644 --- a/repos/domain/sched_params.py +++ b/repos/domain/sched_params.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname', 'capshares',) -optional_params = () +optional_params = {} def check_guest_status(domobj): """Check guest current status""" diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index eb5d0e2..c0db17f 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -8,7 +8,7 @@ import mimetypes import libvirt required_params = ('guestname', 'filename',) -optional_params = ('screen',) +optional_params = {'screen' : 0} last_filename = None diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index b8154da..cd371dd 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} def shutdown(params): """Shutdown domain diff --git a/repos/domain/start.py b/repos/domain/start.py index 325123d..2a6db85 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = ('flags',) +optional_params = {'flags' : ''} NONE = 0 START_PAUSED = 1 diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 5fe2b83..c5716cb 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} def suspend(params): """Suspend domain diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index 9cf8c55..23af6c0 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -10,7 +10,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname',) -optional_params = () +optional_params = {} def check_undefine_domain(guestname): """Check undefine domain result, if undefine domain is successful, diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py index e1b2cee..1238613 100644 --- a/repos/domain/update_devflag.py +++ b/repos/domain/update_devflag.py @@ -15,7 +15,7 @@ from utils import utils from utils import xmlbuilder required_params = ('guestname', 'devtype', 'username', 'password',) -optional_params = () +optional_params = {} def create_image(params, util, img_name): """Create an image file""" diff --git a/repos/domain/xmls/replace.py b/repos/domain/xmls/replace.py new file mode 100644 index 0000000..33f72cb --- /dev/null +++ b/repos/domain/xmls/replace.py @@ -0,0 +1,7 @@ + + +if os.path.exists(): + fh = open(xml_file_path,'r') + text = fh.read() + fh.close() + diff --git a/repos/interface/create.py b/repos/interface/create.py index 9df3464..5844dd9 100644 --- a/repos/interface/create.py +++ b/repos/interface/create.py @@ -13,7 +13,7 @@ from utils import utils from utils import xmlbuilder required_params = ('ifacename',) -optional_params = () +optional_params = {} def display_current_interface(conn): """Display current host interface information""" diff --git a/repos/interface/define.py b/repos/interface/define.py index 630ae45..e9f3ab9 100644 --- a/repos/interface/define.py +++ b/repos/interface/define.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('ifacename', 'ifacetype',) -optional_params = () +optional_params = {} def check_define_interface(ifacename): """Check defining interface result, if define interface is successful, diff --git a/repos/interface/destroy.py b/repos/interface/destroy.py index 7dc0320..9b43b1b 100644 --- a/repos/interface/destroy.py +++ b/repos/interface/destroy.py @@ -13,7 +13,7 @@ from utils import utils from utils import xmlbuilder required_params = ('ifacename',) -optional_params = () +optional_params = {} def display_current_interface(conn): """Display current host interface information""" diff --git a/repos/interface/iface_list.py b/repos/interface/iface_list.py index c6bd365..49f0c05 100644 --- a/repos/interface/iface_list.py +++ b/repos/interface/iface_list.py @@ -6,7 +6,7 @@ import re import commands required_params = ('ifaceopt',) -optional_params = () +optional_params = {} VIRSH_QUIET_IFACE_LIST = "virsh --quiet iface-list %s | awk '{print ""$%s""}'" NETWORK_CONFIG = "/etc/sysconfig/network-scripts/" diff --git a/repos/interface/iface_mac.py b/repos/interface/iface_mac.py index ce1828e..a692abf 100644 --- a/repos/interface/iface_mac.py +++ b/repos/interface/iface_mac.py @@ -6,7 +6,7 @@ import re import commands required_params = () -optional_params = ('ifacename',) +optional_params = {'ifacename': ''} VIRSH_QUIET_IFACE_LIST = "virsh --quiet iface-list --all | awk '{print ""$%s""}'" GET_MAC = "ip link show %s |sed -n '2p'| awk '{print $2}'" diff --git a/repos/interface/iface_name.py b/repos/interface/iface_name.py index e95db28..7db923f 100644 --- a/repos/interface/iface_name.py +++ b/repos/interface/iface_name.py @@ -6,7 +6,7 @@ import re import commands required_params = () -optional_params = ('macaddr',) +optional_params = {'macaddr' : ''} VIRSH_QUIET_IFACE_LIST = "virsh --quiet iface-list --all | awk '{print ""$%s""}'" GET_MAC = "ip link show %s |sed -n '2p'| awk '{print $2}'" diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py index 757d3f9..d53374f 100644 --- a/repos/interface/undefine.py +++ b/repos/interface/undefine.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('ifacename',) -optional_params = () +optional_params = {} def check_undefine_interface(ifacename): """Check undefining interface result, if undefine interface is successful, diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index 12fb09f..894949c 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -14,7 +14,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} VIRSH_LIST = "virsh list --all" RESTART_CMD = "service libvirtd restart" diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 3e06d4c..c095fc7 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -14,7 +14,7 @@ from src import sharedmod from utils import utils required_params = ('guestname',) -optional_params = () +optional_params = {} VIRSH_LIST = "virsh list --all" RESTART_CMD = "service libvirtd restart" diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py index 6cb31a4..7746d20 100644 --- a/repos/libvirtd/upstart.py +++ b/repos/libvirtd/upstart.py @@ -10,7 +10,7 @@ from utils import utils from shutil import copy required_params = () -optional_params = () +optional_params = {} VIRSH_LIST = "virsh list --all" UPSTART_CONF = "rpm -ql libvirt|grep upstart" diff --git a/repos/network/autostart.py b/repos/network/autostart.py index 4bf9692..28f9a46 100644 --- a/repos/network/autostart.py +++ b/repos/network/autostart.py @@ -13,7 +13,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname', 'autostart',) -optional_params = () +optional_params = {} def check_network_autostart(*args): """Check network start automatically result, if setting network is diff --git a/repos/network/create.py b/repos/network/create.py index d50c84d..6158f2a 100644 --- a/repos/network/create.py +++ b/repos/network/create.py @@ -19,7 +19,7 @@ required_params = ('networkname', 'netstart', 'netend', 'netmode',) -optional_params = () +optional_params = {} def check_network_status(*args): """Check current network status, it will return True if diff --git a/repos/network/define.py b/repos/network/define.py index 8c02d2a..610a99a 100644 --- a/repos/network/define.py +++ b/repos/network/define.py @@ -19,7 +19,7 @@ required_params = ('networkname', 'netstart', 'netend', 'netmode',) -optional_params = () +optional_params = {} def check_network_define(networkname, logger): """Check define network result, if define network is successful, diff --git a/repos/network/destroy.py b/repos/network/destroy.py index 1361ff7..d46d6c7 100644 --- a/repos/network/destroy.py +++ b/repos/network/destroy.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname',) -optional_params = () +optional_params = {} def check_network_status(*args): """Check current network status, it will return True if diff --git a/repos/network/network_list.py b/repos/network/network_list.py index fc571cf..c04a183 100644 --- a/repos/network/network_list.py +++ b/repos/network/network_list.py @@ -13,7 +13,7 @@ from src import sharedmod from utils import utils required_params = ('netlistopt',) -optional_params = () +optional_params = {} VIRSH_QUIET_NETLIST = "virsh --quiet net-list %s|awk '{print $1}'" VIRSH_NETLIST = "virsh net-list %s" diff --git a/repos/network/network_name.py b/repos/network/network_name.py index a07a957..c4ab182 100644 --- a/repos/network/network_name.py +++ b/repos/network/network_name.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname',) -optional_params = () +optional_params = {} VIRSH_NETNAME = "virsh net-name" diff --git a/repos/network/network_uuid.py b/repos/network/network_uuid.py index 29d8020..02a104c 100644 --- a/repos/network/network_uuid.py +++ b/repos/network/network_uuid.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname',) -optional_params = () +optional_params = {} VIRSH_NETUUID = "virsh net-uuid" diff --git a/repos/network/start.py b/repos/network/start.py index baa84c2..7c49b4f 100644 --- a/repos/network/start.py +++ b/repos/network/start.py @@ -13,7 +13,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname',) -optional_params = () +optional_params = {} def start(params): """activate a defined network""" diff --git a/repos/network/undefine.py b/repos/network/undefine.py index b088990..e51713a 100644 --- a/repos/network/undefine.py +++ b/repos/network/undefine.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('networkname',) -optional_params = () +optional_params = {} def check_network_undefine(networkname): """Check undefine network result, if undefine network is successful, diff --git a/repos/nodedevice/detach.py b/repos/nodedevice/detach.py index 3ae5b39..ceb0d8e 100644 --- a/repos/nodedevice/detach.py +++ b/repos/nodedevice/detach.py @@ -13,7 +13,7 @@ from src import sharedmod from utils import utils required_params = ('pciaddress',) -optional_params = () +optional_params = {} def check_node_detach(pciaddress): """Check node device detach result, if detachment is successful, the diff --git a/repos/nodedevice/reattach.py b/repos/nodedevice/reattach.py index d8fd6a3..34148a1 100644 --- a/repos/nodedevice/reattach.py +++ b/repos/nodedevice/reattach.py @@ -13,7 +13,7 @@ from src import sharedmod from utils import utils required_params = ('pciaddress',) -optional_params = () +optional_params = {} def check_node_reattach(pciaddress): """Check node device reattach result, if reattachment is successful, the diff --git a/repos/nodedevice/reset.py b/repos/nodedevice/reset.py index f758bf5..0aa1c2c 100644 --- a/repos/nodedevice/reset.py +++ b/repos/nodedevice/reset.py @@ -13,7 +13,7 @@ from src import sharedmod from utils import utils required_params = ('pciaddress',) -optional_params = () +optional_params = {} def check_node_reset(): """Check node device reset result, I have no idea how to check it now""" diff --git a/repos/npiv/create_virtual_hba.py b/repos/npiv/create_virtual_hba.py index a558fbc..95a49f3 100644 --- a/repos/npiv/create_virtual_hba.py +++ b/repos/npiv/create_virtual_hba.py @@ -14,7 +14,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('wwpn',) -optional_params = () +optional_params = {} def check_nodedev_create(wwpn, device_name): """Check if the node device vHBA was created. Can search created diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index ffd25e8..2ee7897 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -22,7 +22,7 @@ IMAG_PATH = "/var/lib/libvirt/images/" DISK_DD = "dd if=/dev/zero of=%s bs=1 count=1 seek=6G" required_params = ('guestos', 'guestarch', 'guesttype', 'guestnum', 'uri') -optional_params = () +optional_params = {} def request_credentials(credentials, user_data): for credential in credentials: diff --git a/repos/remoteAccess/tcp_setup.py b/repos/remoteAccess/tcp_setup.py index 11c14a2..ec76c84 100644 --- a/repos/remoteAccess/tcp_setup.py +++ b/repos/remoteAccess/tcp_setup.py @@ -16,7 +16,7 @@ required_params = ('target_machine', 'password', 'listen_tcp', 'auth_tcp',) -optional_params = () +optional_params = {} SASLPASSWD2 = "/usr/sbin/saslpasswd2" LIBVIRTD_CONF = "/etc/libvirt/libvirtd.conf" diff --git a/repos/remoteAccess/tls_setup.py b/repos/remoteAccess/tls_setup.py index 7ce2e84..4e7c60d 100644 --- a/repos/remoteAccess/tls_setup.py +++ b/repos/remoteAccess/tls_setup.py @@ -18,7 +18,7 @@ required_params = ('listen_tls', 'target_machine', 'username', 'password',) -optional_params = () +optional_params = {} CERTTOOL = "/usr/bin/certtool" CP = "/bin/cp" diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py index d5cd914..4e39c70 100644 --- a/repos/remoteAccess/unix_perm_sasl.py +++ b/repos/remoteAccess/unix_perm_sasl.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from utils import utils required_params = ('auth_unix_ro', 'auth_unix_rw',) -optional_params = ('unix_sock_group',) +optional_params = {'unix_sock_group' : 'libvirt'} TESTING_USER = 'testapi' LIBVIRTD_CONF = "/etc/libvirt/libvirtd.conf" diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index 650947c..59cb267 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -21,7 +21,7 @@ required_params = ('guestname', 'dynamic_ownership', 'virt_use_nfs', 'root_squash',) -optional_params = () +optional_params = {} QEMU_CONF = "/etc/libvirt/qemu.conf" diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index a0f28a4..19689b1 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -10,7 +10,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname', 'snapshotname',) -optional_params = () +optional_params = {} SNAPSHOT_DIR = "/var/lib/libvirt/qemu/snapshot" diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py index 9f1c181..51f6965 100644 --- a/repos/snapshot/file_flag.py +++ b/repos/snapshot/file_flag.py @@ -14,7 +14,7 @@ from utils import utils from utils import check required_params = ('guestname', 'username', 'password',) -optional_params = () +optional_params = {} FLAG_FILE = "snapshot_flag" MAKE_FLAG = "rm -f /tmp/%s; touch /tmp/%s " % (FLAG_FILE, FLAG_FILE) diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py index 9386e2b..19bfaef 100644 --- a/repos/snapshot/flag_check.py +++ b/repos/snapshot/flag_check.py @@ -13,7 +13,7 @@ from utils import utils from utils import check required_params = ('guestname', 'username', 'password',) -optional_params = ('expectedret') +optional_params = {'expectedret' : ''} FLAG_FILE = "/tmp/snapshot_flag" FLAG_CHECK = "ls %s" % FLAG_FILE diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py index d0f3906..3f92ed6 100644 --- a/repos/snapshot/internal_create.py +++ b/repos/snapshot/internal_create.py @@ -14,7 +14,7 @@ from utils import utils from utils import xmlbuilder required_params = ('guestname',) -optional_params = ('snapshotname',) +optional_params = {'snapshotname' : ''} QEMU_IMAGE_FORMAT = "qemu-img info %s |grep format |awk -F': ' '{print $2}'" diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py index d89d926..6fe2045 100644 --- a/repos/snapshot/revert.py +++ b/repos/snapshot/revert.py @@ -10,7 +10,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('guestname', 'snapshotname',) -optional_params = () +optional_params = {} def check_domain_state(conn, guestname, logger): """ check if the domain exists and in shutdown state as well """ diff --git a/repos/snapshot/snapshot_list.py b/repos/snapshot/snapshot_list.py index cbd68a8..591fe84 100644 --- a/repos/snapshot/snapshot_list.py +++ b/repos/snapshot/snapshot_list.py @@ -6,7 +6,7 @@ import re import commands required_params = ('guestname',) -optional_params = () +optional_params = {} SNAPSHOT_DIR = "/var/lib/libvirt/qemu/snapshot" SNAPSHOT_LIST = "virsh snapshot-list %s |sed -n '3,$'p|awk '{print $1}'" diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py index 3954457..5d6e595 100644 --- a/repos/storage/activate_pool.py +++ b/repos/storage/activate_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(stg, logger): """Display current storage pool information""" diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py index cb76c59..8dad327 100644 --- a/repos/storage/build_dir_pool.py +++ b/repos/storage/build_dir_pool.py @@ -13,7 +13,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/build_disk_pool.py b/repos/storage/build_disk_pool.py index d9838d8..d446379 100644 --- a/repos/storage/build_disk_pool.py +++ b/repos/storage/build_disk_pool.py @@ -13,7 +13,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def get_pool_devicename_type(poolobj): """ get device name and partition table of the pool diff --git a/repos/storage/build_logical_pool.py b/repos/storage/build_logical_pool.py index 1c743e3..a9e07aa 100644 --- a/repos/storage/build_logical_pool.py +++ b/repos/storage/build_logical_pool.py @@ -11,7 +11,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/build_netfs_pool.py b/repos/storage/build_netfs_pool.py index 168242d..b8bb650 100644 --- a/repos/storage/build_netfs_pool.py +++ b/repos/storage/build_netfs_pool.py @@ -11,7 +11,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/create_dir_pool.py b/repos/storage/create_dir_pool.py index 067ae92..bfb3205 100644 --- a/repos/storage/create_dir_pool.py +++ b/repos/storage/create_dir_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype',) -optional_params = () +optional_params = {} def check_pool_create(conn, poolname, logger): """Check the result of create storage pool. diff --git a/repos/storage/create_dir_volume.py b/repos/storage/create_dir_volume.py index 155eb3b..8a375b9 100644 --- a/repos/storage/create_dir_volume.py +++ b/repos/storage/create_dir_volume.py @@ -14,7 +14,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'volname', 'volformat', 'capacity',) -optional_params = () +optional_params = {} def get_pool_path(poolobj): """ get pool xml description """ diff --git a/repos/storage/create_fs_pool.py b/repos/storage/create_fs_pool.py index 7daf5f6..3f33df4 100644 --- a/repos/storage/create_fs_pool.py +++ b/repos/storage/create_fs_pool.py @@ -13,7 +13,7 @@ from utils import xmlbuilder from utils import XMLParser required_params = ('poolname', 'sourcepath', 'pooltype',) -optional_params = ('sourceformat',) +optional_params = {'sourceformat' : ''} def check_pool_create_libvirt(conn, poolname, logger): """Check the result of create storage pool on libvirt level. """ diff --git a/repos/storage/create_iscsi_pool.py b/repos/storage/create_iscsi_pool.py index f108a59..35631db 100644 --- a/repos/storage/create_iscsi_pool.py +++ b/repos/storage/create_iscsi_pool.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'sourcename', 'sourcepath', 'pooltype',) -optional_params = () +optional_params = {} def check_pool_create(conn, poolname, logger): """Check the result of create storage pool. """ diff --git a/repos/storage/create_logical_volume.py b/repos/storage/create_logical_volume.py index 714480c..30c0708 100644 --- a/repos/storage/create_logical_volume.py +++ b/repos/storage/create_logical_volume.py @@ -15,7 +15,7 @@ from utils import utils from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'volname', 'capacity',) -optional_params = () +optional_params = {} def get_pool_path(poolobj): """ Get pool target path """ diff --git a/repos/storage/create_netfs_pool.py b/repos/storage/create_netfs_pool.py index 2a0cd23..8473b2d 100644 --- a/repos/storage/create_netfs_pool.py +++ b/repos/storage/create_netfs_pool.py @@ -13,7 +13,7 @@ from utils import xmlbuilder from utils import XMLParser required_params = ('poolname', 'sourcename', 'sourcepath', 'pooltype',) -optional_params = ('targetpath',) +optional_params = {'targetpath' : ''} def check_pool_create_libvirt(conn, poolname, logger): """Check the result of create storage pool inside libvirt """ diff --git a/repos/storage/create_netfs_volume.py b/repos/storage/create_netfs_volume.py index e5f711a..6a3e934 100644 --- a/repos/storage/create_netfs_volume.py +++ b/repos/storage/create_netfs_volume.py @@ -14,7 +14,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'volname', 'volformat', 'capacity',) -optional_params = () +optional_params = {} def get_pool_path(poolobj): """ get pool xml description """ diff --git a/repos/storage/create_partition_volume.py b/repos/storage/create_partition_volume.py index 3ba802b..a7e6ff0 100644 --- a/repos/storage/create_partition_volume.py +++ b/repos/storage/create_partition_volume.py @@ -13,7 +13,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'volname', 'volformat', 'capacity',) -optional_params = () +optional_params = {} def partition_volume_check(poolobj, volname): """check the new created volume, the way of checking is to get diff --git a/repos/storage/define_dir_pool.py b/repos/storage/define_dir_pool.py index b45767d..ea948c3 100644 --- a/repos/storage/define_dir_pool.py +++ b/repos/storage/define_dir_pool.py @@ -18,7 +18,7 @@ POOL_DESTROY = "virsh pool-destroy %s" POOL_UNDEFINE = "virsh pool-undefine %s" required_params = ('poolname', 'pooltype',) -optional_params = ('targetpath',) +optional_params = {'targetpath' : ''} def display_pool_info(conn, logger): """Display current storage pool information""" diff --git a/repos/storage/define_disk_pool.py b/repos/storage/define_disk_pool.py index 619292f..1fe346d 100644 --- a/repos/storage/define_disk_pool.py +++ b/repos/storage/define_disk_pool.py @@ -12,7 +12,9 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'sourcepath',) -optional_params = ('sourceformat', 'targetpath',) +optional_params = {'sourceformat': '', + 'targetpath' : '' + } def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/define_iscsi_pool.py b/repos/storage/define_iscsi_pool.py index fdb09a2..0f5f89a 100644 --- a/repos/storage/define_iscsi_pool.py +++ b/repos/storage/define_iscsi_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'sourcename', 'sourcepath',) -optional_params = () +optional_params = {} def display_pool_info(conn, logger): """Display current storage pool information""" diff --git a/repos/storage/define_logical_pool.py b/repos/storage/define_logical_pool.py index ebbdc76..8c75501 100644 --- a/repos/storage/define_logical_pool.py +++ b/repos/storage/define_logical_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'sourcename', 'sourcepath',) -optional_params = () +optional_params = {} def display_pool_info(conn, logger): """Display current storage pool information""" diff --git a/repos/storage/define_mpath_pool.py b/repos/storage/define_mpath_pool.py index 930f9b8..88f4e53 100644 --- a/repos/storage/define_mpath_pool.py +++ b/repos/storage/define_mpath_pool.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype',) -optional_params = ('targetpath',) +optional_params = {'targetpath' : ''} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/define_netfs_pool.py b/repos/storage/define_netfs_pool.py index e607da2..d3b256b 100644 --- a/repos/storage/define_netfs_pool.py +++ b/repos/storage/define_netfs_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'sourcename', 'sourcepath',) -optional_params = ('targetpath',) +optional_params = {'targetpath' : ''} def display_pool_info(conn, logger): """Display current storage pool information""" diff --git a/repos/storage/define_scsi_pool.py b/repos/storage/define_scsi_pool.py index 8be591a..7998d6a 100644 --- a/repos/storage/define_scsi_pool.py +++ b/repos/storage/define_scsi_pool.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'pooltype', 'sourcename',) -optional_params = ('targetpath',) +optional_params = {'targetpath' : ''} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/delete_dir_volume.py b/repos/storage/delete_dir_volume.py index 92853f4..d2368cb 100644 --- a/repos/storage/delete_dir_volume.py +++ b/repos/storage/delete_dir_volume.py @@ -11,7 +11,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname', 'volname',) -optional_params = () +optional_params = {} def display_volume_info(poolobj): """Display current storage volume information""" diff --git a/repos/storage/delete_logical_pool.py b/repos/storage/delete_logical_pool.py index 9bfb555..80e0183 100644 --- a/repos/storage/delete_logical_pool.py +++ b/repos/storage/delete_logical_pool.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(conn): """Display current storage pool information""" diff --git a/repos/storage/delete_logical_volume.py b/repos/storage/delete_logical_volume.py index cbf3ccc..089ef6f 100644 --- a/repos/storage/delete_logical_volume.py +++ b/repos/storage/delete_logical_volume.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname', 'volname',) -optional_params = () +optional_params = {} def display_volume_info(poolobj): """Display current storage volume information""" diff --git a/repos/storage/delete_netfs_volume.py b/repos/storage/delete_netfs_volume.py index 73f995f..9c73ac5 100644 --- a/repos/storage/delete_netfs_volume.py +++ b/repos/storage/delete_netfs_volume.py @@ -11,7 +11,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname', 'volname',) -optional_params = () +optional_params = {} def display_volume_info(poolobj): """Display current storage volume information""" diff --git a/repos/storage/delete_partition_volume.py b/repos/storage/delete_partition_volume.py index b70ff45..8f7dcbe 100644 --- a/repos/storage/delete_partition_volume.py +++ b/repos/storage/delete_partition_volume.py @@ -12,7 +12,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname', 'volname',) -optional_params = () +optional_params = {} def partition_volume_check(poolobj, volname, partition_name): """check the newly deleted volume, the way of checking is to diff --git a/repos/storage/destroy_pool.py b/repos/storage/destroy_pool.py index 304f1bb..c87b45f 100644 --- a/repos/storage/destroy_pool.py +++ b/repos/storage/destroy_pool.py @@ -11,7 +11,7 @@ from src import sharedmod from utils import xmlbuilder required_params = ('poolname',) -optional_params = () +optional_params = {} def check_pool_destroy(conn, poolname, logger): """ diff --git a/repos/storage/pool_name.py b/repos/storage/pool_name.py index 981e76d..50b0821 100644 --- a/repos/storage/pool_name.py +++ b/repos/storage/pool_name.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} VIRSH_POOLNAME = "virsh pool-name" diff --git a/repos/storage/pool_uuid.py b/repos/storage/pool_uuid.py index 8f77ba7..bb6bf63 100644 --- a/repos/storage/pool_uuid.py +++ b/repos/storage/pool_uuid.py @@ -12,7 +12,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} VIRSH_POOLUUID = "virsh pool-uuid" diff --git a/repos/storage/undefine_pool.py b/repos/storage/undefine_pool.py index 8832c36..23ba73f 100644 --- a/repos/storage/undefine_pool.py +++ b/repos/storage/undefine_pool.py @@ -10,7 +10,7 @@ from libvirt import libvirtError from src import sharedmod required_params = ('poolname',) -optional_params = () +optional_params = {} def display_pool_info(conn): """Display current storage pool information""" -- 1.7.7.5
participants (1)
-
Guannan Ren