$ for i in $(find . -type f -name "*.py"); do \ sed -i -e 's/util\./utils\./g' $i; \ done --- repos/domain/attach_disk.py | 4 +- repos/domain/attach_interface.py | 4 +- repos/domain/balloon_memory.py | 6 +- repos/domain/cpu_affinity.py | 14 ++-- repos/domain/cpu_topology.py | 6 +- repos/domain/create.py | 4 +- repos/domain/define.py | 4 +- repos/domain/destroy.py | 6 +- repos/domain/detach_disk.py | 4 +- repos/domain/detach_interface.py | 6 +- repos/domain/dump.py | 4 +- repos/domain/ifstats.py | 6 +- repos/domain/install_image.py | 6 +- repos/domain/install_linux_cdrom.py | 16 +++--- repos/domain/install_linux_check.py | 12 ++-- repos/domain/install_linux_net.py | 16 +++--- repos/domain/install_windows_cdrom.py | 14 ++-- repos/domain/ownership_test.py | 26 ++++---- repos/domain/reboot.py | 10 ++-- repos/domain/restore.py | 6 +- repos/domain/resume.py | 6 +- repos/domain/save.py | 6 +- repos/domain/sched_params.py | 2 +- repos/domain/shutdown.py | 6 +- repos/domain/start.py | 6 +- repos/domain/suspend.py | 6 +- repos/domain/update_devflag.py | 22 ++++---- repos/interface/create.py | 4 +- repos/interface/destroy.py | 2 +- repos/libvirtd/qemu_hang.py | 10 ++-- repos/libvirtd/restart.py | 16 +++--- repos/libvirtd/upstart.py | 36 ++++++------ repos/network/network_list.py | 2 +- repos/nodedevice/detach.py | 4 +- repos/nodedevice/reattach.py | 4 +- repos/nodedevice/reset.py | 2 +- .../multiple_thread_block_on_domain_create.py | 4 +- repos/remoteAccess/tcp_setup.py | 20 +++--- repos/remoteAccess/tls_setup.py | 60 ++++++++++---------- repos/remoteAccess/unix_perm_sasl.py | 4 +- repos/sVirt/domain_nfs_start.py | 26 ++++---- repos/snapshot/file_flag.py | 4 +- repos/snapshot/flag_check.py | 4 +- repos/snapshot/internal_create.py | 2 +- repos/storage/create_logical_volume.py | 2 +- 45 files changed, 217 insertions(+), 217 deletions(-) diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index ad0d174..1566fa5 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -86,7 +86,7 @@ def attach_disk(params): diskxml = xmlobj.build_disk(params) logger.debug("disk xml:\n%s" %diskxml) - disk_num1 = util.dev_num(guestname, "disk") + disk_num1 = utils.dev_num(guestname, "disk") logger.debug("original disk number: %s" %disk_num1) if disktype == "virtio": @@ -100,7 +100,7 @@ def attach_disk(params): try: try: domobj.attachDevice(diskxml) - disk_num2 = util.dev_num(guestname, "disk") + disk_num2 = utils.dev_num(guestname, "disk") logger.debug("update disk number to %s" %disk_num2) if check_attach_disk(disk_num1, disk_num2): logger.info("current disk number: %s\n" %disk_num2) diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py index 9ef3f8a..5d2ccba 100644 --- a/repos/domain/attach_interface.py +++ b/repos/domain/attach_interface.py @@ -62,14 +62,14 @@ def attach_interface(params): interfacexml = xmlobj.build_interface(params) logger.debug("interface xml:\n%s" %interfacexml) - iface_num1 = util.dev_num(guestname, "interface") + iface_num1 = utils.dev_num(guestname, "interface") logger.debug("original interface number: %s" %iface_num1) # Attach interface to domain try: try: domobj.attachDeviceFlags(interfacexml, 0) - iface_num2 = util.dev_num(guestname, "interface") + iface_num2 = utils.dev_num(guestname, "interface") logger.debug("update interface number to %s" %iface_num2) if check_attach_interface(iface_num1, iface_num2): logger.info("current interface number: %s" %iface_num2) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index fea997d..0235d36 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -102,7 +102,7 @@ def guest_power_on(domobj, domname, mac): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") @@ -164,7 +164,7 @@ def balloon_memory(params): uri = params['uri'] logger.info("get the mac address of vm %s" % domname) - mac = util.get_dom_mac_addr(domname) + mac = utils.get_dom_mac_addr(domname) logger.info("the mac address of vm %s is %s" % (domname, mac)) conn = libvirt.open(uri) @@ -222,7 +222,7 @@ def balloon_memory(params): return return_close(conn, logger, 1) time.sleep(10) - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) current_memory = get_mem_size(ip) logger.info("the current memory size is %s" % current_memory) diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index 6acf260..2fef74f 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -64,11 +64,11 @@ def set_vcpus(util, domobj, domain_name, vcpu): logger.info('destroy domain') logger.info("get the mac address of vm %s" % domain_name) - mac = util.get_dom_mac_addr(domain_name) + mac = utils.get_dom_mac_addr(domain_name) logger.info("the mac address of vm %s is %s" % (domain_name, mac)) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info("the ip address of vm %s is %s" % (domain_name, ip)) try: @@ -86,7 +86,7 @@ def set_vcpus(util, domobj, domain_name, vcpu): logger.info('ping guest') - if util.do_ping(ip, 30): + if utils.do_ping(ip, 30): logger.error('The guest is still active, IP: ' + str(ip)) else: logger.info("domain %s is destroied successfully" % domain_name) @@ -133,7 +133,7 @@ def set_vcpus(util, domobj, domain_name, vcpu): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") @@ -242,7 +242,7 @@ def cpu_affinity(params): domobj = conn.lookupByName(domain_name) - vcpunum = util.get_num_vcpus(domain_name) + vcpunum = utils.get_num_vcpus(domain_name) logger.info("the current vcpu number of guest %s is %s" % \ (domain_name, vcpunum)) @@ -252,12 +252,12 @@ def cpu_affinity(params): if ret != 0: return return_close(conn, logger, 1) - vcpunum_after_set = util.get_num_vcpus(domain_name) + vcpunum_after_set = utils.get_num_vcpus(domain_name) logger.info("after setting, the current vcpu number the guest is %s" % \ vcpunum_after_set) vcpu_list = range(int(vcpunum_after_set)) - physical_cpu_num = util.get_host_cpus() + physical_cpu_num = utils.get_host_cpus() logger.info("in the host, we have %s physical cpu" % physical_cpu_num) cpu_affinity = () diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 8fca63a..f869809 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -106,7 +106,7 @@ def guest_start(domobj, guestname, util, logger): """start guest""" timeout = 600 ip = '' - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) try: logger.info("start guest") @@ -121,7 +121,7 @@ def guest_start(domobj, guestname, util, logger): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") @@ -142,7 +142,7 @@ def cpu_topology_check(ip, username, password, lscpu = "lscpu" # sleep for 5 seconds time.sleep(40) - ret, output = util.remote_exec_pexpect(ip, username, password, lscpu) + ret, output = utils.remote_exec_pexpect(ip, username, password, lscpu) logger.debug("lscpu:") logger.debug(output) if ret: diff --git a/repos/domain/create.py b/repos/domain/create.py index 48fd502..ce5bd49 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -115,7 +115,7 @@ def create(params): return return_close(conn, logger, 1) logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 600 @@ -124,7 +124,7 @@ def create(params): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") diff --git a/repos/domain/define.py b/repos/domain/define.py index feb4abc..97d0c7b 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -71,7 +71,7 @@ def check_define_domain(guestname, guesttype, hostname, username, \ if hostname: cmd = "ls %s" % path - ret, output = util.remote_exec_pexpect(hostname, username, \ + ret, output = utils.remote_exec_pexpect(hostname, username, \ password, cmd) if ret: logger.error("guest %s xml file doesn't exsits" % guestname) @@ -96,7 +96,7 @@ def define(params): test_result = False uri = params['uri'] - hostname = util.parser_uri(uri)[1] + hostname = utils.parser_uri(uri)[1] username = params['username'] password = params['password'] diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 16af8c6..c7ffa37 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -76,9 +76,9 @@ def destroy(params): if not "noping" in flags: # Get domain ip - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info("the ip address of guest is %s" % ip) # Destroy domain @@ -103,7 +103,7 @@ def destroy(params): logger.info('ping guest') - if util.do_ping(ip, 30): + if utils.do_ping(ip, 30): logger.error('The guest is still active, IP: ' + str(ip)) return 1 else: diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index 657aebb..e19384b 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -65,7 +65,7 @@ def detach_disk(params): diskxml = xmlobj.build_disk(params) logger.debug("disk xml:\n%s" %diskxml) - disk_num1 = util.dev_num(guestname, "disk") + disk_num1 = utils.dev_num(guestname, "disk") logger.debug("original disk number: %s" %disk_num1) if disktype == "virtio": @@ -78,7 +78,7 @@ def detach_disk(params): try: try: domobj.detachDevice(diskxml) - disk_num2 = util.dev_num(guestname, "disk") + disk_num2 = utils.dev_num(guestname, "disk") logger.debug("update disk number to %s" %disk_num2) if check_detach_disk(disk_num1, disk_num2): logger.info("current disk number: %s\n" %disk_num2) diff --git a/repos/domain/detach_interface.py b/repos/domain/detach_interface.py index b87b51d..dfc992f 100644 --- a/repos/domain/detach_interface.py +++ b/repos/domain/detach_interface.py @@ -55,7 +55,7 @@ def detach_interface(params): # Connect to local hypervisor connection URI uri = params['uri'] - macs = util.get_dom_mac_addr(guestname) + macs = utils.get_dom_mac_addr(guestname) mac_list = macs.split("\n") logger.debug("mac address: \n%s" % macs) params['macaddr'] = mac_list[-1] @@ -67,7 +67,7 @@ def detach_interface(params): ifacexml = xmlobj.build_interface(params) logger.debug("interface xml:\n%s" % ifacexml) - iface_num1 = util.dev_num(guestname, "interface") + iface_num1 = utils.dev_num(guestname, "interface") logger.debug("original interface number: %s" % iface_num1) if check_guest_status(domobj): @@ -79,7 +79,7 @@ def detach_interface(params): try: try: domobj.detachDevice(ifacexml) - iface_num2 = util.dev_num(guestname, "interface") + iface_num2 = utils.dev_num(guestname, "interface") logger.debug("update interface number to %s" % iface_num2) if check_detach_interface(iface_num1, iface_num2): logger.info("current interface number: %s" % iface_num2) diff --git a/repos/domain/dump.py b/repos/domain/dump.py index c1a1592..441c18b 100644 --- a/repos/domain/dump.py +++ b/repos/domain/dump.py @@ -51,10 +51,10 @@ def check_guest_kernel(*args): chk = check.Check() - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.debug("guest mac address: %s" %mac) - ipaddr = util.mac_to_ip(mac, 15) + ipaddr = utils.mac_to_ip(mac, 15) if ipaddr == None: logger.error("can't get guest ip") return None diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index a1de55c..f846c64 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -64,12 +64,12 @@ def ifstats(params): logger.info("closed hypervisor connection") return 1 - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info('ping guest') - if not util.do_ping(ip, 300): + if not utils.do_ping(ip, 300): logger.error('Failed on ping guest, IP: ' + str(ip)) conn.close() logger.info("closed hypervisor connection") diff --git a/repos/domain/install_image.py b/repos/domain/install_image.py index 42b1b83..16059c4 100644 --- a/repos/domain/install_image.py +++ b/repos/domain/install_image.py @@ -90,7 +90,7 @@ def install_image(params): logger.info("the arch of guest is %s" % guestarch) # Connect to local hypervisor connection URI - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() logger.info("the type of hypervisor is %s" % hypervisor) logger.debug("the uri to connect is %s" % uri) @@ -150,7 +150,7 @@ def install_image(params): logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 600 @@ -159,7 +159,7 @@ def install_image(params): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 9da0374..c07dd1a 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -109,7 +109,7 @@ def prepare_cdrom(*args): if os.path.exists(new_dir): logger.info("the folder exists, remove it") - shutil.rmtree(new_dir) + shutils.rmtree(new_dir) os.makedirs(new_dir) logger.info("the directory is %s" % new_dir) @@ -123,7 +123,7 @@ def prepare_cdrom(*args): urllib.urlretrieve(ks, '%s/%s' % (new_dir, ks_name))[0] logger.info("the url of kickstart is %s" % ks) - shutil.copy('utils/ksiso.sh', new_dir) + shutils.copy('utils/ksiso.sh', new_dir) src_path = os.getcwd() logger.info("enter into the workshop folder: %s" % new_dir) @@ -232,13 +232,13 @@ def install_linux_cdrom(params): logger.info("the name of guest is %s" % guestname) logger.info("the type of guest is %s" % guesttype) - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() conn = libvirt.open(uri) check_domain_state(conn, guestname, logger) if not params.has_key('macaddr'): - macaddr = util.get_rand_mac() + macaddr = utils.get_rand_mac() params['macaddr'] = macaddr logger.info("the macaddress is %s" % params['macaddr']) @@ -412,7 +412,7 @@ def install_linux_cdrom(params): logger.info("guest is booting up") logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 300 @@ -421,7 +421,7 @@ def install_linux_cdrom(params): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") @@ -444,7 +444,7 @@ def install_linux_cdrom_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) elif hypervisor == 'kvm': @@ -485,4 +485,4 @@ def install_linux_cdrom_clean(params): elif guesttype == 'xenfv' or guesttype == 'kvm': guest_dir = os.path.join(HOME_PATH, guestname) if os.path.exists(guest_dir): - shutil.rmtree(guest_dir) + shutils.rmtree(guest_dir) diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index e5d30c5..8e35120 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -99,7 +99,7 @@ def install_linux_check(params): logger.info("the name of guest is %s" % guestname) # Connect to local hypervisor connection URI - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() logger.info("the type of hypervisor is %s" % hypervisor) logger.debug("the uri to connect is %s" % uri) @@ -115,12 +115,12 @@ def install_linux_check(params): return 1 logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 300 while timeout: - ipaddr = util.mac_to_ip(mac, 180) + ipaddr = utils.mac_to_ip(mac, 180) if not ipaddr: logger.info(str(timeout) + "s left") time.sleep(10) @@ -145,7 +145,7 @@ def install_linux_check(params): # Ping guest from host logger.info("check point1: ping guest from host") - if util.do_ping(ipaddr, 20) == 1: + if utils.do_ping(ipaddr, 20) == 1: logger.info("ping current guest successfull") else: logger.error("Error: can't ping current guest") @@ -170,7 +170,7 @@ def install_linux_check(params): # Check whether vcpu equals the value set in geust config xml logger.info("check point3: check cpu number in guest equals to \ the value set in domain config xml") - vcpunum_expect = int(util.get_num_vcpus(domain_name)) + vcpunum_expect = int(utils.get_num_vcpus(domain_name)) logger.info("vcpu number in domain config xml - %s is %s" % \ (domain_name, vcpunum_expect)) vcpunum_actual = int(chk.get_remote_vcpus(ipaddr, "root", "redhat")) @@ -188,7 +188,7 @@ def install_linux_check(params): # Check whether mem in guest is equal to the value set in domain config xml logger.info("check point4: check whether mem in guest is equal to \ the value set in domain config xml") - mem_expect = util.get_size_mem(domain_name) + mem_expect = utils.get_size_mem(domain_name) logger.info("current mem size in domain config xml - %s is %s" % (domain_name, mem_expect)) mem_actual = chk.get_remote_memory(ipaddr, "root", "redhat") diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py index b12d132..d7e1eac 100644 --- a/repos/domain/install_linux_net.py +++ b/repos/domain/install_linux_net.py @@ -160,7 +160,7 @@ def prepare_cdrom(*args): if os.path.exists(new_dir): logger.info("the folder exists, remove it") - shutil.rmtree(new_dir) + shutils.rmtree(new_dir) os.makedirs(new_dir) logger.info("the directory is %s" % new_dir) @@ -174,7 +174,7 @@ def prepare_cdrom(*args): urllib.urlretrieve(ks, '%s/%s' % (new_dir, ks_name))[0] logger.info("the url of kickstart is %s" % ks) - shutil.copy('utils/ksiso.sh', new_dir) + shutils.copy('utils/ksiso.sh', new_dir) src_path = os.getcwd() logger.info("enter into the workshop folder: %s" % new_dir) @@ -216,8 +216,8 @@ def install_linux_net(params): logger.info("the type of guest is %s" % guesttype) logger.info("the installation method is %s" % installmethod) - hypervisor = util.get_hypervisor() - macaddr = util.get_rand_mac() + hypervisor = utils.get_hypervisor() + macaddr = utils.get_rand_mac() logger.info("the macaddress is %s" % macaddr) logger.info("the type of hypervisor is %s" % hypervisor) @@ -410,7 +410,7 @@ def install_linux_net(params): logger.info("guest is booting up") logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 300 @@ -418,7 +418,7 @@ def install_linux_net(params): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) if not ip: logger.info(str(timeout) + "s left") @@ -439,7 +439,7 @@ def install_linux_net_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) elif hypervisor == 'kvm': @@ -480,4 +480,4 @@ def install_linux_net_clean(params): elif guesttype == 'xenfv': guest_dir = os.path.join(HOME_PATH, guestname) if os.path.exists(guest_dir): - shutil.rmtree(guest_dir) + shutils.rmtree(guest_dir) diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py index 39a733e..8017c20 100644 --- a/repos/domain/install_windows_cdrom.py +++ b/repos/domain/install_windows_cdrom.py @@ -148,7 +148,7 @@ def prepare_floppy_image(guestname, guestos, guestarch, floppy_mount = "/mnt/libvirt_floppy" if os.path.exists(floppy_mount): logger.info("the floppy mount point folder exists, remove it") - shutil.rmtree(floppy_mount) + shutils.rmtree(floppy_mount) logger.info("create mount point %s" % floppy_mount) os.makedirs(floppy_mount) @@ -171,7 +171,7 @@ def prepare_floppy_image(guestname, guestos, guestarch, setup_file = 'winnt.bat' setup_file_path = os.path.join(windows_unattended_path, setup_file) setup_file_dest = os.path.join(floppy_mount, setup_file) - shutil.copyfile(setup_file_path, setup_file_dest) + shutils.copyfile(setup_file_path, setup_file_dest) source = os.path.join(windows_unattended_path, "%s_%s.sif" % (guestos, guestarch)) @@ -270,10 +270,10 @@ def install_windows_cdrom(params): logger.info("the name of guest is %s" % guestname) logger.info("the type of guest is %s" % guesttype) - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() if not params.has_key('macaddr'): - macaddr = util.get_rand_mac() + macaddr = utils.get_rand_mac() params['macaddr'] = macaddr logger.info("the macaddress is %s" % params['macaddr']) @@ -431,7 +431,7 @@ def install_windows_cdrom(params): logger.info("guest is booting up") logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 600 @@ -440,7 +440,7 @@ def install_windows_cdrom(params): time.sleep(10) timeout -= 10 - ip = util.mac_to_ip(mac, 0) + ip = utils.mac_to_ip(mac, 0) if not ip: logger.info(str(timeout) + "s left") @@ -464,7 +464,7 @@ def install_windows_cdrom_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) elif hypervisor == 'kvm': diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 3a85ef5..0d1ce5b 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -60,14 +60,14 @@ def nfs_setup(util, logger): """ logger.info("set nfs service") cmd = "echo /tmp *\(rw,root_squash\) >> /etc/exports" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to config nfs export") return 1 logger.info("restart nfs service") cmd = "service nfs restart" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to restart nfs service") return 1 @@ -85,7 +85,7 @@ def chown_file(util, filepath, logger): touch_cmd = "touch %s" % filepath logger.info(touch_cmd) - ret, out = util.exec_cmd(touch_cmd, shell=True) + ret, out = utils.exec_cmd(touch_cmd, shell=True) if ret: logger.error("failed to touch a new file") logger.error(out[0]) @@ -93,14 +93,14 @@ def chown_file(util, filepath, logger): logger.info("set chown of %s as 107:107" % filepath) chown_cmd = "chown 107:107 %s" % filepath - ret, out = util.exec_cmd(chown_cmd, shell=True) + ret, out = utils.exec_cmd(chown_cmd, shell=True) if ret: logger.error("failed to set the ownership of %s" % filepath) return 1 logger.info("set %s mode as 664" % filepath) cmd = "chmod 664 %s" % filepath - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to set the mode of %s" % filepath) return 1 @@ -123,14 +123,14 @@ def prepare_env(util, dynamic_ownership, use_nfs, logger): (QEMU_CONF, d_ownership)) set_cmd = "echo dynamic_ownership = %s >> %s" % \ (d_ownership, QEMU_CONF) - ret, out = util.exec_cmd(set_cmd, shell=True) + ret, out = utils.exec_cmd(set_cmd, shell=True) if ret: logger.error("failed to set dynamic ownership") return 1 logger.info("restart libvirtd") restart_cmd = "service libvirtd restart" - ret, out = util.exec_cmd(restart_cmd, shell=True) + ret, out = utils.exec_cmd(restart_cmd, shell=True) if ret: logger.error("failed to restart libvirtd") return 1 @@ -157,14 +157,14 @@ def prepare_env(util, dynamic_ownership, use_nfs, logger): cmd = "setsebool virt_use_nfs 1" logger.info(cmd) - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("Failed to setsebool virt_use_nfs") return 1 logger.info("mount the nfs path to /mnt") mount_cmd = "mount -o vers=3 127.0.0.1:/tmp /mnt" - ret, out = util.exec_cmd(mount_cmd, shell=True) + ret, out = utils.exec_cmd(mount_cmd, shell=True) if ret: logger.error("Failed to mount the nfs path") for i in range(len(out)): @@ -286,14 +286,14 @@ def ownership_test_clean(params): if use_nfs == 'enable': if os.path.ismount("/mnt"): umount_cmd = "umount /mnt" - ret, out = util.exec_cmd(umount_cmd, shell=True) + ret, out = utils.exec_cmd(umount_cmd, shell=True) if ret: logger.error("Failed to unmount the nfs path") for i in range(len(out)): logger.error(out[i]) clean_nfs_conf = "sed -i '$d' /etc/exports" - util.exec_cmd(clean_nfs_conf, shell=True) + utils.exec_cmd(clean_nfs_conf, shell=True) filepath = TEMP_FILE elif use_nfs == 'disable': @@ -303,9 +303,9 @@ def ownership_test_clean(params): os.remove(filepath) clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF - util.exec_cmd(clean_qemu_conf, shell=True) + utils.exec_cmd(clean_qemu_conf, shell=True) cmd = "service libvirtd restart" - util.exec_cmd(cmd, shell=True) + utils.exec_cmd(cmd, shell=True) return 0 diff --git a/repos/domain/reboot.py b/repos/domain/reboot.py index c2d50b4..99857c2 100644 --- a/repos/domain/reboot.py +++ b/repos/domain/reboot.py @@ -42,7 +42,7 @@ def reboot(params): # Connect to local hypervisor connection URI uri = params['uri'] - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() if hypervisor == "kvm": logger.info("kvm hypervisor doesn't support the funtion now") return 0 @@ -52,10 +52,10 @@ def reboot(params): # Get domain ip logger.info("get the mac address of vm %s" % domain_name) - mac = util.get_dom_mac_addr(domain_name) + mac = utils.get_dom_mac_addr(domain_name) logger.info("the mac address of vm %s is %s" % (domain_name, mac)) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info("the ip address of vm %s is %s" % (domain_name, ip)) timeout = 600 logger.info('reboot vm %s now' % domain_name) @@ -79,7 +79,7 @@ def reboot(params): while timeout: time.sleep(10) timeout -= 10 - if util.do_ping(ip, 0): + if utils.do_ping(ip, 0): logger.info(str(timeout) + "s left") else: logger.info("vm %s power off successfully" % domain_name) @@ -94,7 +94,7 @@ def reboot(params): while timeout: time.sleep(10) timeout -= 10 - if not util.do_ping(ip, 0): + if not utils.do_ping(ip, 0): logger.info(str(timeout) + "s left") else: logger.info("vm %s power on successfully") diff --git a/repos/domain/restore.py b/repos/domain/restore.py index a4c7917..2677aec 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -37,13 +37,13 @@ def get_guest_ipaddr(*args): """Get guest ip address""" (guestname, util, logger) = args - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.debug("guest mac address: %s" % mac) - ipaddr = util.mac_to_ip(mac, 15) + ipaddr = utils.mac_to_ip(mac, 15) logger.debug("guest ip address: %s" % ipaddr) - if util.do_ping(ipaddr, 20) == 1: + if utils.do_ping(ipaddr, 20) == 1: logger.info("ping current guest successfull") return ipaddr else: diff --git a/repos/domain/resume.py b/repos/domain/resume.py index e737e35..3d078d4 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -75,12 +75,12 @@ def resume(params): logger.error('The domain state is not equal to "paused"') return return_close(conn, logger, 1) - mac = util.get_dom_mac_addr(domname) + mac = utils.get_dom_mac_addr(domname) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 120) + ip = utils.mac_to_ip(mac, 120) logger.info('ping guest') - if not util.do_ping(ip, 300): + if not utils.do_ping(ip, 300): logger.error('Failed on ping guest, IP: ' + str(ip)) return return_close(conn, logger, 1) diff --git a/repos/domain/save.py b/repos/domain/save.py index 3e439d9..82adfc3 100644 --- a/repos/domain/save.py +++ b/repos/domain/save.py @@ -32,13 +32,13 @@ def get_guest_ipaddr(*args): """Get guest ip address""" (guestname, util, logger) = args - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.debug("guest mac address: %s" %mac) - ipaddr = util.mac_to_ip(mac, 15) + ipaddr = utils.mac_to_ip(mac, 15) logger.debug("guest ip address: %s" %ipaddr) - if util.do_ping(ipaddr, 20) == 1: + if utils.do_ping(ipaddr, 20) == 1: logger.info("ping current guest successfull") return ipaddr else: diff --git a/repos/domain/sched_params.py b/repos/domain/sched_params.py index b98ab0f..40b23de 100644 --- a/repos/domain/sched_params.py +++ b/repos/domain/sched_params.py @@ -74,7 +74,7 @@ def sched_params(params): to verify validity of the result """ uri = params['uri'] - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() usage(params, hypervisor) logger = params['logger'] diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index 014a2dd..5b7afb2 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -61,9 +61,9 @@ def shutdown(params): timeout = 600 logger.info('shutdown domain') - mac = util.get_dom_mac_addr(domname) + mac = utils.get_dom_mac_addr(domname) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info("the ip address of guest is %s" % ip) # Shutdown domain @@ -90,7 +90,7 @@ def shutdown(params): return return_close(conn, logger, 1) logger.info('ping guest') - if util.do_ping(ip, 300): + if utils.do_ping(ip, 300): logger.error('The guest is still active, IP: ' + str(ip)) return return_close(conn, logger, 1) else: diff --git a/repos/domain/start.py b/repos/domain/start.py index cd82bb6..54d43a8 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -119,12 +119,12 @@ def start(params): # Get domain ip and ping ip to check domain's status if not "noping" in flags: - mac = util.get_dom_mac_addr(domname) + mac = utils.get_dom_mac_addr(domname) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info('ping guest') - if not util.do_ping(ip, 300): + if not utils.do_ping(ip, 300): logger.error('Failed on ping guest, IP: ' + str(ip)) return return_close(conn, logger, 1) diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 02ddcb7..ba08962 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -74,16 +74,16 @@ def suspend(params): logger.error('The domain state is not equal to "paused"') return return_close(conn, logger, 1) - mac = util.get_dom_mac_addr(domname) + mac = utils.get_dom_mac_addr(domname) time.sleep(3) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 10) + ip = utils.mac_to_ip(mac, 10) time.sleep(10) logger.info('ping guest') - if util.do_ping(ip, 20): + if utils.do_ping(ip, 20): logger.error('The guest is still active, IP: ' + str(ip)) return return_close(conn, logger, 1) diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py index 18bcf30..b1cb154 100644 --- a/repos/domain/update_devflag.py +++ b/repos/domain/update_devflag.py @@ -39,14 +39,14 @@ def create_image(params, util, img_name): if params['devtype'] == 'cdrom': cmd1 = "uuidgen|cut -d- -f1" - ret1, out1 = util.exec_cmd(cmd1, shell=True) + ret1, out1 = utils.exec_cmd(cmd1, shell=True) if ret1: logger.error("random code generated fail.") return False cmd2 = "mkdir /tmp/%s && touch /tmp/%s/$(uuidgen|cut -d- -f1)" \ % (out1, out1) - ret2, out2 = util.exec_cmd(cmd2, shell=True) + ret2, out2 = utils.exec_cmd(cmd2, shell=True) if ret2: logger.error("fail to create files for iso image: \n %s" % out1) return False @@ -54,7 +54,7 @@ def create_image(params, util, img_name): logger.info("prepare files for iso image creation.") cmd3 = "genisoimage -o %s /tmp/%s" % (img_name, out1) - ret3, out3 = util.exec_cmd(cmd3, shell=True) + ret3, out3 = utils.exec_cmd(cmd3, shell=True) if ret3: logger.error("iso file creation fail: \n %s" % out1) return False @@ -63,7 +63,7 @@ def create_image(params, util, img_name): elif params['devtype'] == 'floppy': cmd1 = "dd if=/dev/zero of=%s bs=1440k count=1" % img_name - ret1, out1 = util.exec_cmd(cmd1, shell=True) + ret1, out1 = utils.exec_cmd(cmd1, shell=True) if ret1: logger.error("floppy image creation fail: \n %s" % out1) return False @@ -71,7 +71,7 @@ def create_image(params, util, img_name): logger.info("create an image for floppy use: %s" % img_name) cmd2 = "mkfs.msdos -s 1 %s" % img_name - ret2, out2 = util.exec_cmd(cmd2, shell=True) + ret2, out2 = utils.exec_cmd(cmd2, shell=True) if ret2: logger.error("fail to format image: \n %s" % out2) return False @@ -80,7 +80,7 @@ def create_image(params, util, img_name): cmd3 = "mount -o loop %s /mnt && touch /mnt/$(uuidgen|cut -d- -f1) \ && umount -l /mnt" % img_name - ret3, out3 = util.exec_cmd(cmd3, shell=True) + ret3, out3 = utils.exec_cmd(cmd3, shell=True) if ret3: logger.error("fail to write file to floppy image: \n %s" % out3) return False @@ -105,7 +105,7 @@ def check_device_in_guest(params, util, guestip): logger.error("it's not a cdrom or floppy device.") return False, None - ret, output = util.remote_exec_pexpect(guestip, params['username'], \ + ret, output = utils.remote_exec_pexpect(guestip, params['username'], \ params['password'], cmd) logger.debug(output) if ret: @@ -114,7 +114,7 @@ def check_device_in_guest(params, util, guestip): time.sleep(5) - ret, output = util.remote_exec_pexpect(guestip, params['username'], \ + ret, output = utils.remote_exec_pexpect(guestip, params['username'], \ params['password'], "umount /media") logger.debug(output) if ret: @@ -123,7 +123,7 @@ def check_device_in_guest(params, util, guestip): time.sleep(5) - ret, output = util.remote_exec_pexpect(guestip, params['username'], \ + ret, output = utils.remote_exec_pexpect(guestip, params['username'], \ params['password'], "ls /media") logger.debug(output) if ret: @@ -194,8 +194,8 @@ def update_devflag(params): # Connect to local hypervisor connection URI uri = params['uri'] - mac = util.get_dom_mac_addr(guestname) - guestip = util.mac_to_ip(mac, 180) + mac = utils.get_dom_mac_addr(guestname) + guestip = utils.mac_to_ip(mac, 180) logger.debug("ip address: %s" % guestip) conn = libvirt.open(uri) diff --git a/repos/interface/create.py b/repos/interface/create.py index 2ab50b3..023dcf4 100644 --- a/repos/interface/create.py +++ b/repos/interface/create.py @@ -43,7 +43,7 @@ def check_create_interface(ifacename, util): """Check creating interface result, it will can ping itself if create interface is successful. """ - hostip = util.get_ip_address(ifacename) + hostip = utils.get_ip_address(ifacename) logger.debug("interface %s ip address: %s" % (ifacename, hostip)) ping_cmd = "ping -c 4 -q %s" % hostip stat, ret = commands.getstatusoutput(ping_cmd) @@ -71,7 +71,7 @@ def create(params): uri = params['uri'] try: - hostip = util.get_ip_address(ifacename) + hostip = utils.get_ip_address(ifacename) logger.error("interface %s is running" % ifacename) logger.debug("interface %s ip address: %s" % (ifacename, hostip)) return 1 diff --git a/repos/interface/destroy.py b/repos/interface/destroy.py index 7bdd5d2..239eccb 100644 --- a/repos/interface/destroy.py +++ b/repos/interface/destroy.py @@ -69,7 +69,7 @@ def destroy(params): uri = params['uri'] try: - hostip = util.get_ip_address(ifacename) + hostip = utils.get_ip_address(ifacename) logger.info("interface %s is active" % ifacename) logger.debug("interface %s ip address: %s" % (ifacename, hostip)) except: diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index c8b12c8..6dd27fd 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -47,7 +47,7 @@ def libvirtd_check(util, logger): """check libvirtd status """ cmd = "service libvirtd status" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to get libvirtd status") return 1 @@ -55,7 +55,7 @@ def libvirtd_check(util, logger): logger.info(out[0]) logger.info(VIRSH_LIST) - ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + ret, out = utils.exec_cmd(VIRSH_LIST, shell=True) if ret != 0: logger.error("failed to get virsh list result") return 1 @@ -69,7 +69,7 @@ def get_domain_pid(util, logger, guestname): """get the pid of running domain""" logger.info("get the pid of running domain %s" % guestname) get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname - ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + ret, pid = utils.exec_cmd(get_pid_cmd, shell=True) if ret: logger.error("fail to get the pid of runnings domain %s" % \ guestname) @@ -110,7 +110,7 @@ def qemu_hang(params): cmd = "kill -STOP %s" % pid logger.info(cmd) - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to stop qemu process of %s" % guestname) return 1 @@ -129,7 +129,7 @@ def qemu_hang_clean(params): ret = get_domain_pid(util, logger, guestname) cmd = "kill -CONT %s" % ret[1] - ret = util.exec_cmd(cmd, shell=True) + ret = utils.exec_cmd(cmd, shell=True) if ret[0]: logger.error("failed to resume qemu process of %s" % guestname) diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 29f0798..f11a442 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -47,7 +47,7 @@ def libvirtd_check(util, logger): """check libvirtd status """ cmd = "service libvirtd status" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to get libvirtd status") return 1 @@ -55,7 +55,7 @@ def libvirtd_check(util, logger): logger.info(out[0]) logger.info(VIRSH_LIST) - ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + ret, out = utils.exec_cmd(VIRSH_LIST, shell=True) if ret != 0: logger.error("failed to get virsh list result") return 1 @@ -69,7 +69,7 @@ def get_domain_pid(util, logger, guestname): """get the pid of running domain""" logger.info("get the pid of running domain %s" % guestname) get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname - ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + ret, pid = utils.exec_cmd(get_pid_cmd, shell=True) if ret: logger.error("fail to get the pid of runnings domain %s" % \ guestname) @@ -106,15 +106,15 @@ def restart(params): # Get domain ip logger.info("get the mac address of domain %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of domain %s is %s" % (guestname, mac)) logger.info("get ip by mac address") - ip = util.mac_to_ip(mac, 180) + ip = utils.mac_to_ip(mac, 180) logger.info("the ip address of domain %s is %s" % (guestname, ip)) logger.info("ping to domain %s" % guestname) - if util.do_ping(ip, 0): + if utils.do_ping(ip, 0): logger.info("Success ping domain %s" % guestname) else: logger.error("fail to ping domain %s" % guestname) @@ -125,7 +125,7 @@ def restart(params): return 1 logger.info("restart libvirtd service:") - ret, out = util.exec_cmd(RESTART_CMD, shell=True) + ret, out = utils.exec_cmd(RESTART_CMD, shell=True) if ret != 0: logger.error("failed to restart libvirtd") for i in range(len(out)): @@ -141,7 +141,7 @@ def restart(params): return 1 logger.info("ping to domain %s again" % guestname) - if util.do_ping(ip, 0): + if utils.do_ping(ip, 0): logger.info("Success ping domain %s" % guestname) else: logger.error("fail to ping domain %s" % guestname) diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py index ca9291e..9cd393f 100644 --- a/repos/libvirtd/upstart.py +++ b/repos/libvirtd/upstart.py @@ -22,7 +22,7 @@ def libvirtd_check(util, logger): """check libvirtd status """ cmd = "service libvirtd status" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to get libvirtd status") return 1 @@ -30,7 +30,7 @@ def libvirtd_check(util, logger): logger.info(out[0]) logger.info(VIRSH_LIST) - ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + ret, out = utils.exec_cmd(VIRSH_LIST, shell=True) if ret != 0: logger.error("failed to get virsh list result") return 1 @@ -46,7 +46,7 @@ def upstart(params): logger.info("chkconfig libvirtd off:") cmd = "chkconfig libvirtd off" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed") return 1 @@ -55,7 +55,7 @@ def upstart(params): cmd = "service libvirtd stop" logger.info(cmd) - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to stop libvirtd service") return 1 @@ -63,7 +63,7 @@ def upstart(params): logger.info(out[0]) logger.info("find libvirtd.upstart file in libvirt package:") - ret, conf = util.exec_cmd(UPSTART_CONF, shell=True) + ret, conf = utils.exec_cmd(UPSTART_CONF, shell=True) if ret != 0: logger.error("can't find libvirtd.upstart as part of libvirt package") return 1 @@ -74,7 +74,7 @@ def upstart(params): if os.path.exists(INITCTL_CMD): logger.info(INITCTL_RELOAD_CMD) - ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + ret, out = utils.exec_cmd(INITCTL_RELOAD_CMD, shell=True) if ret != 0: logger.error("failed to reload configuration") return 1 @@ -83,7 +83,7 @@ def upstart(params): cmd = "initctl start libvirtd" logger.info(cmd) - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to start libvirtd by initctl") return 1 @@ -92,7 +92,7 @@ def upstart(params): cmd = "initctl status libvirtd" logger.info("get libvirtd status by initctl:") - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.info("failed to get libvirtd status by initctl") return 1 @@ -101,7 +101,7 @@ def upstart(params): elif os.path.exists(SYSTEMCTL_CMD): logger.info(SYSTEMCTL_RELOAD_CMD) - ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + ret, out = utils.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) if ret != 0: logger.error("failed to reload systemd manager configuration") return 1 @@ -110,7 +110,7 @@ def upstart(params): cmd = "systemctl start libvirtd.service" logger.info(cmd) - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to start libvirtd.service by systemctl") return 1 @@ -119,7 +119,7 @@ def upstart(params): cmd = "systemctl status libvirtd.service" logger.info("get libvirtd.service status by systemctl:") - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.info("failed to get libvirtd.service status by systemctl") return 1 @@ -137,7 +137,7 @@ def upstart(params): cmd = "killall -9 libvirtd" logger.info("kill libvirtd process") - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to kill libvirtd process") return 1 @@ -161,36 +161,36 @@ def upstart_clean(params): if os.path.exists(INITCTL_CMD): cmd = "initctl stop libvirtd" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to stop libvirtd by initctl") if os.path.exists(INIT_CONF): os.remove(INIT_CONF) - ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + ret, out = utils.exec_cmd(INITCTL_RELOAD_CMD, shell=True) if ret != 0: logger.error("failed to reload init confituration") elif os.path.exists(SYSTEMCTL_CMD): cmd = "systemctl stop libvirtd.service" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to stop libvirtd.service by systemctl") if os.path.exists(INIT_CONF): os.remove(INIT_CONF) - ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + ret, out = utils.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) if ret != 0: logger.error("failed to reload systemd manager confituration") cmd = "service libvirtd restart" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to restart libvirtd") cmd = "chkconfig --level 345 libvirtd on" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret != 0: logger.error("failed to set chkconfig") diff --git a/repos/network/network_list.py b/repos/network/network_list.py index 8ed3fc3..ff411d9 100644 --- a/repos/network/network_list.py +++ b/repos/network/network_list.py @@ -130,7 +130,7 @@ def check_default_option(conn, util, logger): netobj = conn.networkLookupByName(network) bridgename = netobj.bridgeName() status, ip = get_output(logger, GET_BRIDGE_IP % bridgename, 0) - if not status and util.do_ping(ip, 0): + if not status and utils.do_ping(ip, 0): logger.info("network %s is active as we expected" % network) logger.debug("%s has ip: %s" % (bridgename, ip)) else: diff --git a/repos/nodedevice/detach.py b/repos/nodedevice/detach.py index 37dbf6a..d94fc37 100644 --- a/repos/nodedevice/detach.py +++ b/repos/nodedevice/detach.py @@ -63,8 +63,8 @@ def detach(params): uri = params['uri'] - kernel_version = util.get_host_kernel_version() - hypervisor = util.get_hypervisor() + kernel_version = utils.get_host_kernel_version() + hypervisor = utils.get_hypervisor() pciback = '' if hypervisor == 'kvm': pciback = 'pci-stub' diff --git a/repos/nodedevice/reattach.py b/repos/nodedevice/reattach.py index 17a430b..4082ba0 100644 --- a/repos/nodedevice/reattach.py +++ b/repos/nodedevice/reattach.py @@ -62,8 +62,8 @@ def reattach(params): uri = params['uri'] - kernel_version = util.get_host_kernel_version() - hypervisor = util.get_hypervisor() + kernel_version = utils.get_host_kernel_version() + hypervisor = utils.get_hypervisor() pciback = '' if hypervisor == 'kvm': pciback = 'pci-stub' diff --git a/repos/nodedevice/reset.py b/repos/nodedevice/reset.py index 5e76ec3..870c899 100644 --- a/repos/nodedevice/reset.py +++ b/repos/nodedevice/reset.py @@ -41,7 +41,7 @@ def reset(params): uri = params['uri'] - kernel_version = util.get_host_kernel_version() + kernel_version = utils.get_host_kernel_version() if 'el5' in kernel_version: vendor_product_get = "lspci -n |grep %s|awk '{print $3}'" % pciaddress diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index 035868e..2ed62af 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -75,7 +75,7 @@ class guest_install(Thread): guest_params['guesttype'] = self.type guest_params['guestname'] = self.name guest_params['kickstart'] = self.ks - macaddr = self.util.get_rand_mac() + macaddr = self.utils.get_rand_mac() guest_params['macaddr'] = macaddr # prepare disk image file @@ -124,7 +124,7 @@ def multiple_thread_block_on_domain_create(params): logger.info("the type of guest is %s" % type) logger.info("the number of guest we are going to install is %s" % num) - hypervisor = util.get_hypervisor() + hypervisor = utils.get_hypervisor() uri = params['uri'] auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_credentials, None] diff --git a/repos/remoteAccess/tcp_setup.py b/repos/remoteAccess/tcp_setup.py index dd9201b..720e380 100644 --- a/repos/remoteAccess/tcp_setup.py +++ b/repos/remoteAccess/tcp_setup.py @@ -40,7 +40,7 @@ def sasl_user_add(target_machine, username, password, util, logger): """ execute saslpasswd2 to add sasl user """ logger.info("add sasl user on server side") saslpasswd2_add = "echo %s | %s -a libvirt %s" % (password, SASLPASSWD2, username) - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, saslpasswd2_add) if ret: logger.error("failed to add sasl user") @@ -54,7 +54,7 @@ def tcp_libvirtd_set(target_machine, username, password, logger.info("setting libvirtd.conf on libvirt server") # open libvirtd --listen option listen_open_cmd = "echo 'LIBVIRTD_ARGS=\"--listen\"' >> %s" % SYSCONFIG_LIBVIRTD - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, listen_open_cmd) if ret: logger.error("failed to uncomment --listen in %s" % SYSCONFIG_LIBVIRTD) @@ -63,7 +63,7 @@ def tcp_libvirtd_set(target_machine, username, password, # set listen_tls logger.info("set listen_tls to 0 in %s" % LIBVIRTD_CONF) listen_tls_disable = "echo \"listen_tls = 0\" >> %s" % LIBVIRTD_CONF - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, listen_tls_disable) if ret: logger.error("failed to set listen_tls to 0 in %s" % LIBVIRTD_CONF) @@ -73,7 +73,7 @@ def tcp_libvirtd_set(target_machine, username, password, if listen_tcp == 'enable': logger.info("enable listen_tcp = 1 in %s" % LIBVIRTD_CONF) listen_tcp_set = "echo 'listen_tcp = 1' >> %s" % LIBVIRTD_CONF - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, listen_tcp_set) if ret: logger.error("failed to set listen_tcp in %s" % LIBVIRTD_CONF) @@ -82,7 +82,7 @@ def tcp_libvirtd_set(target_machine, username, password, # set auth_tcp logger.info("set auth_tcp to \"%s\" in %s" % (auth_tcp, LIBVIRTD_CONF)) auth_tcp_set = "echo 'auth_tcp = \"%s\"' >> %s" % (auth_tcp, LIBVIRTD_CONF) - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, auth_tcp_set) if ret: logger.error("failed to set auth_tcp in %s" % LIBVIRTD_CONF) @@ -91,7 +91,7 @@ def tcp_libvirtd_set(target_machine, username, password, # restart remote libvirtd service libvirtd_restart_cmd = "service libvirtd restart" logger.info("libvirtd restart") - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, libvirtd_restart_cmd) if ret: logger.error("failed to restart libvirtd service") @@ -169,7 +169,7 @@ def tcp_setup(params): logger.info("the value of listen_tcp is %s" % listen_tcp) logger.info("the value of auth_tcp is %s" % auth_tcp) - if not util.do_ping(target_machine, 0): + if not utils.do_ping(target_machine, 0): logger.error("failed to ping host %s" % target_machine) return 1 @@ -205,18 +205,18 @@ def tcp_setup_clean(params): if auth_tcp == 'sasl': saslpasswd2_delete = "%s -a libvirt -d %s" % (SASLPASSWD2, username) - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, saslpasswd2_delete) if ret: logger.error("failed to delete sasl user") libvirtd_conf_retore = "sed -i -n '/^[ #]/p' %s" % LIBVIRTD_CONF - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, libvirtd_conf_retore) if ret: logger.error("failed to restore %s" % LIBVIRTD_CONF) sysconfig_libvirtd_restore = "sed -i -n '/^[ #]/p' %s" % SYSCONFIG_LIBVIRTD - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, sysconfig_libvirtd_restore) if ret: logger.error("failed to restore %s" % SYSCONFIG_LIBVIRTD) diff --git a/repos/remoteAccess/tls_setup.py b/repos/remoteAccess/tls_setup.py index ea1bf68..d763e0f 100644 --- a/repos/remoteAccess/tls_setup.py +++ b/repos/remoteAccess/tls_setup.py @@ -62,7 +62,7 @@ def CA_setting_up(util, logger): logger.info("generate CA certificates") cakey_fd = open(CAKEY, 'w') - ret, out = util.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=cakey_fd) + ret, out = utils.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=cakey_fd) cakey_fd.close() if ret != 0: logger.error("failed to create CA private key") @@ -82,7 +82,7 @@ def CA_setting_up(util, logger): # Generate cacert.pem cacert_args = [CERTTOOL, '--generate-self-signed', '--load-privkey', CAKEY, '--template', cainfo] cacert_fd = open(CACERT, 'w') - ret, out = util.exec_cmd(cacert_args, outfile=cacert_fd) + ret, out = utils.exec_cmd(cacert_args, outfile=cacert_fd) cacert_fd.close() if ret != 0: logger.error("failed to create cacert.pem") @@ -97,7 +97,7 @@ def tls_server_cert(target_machine, util, logger): logger.info("generate server certificates") serverkey_fd = open(SERVERKEY, 'w') - ret, out = util.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=serverkey_fd) + ret, out = utils.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=serverkey_fd) serverkey_fd.close() if ret != 0: logger.error("failed to create server key") @@ -124,7 +124,7 @@ def tls_server_cert(target_machine, util, logger): '--template', serverinfo ] servercert_fd = open(SERVERCERT, 'w') - ret, out = util.exec_cmd(servercert_args, outfile=servercert_fd) + ret, out = utils.exec_cmd(servercert_args, outfile=servercert_fd) servercert_fd.close() if ret != 0: logger.error("failed to create servercert.pem") @@ -139,7 +139,7 @@ def tls_client_cert(local_machine, util, logger): logger.info("generate client certificates") clientkey_fd = open(CLIENTKEY, 'w') - ret, out = util.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=clientkey_fd) + ret, out = utils.exec_cmd([CERTTOOL, '--generate-privkey'], outfile=clientkey_fd) clientkey_fd.close() if ret != 0: logger.error("failed to create client key") @@ -170,7 +170,7 @@ def tls_client_cert(local_machine, util, logger): ] clientcert_fd = open(CLIENTCERT, 'w') - ret, out = util.exec_cmd(clientcert_args, outfile=clientcert_fd) + ret, out = utils.exec_cmd(clientcert_args, outfile=clientcert_fd) clientcert_fd.close() if ret != 0: logger.error("failed to create client certificates") @@ -183,53 +183,53 @@ def deliver_cert(target_machine, username, password, pkipath, util, logger): """ deliver CA, server and client certificates """ # transmit cacert.pem to remote host logger.info("deliver CA, server and client certificates to both local and remote server") - ret = util.scp_file(target_machine, username, password, CA_FOLDER, CACERT) + ret = utils.scp_file(target_machine, username, password, CA_FOLDER, CACERT) if ret: logger.error("scp cacert.pem to %s error" % target_machine) return 1 # copy cacert.pem to local CA folder cacert_cp = [CP, '-f', CACERT, (pkipath and pkipath) or CA_FOLDER] - ret, out = util.exec_cmd(cacert_cp) + ret, out = utils.exec_cmd(cacert_cp) if ret: logger.error("copying cacert.pem to %s error" % CA_FOLDER) return 1 # mkdir /etc/pki/libvirt/private on remote host libvirt_priv_cmd = "mkdir -p %s" % PRIVATE_KEY_FOLDER - ret, output = util.remote_exec_pexpect(target_machine, username, password, libvirt_priv_cmd) + ret, output = utils.remote_exec_pexpect(target_machine, username, password, libvirt_priv_cmd) if ret: logger.error("failed to make /etc/pki/libvirt/private on %s" % target_machine) return 1 # transmit serverkey.pem to remote host - ret = util.scp_file(target_machine, username, password, PRIVATE_KEY_FOLDER, SERVERKEY) + ret = utils.scp_file(target_machine, username, password, PRIVATE_KEY_FOLDER, SERVERKEY) if ret: logger.error("failed to scp serverkey.pem to %s" % target_machine) return 1 # transmit servercert.pem to remote host - ret = util.scp_file(target_machine, username, password, CERTIFICATE_FOLDER, SERVERCERT) + ret = utils.scp_file(target_machine, username, password, CERTIFICATE_FOLDER, SERVERCERT) if ret: logger.error("failed to scp servercert.pem to %s" % target_machine) return 1 libvirt_priv_cmd_local = [MKDIR, '-p', PRIVATE_KEY_FOLDER] - ret, out = util.exec_cmd(libvirt_priv_cmd_local) + ret, out = utils.exec_cmd(libvirt_priv_cmd_local) if ret: logger.error("failed to make %s on local" % PRIVATE_KEY_FOLDER) return 1 # copy clientkey.pem to local folder clientkey_cp = [CP, '-f', CLIENTKEY, (pkipath and pkipath) or PRIVATE_KEY_FOLDER] - ret, out = util.exec_cmd(clientkey_cp) + ret, out = utils.exec_cmd(clientkey_cp) if ret: logger.error("failed to copy clientkey.pem to %s" % PRIVATE_KEY_FOLDER) return 1 # copy clientcert.pem to local folder clientcert_cp = [CP, '-f', CLIENTCERT, (pkipath and pkipath) or CERTIFICATE_FOLDER] - ret, out = util.exec_cmd(clientcert_cp) + ret, out = utils.exec_cmd(clientcert_cp) if ret: logger.error("failed to copy clientcert.pem to %s" % CERTIFICATE_FOLDER) return 1 @@ -241,7 +241,7 @@ def sasl_user_add(target_machine, username, password, util, logger): """ execute saslpasswd2 to add sasl user """ logger.info("add sasl user on server side") saslpasswd2_add = "echo %s | %s -a libvirt %s" % (password, SASLPASSWD2, username) - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, saslpasswd2_add) if ret: logger.error("failed to add sasl user") @@ -255,7 +255,7 @@ def tls_libvirtd_set(target_machine, username, password, logger.info("setting libvirtd.conf on tls server") # open libvirtd --listen option listen_open_cmd = "echo 'LIBVIRTD_ARGS=\"--listen\"' >> /etc/sysconfig/libvirtd" - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, listen_open_cmd) if ret: logger.error("failed to uncomment --listen in /etc/sysconfig/libvirtd") @@ -264,7 +264,7 @@ def tls_libvirtd_set(target_machine, username, password, if listen_tls == 'disable': logger.info("set listen_tls to 0 in %s" % LIBVIRTD_CONF) listen_tls_disable = "echo \"listen_tls = 0\" >> %s" % LIBVIRTD_CONF - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, listen_tls_disable) if ret: logger.error("failed to set listen_tls to 0 in %s" % LIBVIRTD_CONF) @@ -273,7 +273,7 @@ def tls_libvirtd_set(target_machine, username, password, if auth_tls == 'sasl': logger.info("enable auth_tls = sasl in %s" % LIBVIRTD_CONF) auth_tls_set = "echo 'auth_tls = \"sasl\"' >> %s" % LIBVIRTD_CONF - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, auth_tls_set) if ret: logger.error("failed to set auth_tls to sasl in %s" % LIBVIRTD_CONF) @@ -282,7 +282,7 @@ def tls_libvirtd_set(target_machine, username, password, # restart remote libvirtd service libvirtd_restart_cmd = "service libvirtd restart" logger.info("libvirtd restart") - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, libvirtd_restart_cmd) if ret: logger.error("failed to restart libvirtd service") @@ -295,14 +295,14 @@ def iptables_stop(target_machine, username, password, util, logger): """ This is a temprory method in favor of migration """ logger.info("stop local and remote iptables temprorily") iptables_stop_cmd = "service iptables stop" - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, iptables_stop_cmd) if ret: logger.error("failed to stop remote iptables service") return 1 iptables_stop = ["service", "iptables", "stop"] - ret, out = util.exec_cmd(iptables_stop) + ret, out = utils.exec_cmd(iptables_stop) if ret: logger.error("failed to stop local iptables service") return 1 @@ -374,7 +374,7 @@ def tls_setup(params): if params.has_key('pkipath'): pkipath = params['pkipath'] if os.path.exists(pkipath): - shutil.rmtree(pkipath) + shutils.rmtree(pkipath) os.mkdir(pkipath) @@ -382,19 +382,19 @@ def tls_setup(params): if pkipath: uri += "?pkipath=%s" % pkipath - local_machine = util.get_local_hostname() + local_machine = utils.get_local_hostname() logger.info("the hostname of server is %s" % target_machine) logger.info("the hostname of local machine is %s" % local_machine) logger.info("the value of listen_tls is %s" % listen_tls) logger.info("the value of auth_tls is %s" % auth_tls) - if not util.do_ping(target_machine, 0): + if not utils.do_ping(target_machine, 0): logger.error("failed to ping host %s" % target_machine) return 1 if os.path.exists(TEMP_TLS_FOLDER): - shutil.rmtree(TEMP_TLS_FOLDER) + shutils.rmtree(TEMP_TLS_FOLDER) os.mkdir(TEMP_TLS_FOLDER) @@ -436,7 +436,7 @@ def tls_setup(params): def tls_setup_clean(params): """ cleanup testing enviroment """ if os.path.exists(TEMP_TLS_FOLDER): - shutil.rmtree(TEMP_TLS_FOLDER) + shutils.rmtree(TEMP_TLS_FOLDER) logger = params['logger'] target_machine = params['target_machine'] @@ -446,23 +446,23 @@ def tls_setup_clean(params): auth_tls = params['auth_tls'] cacert_rm = "rm -f %s/cacert.pem" % CA_FOLDER - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, cacert_rm) if ret: logger.error("failed to remove cacert.pem on remote machine") ca_libvirt_rm = "rm -rf %s" % CERTIFICATE_FOLDER - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, ca_libvirt_rm) if ret: logger.error("failed to remove libvirt folder") os.remove("%s/cacert.pem" % CA_FOLDER) - shutil.rmtree(CERTIFICATE_FOLDER) + shutils.rmtree(CERTIFICATE_FOLDER) if auth_tls == 'sasl': saslpasswd2_delete = "%s -a libvirt -d %s" % (SASLPASSWD2, username) - ret, output = util.remote_exec_pexpect(target_machine, username, + ret, output = utils.remote_exec_pexpect(target_machine, username, password, saslpasswd2_delete) if ret: logger.error("failed to delete sasl user") diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py index 6703b82..0b4beaa 100644 --- a/repos/remoteAccess/unix_perm_sasl.py +++ b/repos/remoteAccess/unix_perm_sasl.py @@ -225,9 +225,9 @@ def unix_perm_sasl_clean(params): clean_libvirtd_conf = "sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' %s" % \ LIBVIRTD_CONF - util.exec_cmd(clean_libvirtd_conf, shell=True) + utils.exec_cmd(clean_libvirtd_conf, shell=True) cmd = "service libvirtd restart" - util.exec_cmd(cmd, shell=True) + utils.exec_cmd(cmd, shell=True) return 0 diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index 39122ba..fa58610 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -57,14 +57,14 @@ def nfs_setup(util, root_squash, logger): return 1 cmd = "echo /tmp *\(rw,%s\) >> /etc/exports" % option - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to config nfs export") return 1 logger.info("restart nfs service") cmd = "service nfs restart" - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to restart nfs service") return 1 @@ -81,7 +81,7 @@ def prepare_env(util, d_ownership, virt_use_nfs, guestname, root_squash, \ """ logger.info("set virt_use_nfs selinux boolean") cmd = "setsebool virt_use_nfs %s" % virt_use_nfs - ret, out = util.exec_cmd(cmd, shell=True) + ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("failed to set virt_use_nfs SElinux boolean") return 1 @@ -98,14 +98,14 @@ def prepare_env(util, d_ownership, virt_use_nfs, guestname, root_squash, \ set_cmd = "echo dynamic_ownership = %s >> %s" % \ (option, QEMU_CONF) - ret, out = util.exec_cmd(set_cmd, shell=True) + ret, out = utils.exec_cmd(set_cmd, shell=True) if ret: logger.error("failed to set dynamic ownership") return 1 logger.info("restart libvirtd") restart_cmd = "service libvirtd restart" - ret, out = util.exec_cmd(restart_cmd, shell=True) + ret, out = utils.exec_cmd(restart_cmd, shell=True) if ret: logger.error("failed to restart libvirtd") for i in range(len(out)): @@ -130,7 +130,7 @@ def prepare_env(util, d_ownership, virt_use_nfs, guestname, root_squash, \ logger.info("mount nfs to img dir path") mount_cmd = "mount -o vers=3 127.0.0.1:/tmp %s" % img_dir - ret, out = util.exec_cmd(mount_cmd, shell=True) + ret, out = utils.exec_cmd(mount_cmd, shell=True) if ret: logger.error("Failed to mount the nfs path") for i in range(len(out)): @@ -181,7 +181,7 @@ def domain_nfs_start(params): logger.info("get guest img file path") try: dom_xml = domobj.XMLDesc(0) - disk_file = util.get_disk_path(dom_xml) + disk_file = utils.get_disk_path(dom_xml) logger.info("%s disk file path is %s" % (guestname, disk_file)) img_dir = os.path.dirname(disk_file) except libvirtError, e: @@ -331,7 +331,7 @@ def domain_nfs_start(params): filepath = "/tmp/%s" % file_name logger.info("set chown of %s as 107:107" % filepath) chown_cmd = "chown 107:107 %s" % filepath - ret, out = util.exec_cmd(chown_cmd, shell=True) + ret, out = utils.exec_cmd(chown_cmd, shell=True) if ret: logger.error("failed to chown %s to qemu:qemu" % filepath) return return_close(conn, logger, 1) @@ -447,14 +447,14 @@ def domain_nfs_start_clean(params): domobj.destroy() dom_xml = domobj.XMLDesc(0) - disk_file = util.get_disk_path(dom_xml) + disk_file = utils.get_disk_path(dom_xml) img_dir = os.path.dirname(disk_file) file_name = os.path.basename(disk_file) temp_file = "/tmp/%s" % file_name if os.path.ismount(img_dir): umount_cmd = "umount -f %s" % img_dir - ret, out = util.exec_cmd(umount_cmd, shell=True) + ret, out = utils.exec_cmd(umount_cmd, shell=True) if ret: logger.error("failed to umount %s" % img_dir) @@ -464,12 +464,12 @@ def domain_nfs_start_clean(params): conn.close() clean_nfs_conf = "sed -i '$d' /etc/exports" - util.exec_cmd(clean_nfs_conf, shell=True) + utils.exec_cmd(clean_nfs_conf, shell=True) clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF - util.exec_cmd(clean_qemu_conf, shell=True) + utils.exec_cmd(clean_qemu_conf, shell=True) cmd = "service libvirtd restart" - util.exec_cmd(cmd, shell=True) + utils.exec_cmd(cmd, shell=True) return 0 diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py index fa22c41..3c8e9ac 100644 --- a/repos/snapshot/file_flag.py +++ b/repos/snapshot/file_flag.py @@ -84,12 +84,12 @@ def file_flag(params): return return_close(conn, logger, 1) logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 300 while timeout: - ipaddr = util.mac_to_ip(mac, 180) + ipaddr = utils.mac_to_ip(mac, 180) if not ipaddr: logger.info(str(timeout) + "s left") time.sleep(10) diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py index ae10bfb..7e4976f 100644 --- a/repos/snapshot/flag_check.py +++ b/repos/snapshot/flag_check.py @@ -74,12 +74,12 @@ def flag_check(params): return return_close(conn, logger, 1) logger.info("get the mac address of vm %s" % guestname) - mac = util.get_dom_mac_addr(guestname) + mac = utils.get_dom_mac_addr(guestname) logger.info("the mac address of vm %s is %s" % (guestname, mac)) timeout = 300 while timeout: - ipaddr = util.mac_to_ip(mac, 180) + ipaddr = utils.mac_to_ip(mac, 180) if not ipaddr: logger.info(str(timeout) + "s left") time.sleep(10) diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py index 87cc0aa..f61b752 100644 --- a/repos/snapshot/internal_create.py +++ b/repos/snapshot/internal_create.py @@ -37,7 +37,7 @@ def check_domain_image(domobj, util, guestname, logger): and its disk image is the type of qcow2 """ dom_xml = domobj.XMLDesc(0) - disk_path = util.get_disk_path(dom_xml) + disk_path = utils.get_disk_path(dom_xml) status, ret = commands.getstatusoutput(QEMU_IMAGE_FORMAT % disk_path) if status: logger.error("executing "+ "\"" + QEMU_IMAGE_FORMAT % guestname + "\"" + " failed") diff --git a/repos/storage/create_logical_volume.py b/repos/storage/create_logical_volume.py index 93f1d7f..7fd191e 100644 --- a/repos/storage/create_logical_volume.py +++ b/repos/storage/create_logical_volume.py @@ -93,7 +93,7 @@ def create_logical_volume(params): volname = params['volname'] capacity = params['capacity'] - dicts = util.get_capacity_suffix_size(capacity) + dicts = utils.get_capacity_suffix_size(capacity) params['capacity'] = dicts['capacity'] params['suffix'] = dicts['suffix'] -- 1.7.7.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list