[libvirt] [test-API PATCH 0/5] Destroy class definition in utils.py

These five patches are to change utils.py into a collection of functions. And cleanup all of existing testcase to use the functions in it directly. (1) Destroy Utils class definition (2) Remove "util = utils.Utils()" (3) Substitue "util." with "utils." (4) Remove useless utils import "from utils import utils" in testcases where none of functions in utils.py is called In testcase from utils import utils ... utils.functions(...) ...

IMHO there is not any benifit to use class in a utils script, except you have to construct the object again and again in scripts. :-) Incidental cleanups: * s/parser_uri/parse_uri/ * s/#this/# This/ * Useless comments on the top are removed. --- utils/utils.py | 769 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 382 insertions(+), 387 deletions(-) diff --git a/utils/utils.py b/utils/utils.py index 7d054df..3848aca 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -13,9 +13,6 @@ # The GPL text is available in the file COPYING that accompanies this # distribution and at <http://www.gnu.org/licenses>. # -# Filename: utils.py -# Summary: basic operation on host -# Description: The module is a tool to provide basic operation on host import os import re @@ -32,402 +29,400 @@ import subprocess from xml.dom import minidom from urlparse import urlparse -class Utils(object): - """Basic operation on host""" - def get_hypervisor(self): - if commands.getoutput("lsmod | grep kvm"): - return 'kvm' - elif os.access("/proc/xen", os.R_OK): - return 'xen' - else: - return 'no any hypervisor is running.' - - def get_uri(self, ip): - """Get hypervisor uri""" - hypervisor = self.get_hypervisor() - if ip == "127.0.0.1": - if hypervisor == "xen": - uri = "xen:///" - if hypervisor == "kvm": - uri = "qemu:///system" - else: - if hypervisor == "xen": - uri = "xen+ssh://%s" % ip - if hypervisor == "kvm": - uri = "qemu+ssh://%s/system" % ip - return uri - - def parser_uri(self, uri): - #this is a simple parser for uri - return urlparse(uri) - - def get_host_arch(self): - ret = commands.getoutput('uname -a') - arch = ret.split(" ")[-2] - return arch - - def get_local_hostname(self): - """ get local host name """ - return socket.gethostname() - - def get_libvirt_version(self, ver = ''): - ver = commands.getoutput("rpm -q libvirt|head -1") - if ver.split('-')[0] == 'libvirt': - return ver +def get_hypervisor(): + if commands.getoutput("lsmod | grep kvm"): + return 'kvm' + elif os.access("/proc/xen", os.R_OK): + return 'xen' + else: + return 'no any hypervisor is running.' + +def get_uri(ip): + """Get hypervisor uri""" + hypervisor = get_hypervisor() + if ip == "127.0.0.1": + if hypervisor == "xen": + uri = "xen:///" + if hypervisor == "kvm": + uri = "qemu:///system" + else: + if hypervisor == "xen": + uri = "xen+ssh://%s" % ip + if hypervisor == "kvm": + uri = "qemu+ssh://%s/system" % ip + return uri + +def parse_uri(uri): + # This is a simple parser for uri + return urlparse(uri) + +def get_host_arch(): + ret = commands.getoutput('uname -a') + arch = ret.split(" ")[-2] + return arch + +def get_local_hostname(): + """ get local host name """ + return socket.gethostname() + +def get_libvirt_version(ver = ''): + ver = commands.getoutput("rpm -q libvirt|head -1") + if ver.split('-')[0] == 'libvirt': + return ver + else: + print "Missing libvirt package!" + sys.exit(1) + +def get_hypervisor_version(ver = ''): + hypervisor = get_hypervisor() + + if 'kvm' in hypervisor: + kernel_ver = get_host_kernel_version() + if 'el5' in kernel_ver: + ver = commands.getoutput("rpm -q kvm") + elif 'el6' in kernel_ver: + ver = commands.getoutput("rpm -q qemu-kvm") else: - print "Missing libvirt package!" + print "Unsupported kernel type!" sys.exit(1) - - def get_hypervisor_version(self, ver = ''): - hypervisor = self.get_hypervisor() - - if 'kvm' in hypervisor: - kernel_ver = self.get_host_kernel_version() - if 'el5' in kernel_ver: - ver = commands.getoutput("rpm -q kvm") - elif 'el6' in kernel_ver: - ver = commands.getoutput("rpm -q qemu-kvm") - else: - print "Unsupported kernel type!" - sys.exit(1) - elif 'xen' in hypervisor: - ver = commands.getoutput("rpm -q xen") + elif 'xen' in hypervisor: + ver = commands.getoutput("rpm -q xen") + else: + print "Unsupported hypervisor type!" + sys.exit(1) + + return ver + +def get_host_kernel_version(): + kernel_ver = commands.getoutput('uname -r') + return kernel_ver + +def get_ip_address(ifname): + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + return socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]))[20:24]) + + +def get_host_cpus(): + if not os.access("/proc/cpuinfo", os.R_OK): + print "warning:os error" + sys.exit(1) + else: + cmd = "cat /proc/cpuinfo | grep '^processor'|wc -l" + cpus = int(commands.getoutput(cmd)) + if cpus: + return cpus else: - print "Unsupported hypervisor type!" - sys.exit(1) - - return ver - - def get_host_kernel_version(self): - kernel_ver = commands.getoutput('uname -r') - return kernel_ver - - def get_ip_address(self, ifname): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]))[20:24]) - - - def get_host_cpus(self): - if not os.access("/proc/cpuinfo", os.R_OK): - print "warning:os error" - sys.exit(1) + print "warnning:don't get system cpu number" + +def get_host_frequency(): + if not os.access("/proc/cpuinfo", os.R_OK): + print "warning:os error" + sys.exit(1) + else: + cmd = "cat /proc/cpuinfo | grep 'cpu MHz'|uniq" + cpufreq = commands.getoutput(cmd) + if cpufreq: + freq = cpufreq.split(":")[1].split(" ")[1] + return freq else: - cmd = "cat /proc/cpuinfo | grep '^processor'|wc -l" - cpus = int(commands.getoutput(cmd)) - if cpus: - return cpus - else: - print "warnning:don't get system cpu number" - - def get_host_frequency(self): - if not os.access("/proc/cpuinfo", os.R_OK): - print "warning:os error" - sys.exit(1) + print "warnning:don't get system cpu frequency" + +def get_host_memory(): + if not os.access("/proc/meminfo", os.R_OK): + print "please check os." + sys.exit(1) + else: + cmd = "cat /proc/meminfo | egrep 'MemTotal'" + ret = commands.getoutput(cmd) + strMem = ret.split(":")[1] + mem_num = strMem.split("kB")[0] + mem_size = int(mem_num.strip()) + if mem_size: + return mem_size else: - cmd = "cat /proc/cpuinfo | grep 'cpu MHz'|uniq" - cpufreq = commands.getoutput(cmd) - if cpufreq: - freq = cpufreq.split(":")[1].split(" ")[1] - return freq - else: - print "warnning:don't get system cpu frequency" - - def get_host_memory(self): - if not os.access("/proc/meminfo", os.R_OK): - print "please check os." - sys.exit(1) + print "warnning:don't get os memory" + +def get_vcpus_list(): + host_cpus = get_host_cpus() + max_vcpus = host_cpus * 4 + vcpus_list = [] + n = 0 + while 2**n <= max_vcpus: + vcpus_list.append(2**n) + n += 1 + return vcpus_list + +def get_memory_list(): + host_mem = get_host_memory() + mem_list = [] + i = 10 + while 2**i*1024 <= host_mem: + mem_list.append(2**i) + i += 1 + return mem_list + +def get_curr_time(): + curr_time = time.strftime('%Y-%m-%d %H:%M:%S') + return curr_time + +def get_rand_uuid(): + return file('/proc/sys/kernel/random/uuid').readline().strip() + +def get_rand_mac(): + mac = [] + mac.append(0x54) + mac.append(0x52) + mac.append(0x00) + i = 0 + while i < 3: + mac.append(random.randint(0x00, 0xff)) + i += 1 + return ':'.join(map (lambda x: "%02x" % x, mac)) + +def get_dom_mac_addr(domname): + """Get mac address of a domain + + Return mac address on SUCCESS or None on FAILURE + """ + cmd = \ + "virsh dumpxml " + domname \ + + " | grep 'mac address' | awk -F'=' '{print $2}' | tr -d \"[\'/>]\"" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_num_vcpus(domname): + """Get mac address of a domain + Return mac address on SUCCESS or None on FAILURE + """ + cmd = "virsh dumpxml " + domname + \ + " | grep 'vcpu' | awk -F'<' '{print $2}' | awk -F'>' '{print $2}'" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_size_mem(domname): + """Get mem size of a domain + Return mem size on SUCCESS or None on FAILURE + """ + cmd = "virsh dumpxml " + domname + \ + " | grep 'currentMemory'|awk -F'<' '{print $2}'|awk -F'>' '{print $2}'" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_disk_path(dom_xml): + """Get full path of bootable disk image of domain + Return mac address on SUCCESS or None on FAILURE + """ + doc = minidom.parseString(dom_xml) + disk_list = doc.getElementsByTagName('disk') + source = disk_list[0].getElementsByTagName('source')[0] + attribute = source.attributes.keys()[0] + + return source.attributes[attribute].value + +def get_capacity_suffix_size(capacity): + dicts = {} + change_to_byte = {'K':pow(2, 10), 'M':pow(2, 20), 'G':pow(2, 30), + 'T':pow(2, 40)} + for suffix in change_to_byte.keys(): + if capacity.endswith(suffix): + dicts['suffix'] = suffix + dicts['capacity'] = capacity.split(suffix)[0] + dicts['capacity_byte'] = \ + int(dicts['capacity']) * change_to_byte[suffix] + return dicts + +def dev_num(guestname, device): + """Get disk or interface number in the guest""" + cur = commands.getoutput("pwd") + cmd = "sh %s/utils/dev_num.sh %s %s" % (cur, guestname, device) + num = int(commands.getoutput(cmd)) + if num: + return num + else: + return None + +def stop_selinux(): + selinux_value = commands.getoutput("getenforce") + if selinux_value == "Enforcing": + os.system("setenforce 0") + if commands.getoutput("getenforce") == "Permissive": + return "selinux is disabled" else: - cmd = "cat /proc/meminfo | egrep 'MemTotal'" - ret = commands.getoutput(cmd) - strMem = ret.split(":")[1] - mem_num = strMem.split("kB")[0] - mem_size = int(mem_num.strip()) - if mem_size: - return mem_size - else: - print "warnning:don't get os memory" - - def get_vcpus_list(self): - host_cpus = self.get_host_cpus() - max_vcpus = host_cpus * 4 - vcpus_list = [] - n = 0 - while 2**n <= max_vcpus: - vcpus_list.append(2**n) - n += 1 - return vcpus_list - - def get_memory_list(self): - host_mem = self.get_host_memory() - mem_list = [] - i = 10 - while 2**i*1024 <= host_mem: - mem_list.append(2**i) - i += 1 - return mem_list - - def get_curr_time(self): - curr_time = time.strftime('%Y-%m-%d %H:%M:%S') - return curr_time - - def get_rand_uuid(self): - return file('/proc/sys/kernel/random/uuid').readline().strip() - - def get_rand_mac(self): - mac = [] - mac.append(0x54) - mac.append(0x52) - mac.append(0x00) - i = 0 - while i < 3: - mac.append(random.randint(0x00, 0xff)) - i += 1 - return ':'.join(map (lambda x: "%02x" % x, mac)) - - def get_dom_mac_addr(self, domname): - """Get mac address of a domain - - Return mac address on SUCCESS or None on FAILURE - """ - cmd = \ - "virsh dumpxml " + domname \ - + " | grep 'mac address' | awk -F'=' '{print $2}' | tr -d \"[\'/>]\"" - + return "Failed to stop selinux" + else: + return "selinux is disabled" + +def stop_firewall(ip): + stopfire = "" + if ip == "127.0.0.1": + stopfire = commands.getoutput("service iptables stop") + else: + stopfire = commands.getoutput("ssh %s service iptables stop") %ip + if stopfire.find("stopped"): + print "Firewall is stopped." + else: + print "Failed to stop firewall" + sys.exit(1) + +def print_section(title): + print "\n%s" % title + print "=" * 60 + +def print_entry(key, value): + print "%-10s %-10s" % (key, value) + +def print_xml(key, ctx, path): + res = ctx.xpathEval(path) + if res is None or len(res) == 0: + value = "Unknown" + else: + value = res[0].content + print_entry(key, value) + return value + +def print_title(info, delimiter, num): + curr_time = get_curr_time() + blank = ' '*(num/2 - (len(info) + 8 + len(curr_time))/2) + print delimiter * num + print "%s%s\t%s" % (blank, info, curr_time) + print delimiter * num + +def file_read(file): + if os.path.exists(file): + fh = open(file, 'r') + theData = fh.read() + fh.close() + return theData + else: + print "The FILE %s doesn't exist." % file + +def parse_xml(file, element): + xmldoc = minidom.parse(file) + elementlist = xmldoc.getElementsByTagName(element) + return elementlist + +def locate_utils(): + """Get the directory path of 'utils'""" + pwd = os.getcwd() + result = re.search('(.*)libvirt-test-API(.*)', pwd) + return result.group(0) + "/utils" + +def mac_to_ip(mac, timeout): + """Map mac address to ip + + Return None on FAILURE and the mac address on SUCCESS + """ + if not mac: + return None + + if timeout < 10: + timeout = 10 + + cmd = "sh " + locate_utils() + "/ipget.sh " + mac + + while timeout > 0: (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None + if not out.lstrip() == "": + break - def get_num_vcpus(self, domname): - """Get mac address of a domain - Return mac address on SUCCESS or None on FAILURE - """ - cmd = "virsh dumpxml " + domname + \ - " | grep 'vcpu' | awk -F'<' '{print $2}' | awk -F'>' '{print $2}'" + timeout -= 10 - (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None + return timeout and out or None - def get_size_mem(self, domname): - """Get mem size of a domain - Return mem size on SUCCESS or None on FAILURE - """ - cmd = "virsh dumpxml " + domname + \ - " | grep 'currentMemory'|awk -F'<' '{print $2}'|awk -F'>' '{print $2}'" +def do_ping(ip, timeout): + """Ping some host - (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None - - def get_disk_path(self, dom_xml): - """Get full path of bootable disk image of domain - Return mac address on SUCCESS or None on FAILURE - """ - doc = minidom.parseString(dom_xml) - disk_list = doc.getElementsByTagName('disk') - source = disk_list[0].getElementsByTagName('source')[0] - attribute = source.attributes.keys()[0] - - return source.attributes[attribute].value - - def get_capacity_suffix_size(self, capacity): - dicts = {} - change_to_byte = {'K':pow(2, 10), 'M':pow(2, 20), 'G':pow(2, 30), - 'T':pow(2, 40)} - for suffix in change_to_byte.keys(): - if capacity.endswith(suffix): - dicts['suffix'] = suffix - dicts['capacity'] = capacity.split(suffix)[0] - dicts['capacity_byte'] = \ - int(dicts['capacity']) * change_to_byte[suffix] - return dicts - - def dev_num(self, guestname, device): - """Get disk or interface number in the guest""" - cur = commands.getoutput("pwd") - cmd = "sh %s/utils/dev_num.sh %s %s" % (cur, guestname, device) - num = int(commands.getoutput(cmd)) - if num: - return num - else: - return None - - def stop_selinux(self): - selinux_value = commands.getoutput("getenforce") - if selinux_value == "Enforcing": - os.system("setenforce 0") - if commands.getoutput("getenforce") == "Permissive": - return "selinux is disabled" - else: - return "Failed to stop selinux" - else: - return "selinux is disabled" - - def stop_firewall(self, ip): - stopfire = "" - if ip == "127.0.0.1": - stopfire = commands.getoutput("service iptables stop") - else: - stopfire = commands.getoutput("ssh %s service iptables stop") %ip - if stopfire.find("stopped"): - print "Firewall is stopped." - else: - print "Failed to stop firewall" - sys.exit(1) + return True on success or False on Failure + timeout should be greater or equal to 10 + """ + if not ip: + return False - def print_section(self, title): - print "\n%s" % title - print "=" * 60 + if timeout < 10: + timeout = 10 - def print_entry(self, key, value): - print "%-10s %-10s" % (key, value) + cmd = "ping -c 3 " + str(ip) - def print_xml(self, key, ctx, path): - res = ctx.xpathEval(path) - if res is None or len(res) == 0: - value = "Unknown" - else: - value = res[0].content - print_entry(key, value) - return value - - def print_title(self, info, delimiter, num): - curr_time = self.get_curr_time() - blank = ' '*(num/2 - (len(info) + 8 + len(curr_time))/2) - print delimiter * num - print "%s%s\t%s" % (blank, info, curr_time) - print delimiter * num - - def file_read(self, file): - if os.path.exists(file): - fh = open(file, 'r') - theData = fh.read() - fh.close() - return theData + while timeout > 0: + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + break + timeout -= 10 + + return (timeout and 1) or 0 + +def exec_cmd(command, sudo=False, cwd=None, infile=None, outfile=None, shell=False, data=None): + """ + Executes an external command, optionally via sudo. + """ + if sudo: + if type(command) == type(""): + command = "sudo " + command else: - print "The FILE %s doesn't exist." % file - - def parse_xml(file, element): - xmldoc = minidom.parse(file) - elementlist = xmldoc.getElementsByTagName(element) - return elementlist - - def locate_utils(self): - """Get the directory path of 'utils'""" - pwd = os.getcwd() - result = re.search('(.*)libvirt-test-API(.*)', pwd) - return result.group(0) + "/utils" - - def mac_to_ip(self, mac, timeout): - """Map mac address to ip - - Return None on FAILURE and the mac address on SUCCESS - """ - if not mac: - return None - - if timeout < 10: - timeout = 10 - - cmd = "sh " + self.locate_utils() + "/ipget.sh " + mac - - while timeout > 0: - (ret, out) = commands.getstatusoutput(cmd) - if not out.lstrip() == "": - break - - timeout -= 10 - - return timeout and out or None - - def do_ping(self, ip, timeout): - """Ping some host - - return True on success or False on Failure - timeout should be greater or equal to 10 - """ - if not ip: - return False - - if timeout < 10: - timeout = 10 - - cmd = "ping -c 3 " + str(ip) - - while timeout > 0: - (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - break - timeout -= 10 - - return (timeout and 1) or 0 - - def exec_cmd(self, command, sudo=False, cwd=None, infile=None, outfile=None, shell=False, data=None): - """ - Executes an external command, optionally via sudo. - """ - if sudo: - if type(command) == type(""): - command = "sudo " + command - else: - command = ["sudo"] + command - if infile == None: - infile = subprocess.PIPE - if outfile == None: - outfile = subprocess.PIPE - p = subprocess.Popen(command, shell=shell, close_fds=True, cwd=cwd, - stdin=infile, stdout=outfile, stderr=subprocess.PIPE) - (out, err) = p.communicate(data) - if out == None: - # Prevent splitlines() from barfing later on - out = "" - return (p.returncode, out.splitlines()) - - def remote_exec_pexpect(self, hostname, username, password, cmd): - """ Remote exec function via pexpect """ - user_hostname = "%s@%s" % (username, hostname) - child = pexpect.spawn("/usr/bin/ssh", [user_hostname, cmd], - timeout = 60, maxread = 2000, logfile = None) - while True: - index = child.expect(['(yes\/no)', 'password:', pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - child.close() - return 0, child.before - elif index == 3: - child.close() - return 1, "" - - return 0 - - def scp_file(self, hostname, username, password, target_path, file): - """ Scp file to remote host """ - user_hostname = "%s@%s:%s" % (username, hostname, target_path) - child = pexpect.spawn("/usr/bin/scp", [file, user_hostname]) - while True: - index = child.expect(['yes\/no', 'password: ', - pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - child.close() - return 0 - elif index == 3: - child.close() - return 1 - - return 0 + command = ["sudo"] + command + if infile == None: + infile = subprocess.PIPE + if outfile == None: + outfile = subprocess.PIPE + p = subprocess.Popen(command, shell=shell, close_fds=True, cwd=cwd, + stdin=infile, stdout=outfile, stderr=subprocess.PIPE) + (out, err) = p.communicate(data) + if out == None: + # Prevent splitlines() from barfing later on + out = "" + return (p.returncode, out.splitlines()) + +def remote_exec_pexpect(hostname, username, password, cmd): + """ Remote exec function via pexpect """ + user_hostname = "%s@%s" % (username, hostname) + child = pexpect.spawn("/usr/bin/ssh", [user_hostname, cmd], + timeout = 60, maxread = 2000, logfile = None) + while True: + index = child.expect(['(yes\/no)', 'password:', pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("yes") + elif index == 1: + child.sendline(password) + elif index == 2: + child.close() + return 0, child.before + elif index == 3: + child.close() + return 1, "" + + return 0 + +def scp_file(hostname, username, password, target_path, file): + """ Scp file to remote host """ + user_hostname = "%s@%s:%s" % (username, hostname, target_path) + child = pexpect.spawn("/usr/bin/scp", [file, user_hostname]) + while True: + index = child.expect(['yes\/no', 'password: ', + pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("yes") + elif index == 1: + child.sendline(password) + elif index == 2: + child.close() + return 0 + elif index == 3: + child.close() + return 1 + + return 0 -- 1.7.7.5

On 04/10/2012 03:34 PM, Osier Yang wrote:
IMHO there is not any benifit to use class in a utils script, except you have to construct the object again and again in scripts. :-)
Incidental cleanups: * s/parser_uri/parse_uri/ * s/#this/# This/ * Useless comments on the top are removed. --- utils/utils.py | 769 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 382 insertions(+), 387 deletions(-)
diff --git a/utils/utils.py b/utils/utils.py index 7d054df..3848aca 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -13,9 +13,6 @@ # The GPL text is available in the file COPYING that accompanies this # distribution and at<http://www.gnu.org/licenses>. # -# Filename: utils.py -# Summary: basic operation on host -# Description: The module is a tool to provide basic operation on host
import os import re @@ -32,402 +29,400 @@ import subprocess from xml.dom import minidom from urlparse import urlparse
-class Utils(object): - """Basic operation on host""" - def get_hypervisor(self): - if commands.getoutput("lsmod | grep kvm"): - return 'kvm' - elif os.access("/proc/xen", os.R_OK): - return 'xen' - else: - return 'no any hypervisor is running.' - - def get_uri(self, ip): - """Get hypervisor uri""" - hypervisor = self.get_hypervisor() - if ip == "127.0.0.1": - if hypervisor == "xen": - uri = "xen:///" - if hypervisor == "kvm": - uri = "qemu:///system" - else: - if hypervisor == "xen": - uri = "xen+ssh://%s" % ip - if hypervisor == "kvm": - uri = "qemu+ssh://%s/system" % ip - return uri - - def parser_uri(self, uri): - #this is a simple parser for uri - return urlparse(uri) - - def get_host_arch(self): - ret = commands.getoutput('uname -a') - arch = ret.split(" ")[-2] - return arch - - def get_local_hostname(self): - """ get local host name """ - return socket.gethostname() - - def get_libvirt_version(self, ver = ''): - ver = commands.getoutput("rpm -q libvirt|head -1") - if ver.split('-')[0] == 'libvirt': - return ver +def get_hypervisor(): + if commands.getoutput("lsmod | grep kvm"): + return 'kvm' + elif os.access("/proc/xen", os.R_OK): + return 'xen' + else: + return 'no any hypervisor is running.' + +def get_uri(ip): + """Get hypervisor uri""" + hypervisor = get_hypervisor() + if ip == "127.0.0.1": + if hypervisor == "xen": + uri = "xen:///" + if hypervisor == "kvm": + uri = "qemu:///system" + else: + if hypervisor == "xen": + uri = "xen+ssh://%s" % ip + if hypervisor == "kvm": + uri = "qemu+ssh://%s/system" % ip + return uri + +def parse_uri(uri): + # This is a simple parser for uri + return urlparse(uri) + +def get_host_arch(): + ret = commands.getoutput('uname -a') + arch = ret.split(" ")[-2] + return arch + +def get_local_hostname(): + """ get local host name """ + return socket.gethostname() + +def get_libvirt_version(ver = ''): + ver = commands.getoutput("rpm -q libvirt|head -1") + if ver.split('-')[0] == 'libvirt': + return ver + else: + print "Missing libvirt package!" + sys.exit(1) + +def get_hypervisor_version(ver = ''): + hypervisor = get_hypervisor() + + if 'kvm' in hypervisor: + kernel_ver = get_host_kernel_version() + if 'el5' in kernel_ver: + ver = commands.getoutput("rpm -q kvm") + elif 'el6' in kernel_ver: + ver = commands.getoutput("rpm -q qemu-kvm") else: - print "Missing libvirt package!" + print "Unsupported kernel type!" sys.exit(1) - - def get_hypervisor_version(self, ver = ''): - hypervisor = self.get_hypervisor() - - if 'kvm' in hypervisor: - kernel_ver = self.get_host_kernel_version() - if 'el5' in kernel_ver: - ver = commands.getoutput("rpm -q kvm") - elif 'el6' in kernel_ver: - ver = commands.getoutput("rpm -q qemu-kvm") - else: - print "Unsupported kernel type!" - sys.exit(1) - elif 'xen' in hypervisor: - ver = commands.getoutput("rpm -q xen") + elif 'xen' in hypervisor: + ver = commands.getoutput("rpm -q xen") + else: + print "Unsupported hypervisor type!" + sys.exit(1) + + return ver + +def get_host_kernel_version(): + kernel_ver = commands.getoutput('uname -r') + return kernel_ver + +def get_ip_address(ifname): + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + return socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]))[20:24]) + + +def get_host_cpus(): + if not os.access("/proc/cpuinfo", os.R_OK): + print "warning:os error" + sys.exit(1) + else: + cmd = "cat /proc/cpuinfo | grep '^processor'|wc -l" + cpus = int(commands.getoutput(cmd)) + if cpus: + return cpus else: - print "Unsupported hypervisor type!" - sys.exit(1) - - return ver - - def get_host_kernel_version(self): - kernel_ver = commands.getoutput('uname -r') - return kernel_ver - - def get_ip_address(self, ifname): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]))[20:24]) - - - def get_host_cpus(self): - if not os.access("/proc/cpuinfo", os.R_OK): - print "warning:os error" - sys.exit(1) + print "warnning:don't get system cpu number" + +def get_host_frequency(): + if not os.access("/proc/cpuinfo", os.R_OK): + print "warning:os error" + sys.exit(1) + else: + cmd = "cat /proc/cpuinfo | grep 'cpu MHz'|uniq" + cpufreq = commands.getoutput(cmd) + if cpufreq: + freq = cpufreq.split(":")[1].split(" ")[1] + return freq else: - cmd = "cat /proc/cpuinfo | grep '^processor'|wc -l" - cpus = int(commands.getoutput(cmd)) - if cpus: - return cpus - else: - print "warnning:don't get system cpu number" - - def get_host_frequency(self): - if not os.access("/proc/cpuinfo", os.R_OK): - print "warning:os error" - sys.exit(1) + print "warnning:don't get system cpu frequency" + +def get_host_memory(): + if not os.access("/proc/meminfo", os.R_OK): + print "please check os." + sys.exit(1) + else: + cmd = "cat /proc/meminfo | egrep 'MemTotal'" + ret = commands.getoutput(cmd) + strMem = ret.split(":")[1] + mem_num = strMem.split("kB")[0] + mem_size = int(mem_num.strip()) + if mem_size: + return mem_size else: - cmd = "cat /proc/cpuinfo | grep 'cpu MHz'|uniq" - cpufreq = commands.getoutput(cmd) - if cpufreq: - freq = cpufreq.split(":")[1].split(" ")[1] - return freq - else: - print "warnning:don't get system cpu frequency" - - def get_host_memory(self): - if not os.access("/proc/meminfo", os.R_OK): - print "please check os." - sys.exit(1) + print "warnning:don't get os memory" + +def get_vcpus_list(): + host_cpus = get_host_cpus() + max_vcpus = host_cpus * 4 + vcpus_list = [] + n = 0 + while 2**n<= max_vcpus: + vcpus_list.append(2**n) + n += 1 + return vcpus_list + +def get_memory_list(): + host_mem = get_host_memory() + mem_list = [] + i = 10 + while 2**i*1024<= host_mem: + mem_list.append(2**i) + i += 1 + return mem_list + +def get_curr_time(): + curr_time = time.strftime('%Y-%m-%d %H:%M:%S') + return curr_time + +def get_rand_uuid(): + return file('/proc/sys/kernel/random/uuid').readline().strip() + +def get_rand_mac(): + mac = [] + mac.append(0x54) + mac.append(0x52) + mac.append(0x00) + i = 0 + while i< 3: + mac.append(random.randint(0x00, 0xff)) + i += 1 + return ':'.join(map (lambda x: "%02x" % x, mac)) + +def get_dom_mac_addr(domname): + """Get mac address of a domain + + Return mac address on SUCCESS or None on FAILURE + """ + cmd = \ + "virsh dumpxml " + domname \ + + " | grep 'mac address' | awk -F'=' '{print $2}' | tr -d \"[\'/>]\"" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_num_vcpus(domname): + """Get mac address of a domain + Return mac address on SUCCESS or None on FAILURE + """ + cmd = "virsh dumpxml " + domname + \ + " | grep 'vcpu' | awk -F'<' '{print $2}' | awk -F'>' '{print $2}'" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_size_mem(domname): + """Get mem size of a domain + Return mem size on SUCCESS or None on FAILURE + """ + cmd = "virsh dumpxml " + domname + \ + " | grep 'currentMemory'|awk -F'<' '{print $2}'|awk -F'>' '{print $2}'" + + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + return out + else: + return None + +def get_disk_path(dom_xml): + """Get full path of bootable disk image of domain + Return mac address on SUCCESS or None on FAILURE + """ + doc = minidom.parseString(dom_xml) + disk_list = doc.getElementsByTagName('disk') + source = disk_list[0].getElementsByTagName('source')[0] + attribute = source.attributes.keys()[0] + + return source.attributes[attribute].value + +def get_capacity_suffix_size(capacity): + dicts = {} + change_to_byte = {'K':pow(2, 10), 'M':pow(2, 20), 'G':pow(2, 30), + 'T':pow(2, 40)} + for suffix in change_to_byte.keys(): + if capacity.endswith(suffix): + dicts['suffix'] = suffix + dicts['capacity'] = capacity.split(suffix)[0] + dicts['capacity_byte'] = \ + int(dicts['capacity']) * change_to_byte[suffix] + return dicts + +def dev_num(guestname, device): + """Get disk or interface number in the guest""" + cur = commands.getoutput("pwd") + cmd = "sh %s/utils/dev_num.sh %s %s" % (cur, guestname, device) + num = int(commands.getoutput(cmd)) + if num: + return num + else: + return None + +def stop_selinux(): + selinux_value = commands.getoutput("getenforce") + if selinux_value == "Enforcing": + os.system("setenforce 0") + if commands.getoutput("getenforce") == "Permissive": + return "selinux is disabled" else: - cmd = "cat /proc/meminfo | egrep 'MemTotal'" - ret = commands.getoutput(cmd) - strMem = ret.split(":")[1] - mem_num = strMem.split("kB")[0] - mem_size = int(mem_num.strip()) - if mem_size: - return mem_size - else: - print "warnning:don't get os memory" - - def get_vcpus_list(self): - host_cpus = self.get_host_cpus() - max_vcpus = host_cpus * 4 - vcpus_list = [] - n = 0 - while 2**n<= max_vcpus: - vcpus_list.append(2**n) - n += 1 - return vcpus_list - - def get_memory_list(self): - host_mem = self.get_host_memory() - mem_list = [] - i = 10 - while 2**i*1024<= host_mem: - mem_list.append(2**i) - i += 1 - return mem_list - - def get_curr_time(self): - curr_time = time.strftime('%Y-%m-%d %H:%M:%S') - return curr_time - - def get_rand_uuid(self): - return file('/proc/sys/kernel/random/uuid').readline().strip() - - def get_rand_mac(self): - mac = [] - mac.append(0x54) - mac.append(0x52) - mac.append(0x00) - i = 0 - while i< 3: - mac.append(random.randint(0x00, 0xff)) - i += 1 - return ':'.join(map (lambda x: "%02x" % x, mac)) - - def get_dom_mac_addr(self, domname): - """Get mac address of a domain - - Return mac address on SUCCESS or None on FAILURE - """ - cmd = \ - "virsh dumpxml " + domname \ - + " | grep 'mac address' | awk -F'=' '{print $2}' | tr -d \"[\'/>]\"" - + return "Failed to stop selinux" + else: + return "selinux is disabled" + +def stop_firewall(ip): + stopfire = "" + if ip == "127.0.0.1": + stopfire = commands.getoutput("service iptables stop") + else: + stopfire = commands.getoutput("ssh %s service iptables stop") %ip + if stopfire.find("stopped"): + print "Firewall is stopped." + else: + print "Failed to stop firewall" + sys.exit(1) + +def print_section(title): + print "\n%s" % title + print "=" * 60 + +def print_entry(key, value): + print "%-10s %-10s" % (key, value) + +def print_xml(key, ctx, path): + res = ctx.xpathEval(path) + if res is None or len(res) == 0: + value = "Unknown" + else: + value = res[0].content + print_entry(key, value) + return value + +def print_title(info, delimiter, num): + curr_time = get_curr_time() + blank = ' '*(num/2 - (len(info) + 8 + len(curr_time))/2) + print delimiter * num + print "%s%s\t%s" % (blank, info, curr_time) + print delimiter * num + +def file_read(file): + if os.path.exists(file): + fh = open(file, 'r') + theData = fh.read() + fh.close() + return theData + else: + print "The FILE %s doesn't exist." % file + +def parse_xml(file, element): + xmldoc = minidom.parse(file) + elementlist = xmldoc.getElementsByTagName(element) + return elementlist + +def locate_utils(): + """Get the directory path of 'utils'""" + pwd = os.getcwd() + result = re.search('(.*)libvirt-test-API(.*)', pwd) + return result.group(0) + "/utils" + +def mac_to_ip(mac, timeout): + """Map mac address to ip + + Return None on FAILURE and the mac address on SUCCESS + """ + if not mac: + return None + + if timeout< 10: + timeout = 10 + + cmd = "sh " + locate_utils() + "/ipget.sh " + mac + + while timeout> 0: (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None + if not out.lstrip() == "": + break
- def get_num_vcpus(self, domname): - """Get mac address of a domain - Return mac address on SUCCESS or None on FAILURE - """ - cmd = "virsh dumpxml " + domname + \ - " | grep 'vcpu' | awk -F'<' '{print $2}' | awk -F'>' '{print $2}'" + timeout -= 10
- (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None + return timeout and out or None
- def get_size_mem(self, domname): - """Get mem size of a domain - Return mem size on SUCCESS or None on FAILURE - """ - cmd = "virsh dumpxml " + domname + \ - " | grep 'currentMemory'|awk -F'<' '{print $2}'|awk -F'>' '{print $2}'" +def do_ping(ip, timeout): + """Ping some host
- (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - return out - else: - return None - - def get_disk_path(self, dom_xml): - """Get full path of bootable disk image of domain - Return mac address on SUCCESS or None on FAILURE - """ - doc = minidom.parseString(dom_xml) - disk_list = doc.getElementsByTagName('disk') - source = disk_list[0].getElementsByTagName('source')[0] - attribute = source.attributes.keys()[0] - - return source.attributes[attribute].value - - def get_capacity_suffix_size(self, capacity): - dicts = {} - change_to_byte = {'K':pow(2, 10), 'M':pow(2, 20), 'G':pow(2, 30), - 'T':pow(2, 40)} - for suffix in change_to_byte.keys(): - if capacity.endswith(suffix): - dicts['suffix'] = suffix - dicts['capacity'] = capacity.split(suffix)[0] - dicts['capacity_byte'] = \ - int(dicts['capacity']) * change_to_byte[suffix] - return dicts - - def dev_num(self, guestname, device): - """Get disk or interface number in the guest""" - cur = commands.getoutput("pwd") - cmd = "sh %s/utils/dev_num.sh %s %s" % (cur, guestname, device) - num = int(commands.getoutput(cmd)) - if num: - return num - else: - return None - - def stop_selinux(self): - selinux_value = commands.getoutput("getenforce") - if selinux_value == "Enforcing": - os.system("setenforce 0") - if commands.getoutput("getenforce") == "Permissive": - return "selinux is disabled" - else: - return "Failed to stop selinux" - else: - return "selinux is disabled" - - def stop_firewall(self, ip): - stopfire = "" - if ip == "127.0.0.1": - stopfire = commands.getoutput("service iptables stop") - else: - stopfire = commands.getoutput("ssh %s service iptables stop") %ip - if stopfire.find("stopped"): - print "Firewall is stopped." - else: - print "Failed to stop firewall" - sys.exit(1) + return True on success or False on Failure + timeout should be greater or equal to 10 + """ + if not ip: + return False
- def print_section(self, title): - print "\n%s" % title - print "=" * 60 + if timeout< 10: + timeout = 10
- def print_entry(self, key, value): - print "%-10s %-10s" % (key, value) + cmd = "ping -c 3 " + str(ip)
- def print_xml(self, key, ctx, path): - res = ctx.xpathEval(path) - if res is None or len(res) == 0: - value = "Unknown" - else: - value = res[0].content - print_entry(key, value) - return value - - def print_title(self, info, delimiter, num): - curr_time = self.get_curr_time() - blank = ' '*(num/2 - (len(info) + 8 + len(curr_time))/2) - print delimiter * num - print "%s%s\t%s" % (blank, info, curr_time) - print delimiter * num - - def file_read(self, file): - if os.path.exists(file): - fh = open(file, 'r') - theData = fh.read() - fh.close() - return theData + while timeout> 0: + (ret, out) = commands.getstatusoutput(cmd) + if ret == 0: + break + timeout -= 10 + + return (timeout and 1) or 0 + +def exec_cmd(command, sudo=False, cwd=None, infile=None, outfile=None, shell=False, data=None): + """ + Executes an external command, optionally via sudo. + """ + if sudo: + if type(command) == type(""): + command = "sudo " + command else: - print "The FILE %s doesn't exist." % file - - def parse_xml(file, element): - xmldoc = minidom.parse(file) - elementlist = xmldoc.getElementsByTagName(element) - return elementlist - - def locate_utils(self): - """Get the directory path of 'utils'""" - pwd = os.getcwd() - result = re.search('(.*)libvirt-test-API(.*)', pwd) - return result.group(0) + "/utils" - - def mac_to_ip(self, mac, timeout): - """Map mac address to ip - - Return None on FAILURE and the mac address on SUCCESS - """ - if not mac: - return None - - if timeout< 10: - timeout = 10 - - cmd = "sh " + self.locate_utils() + "/ipget.sh " + mac - - while timeout> 0: - (ret, out) = commands.getstatusoutput(cmd) - if not out.lstrip() == "": - break - - timeout -= 10 - - return timeout and out or None - - def do_ping(self, ip, timeout): - """Ping some host - - return True on success or False on Failure - timeout should be greater or equal to 10 - """ - if not ip: - return False - - if timeout< 10: - timeout = 10 - - cmd = "ping -c 3 " + str(ip) - - while timeout> 0: - (ret, out) = commands.getstatusoutput(cmd) - if ret == 0: - break - timeout -= 10 - - return (timeout and 1) or 0 - - def exec_cmd(self, command, sudo=False, cwd=None, infile=None, outfile=None, shell=False, data=None): - """ - Executes an external command, optionally via sudo. - """ - if sudo: - if type(command) == type(""): - command = "sudo " + command - else: - command = ["sudo"] + command - if infile == None: - infile = subprocess.PIPE - if outfile == None: - outfile = subprocess.PIPE - p = subprocess.Popen(command, shell=shell, close_fds=True, cwd=cwd, - stdin=infile, stdout=outfile, stderr=subprocess.PIPE) - (out, err) = p.communicate(data) - if out == None: - # Prevent splitlines() from barfing later on - out = "" - return (p.returncode, out.splitlines()) - - def remote_exec_pexpect(self, hostname, username, password, cmd): - """ Remote exec function via pexpect """ - user_hostname = "%s@%s" % (username, hostname) - child = pexpect.spawn("/usr/bin/ssh", [user_hostname, cmd], - timeout = 60, maxread = 2000, logfile = None) - while True: - index = child.expect(['(yes\/no)', 'password:', pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - child.close() - return 0, child.before - elif index == 3: - child.close() - return 1, "" - - return 0 - - def scp_file(self, hostname, username, password, target_path, file): - """ Scp file to remote host """ - user_hostname = "%s@%s:%s" % (username, hostname, target_path) - child = pexpect.spawn("/usr/bin/scp", [file, user_hostname]) - while True: - index = child.expect(['yes\/no', 'password: ', - pexpect.EOF, - pexpect.TIMEOUT]) - if index == 0: - child.sendline("yes") - elif index == 1: - child.sendline(password) - elif index == 2: - child.close() - return 0 - elif index == 3: - child.close() - return 1 - - return 0 + command = ["sudo"] + command + if infile == None: + infile = subprocess.PIPE + if outfile == None: + outfile = subprocess.PIPE + p = subprocess.Popen(command, shell=shell, close_fds=True, cwd=cwd, + stdin=infile, stdout=outfile, stderr=subprocess.PIPE) + (out, err) = p.communicate(data) + if out == None: + # Prevent splitlines() from barfing later on + out = "" + return (p.returncode, out.splitlines()) + +def remote_exec_pexpect(hostname, username, password, cmd): + """ Remote exec function via pexpect """ + user_hostname = "%s@%s" % (username, hostname) + child = pexpect.spawn("/usr/bin/ssh", [user_hostname, cmd], + timeout = 60, maxread = 2000, logfile = None) + while True: + index = child.expect(['(yes\/no)', 'password:', pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("yes") + elif index == 1: + child.sendline(password) + elif index == 2: + child.close() + return 0, child.before + elif index == 3: + child.close() + return 1, "" + + return 0 + +def scp_file(hostname, username, password, target_path, file): + """ Scp file to remote host """ + user_hostname = "%s@%s:%s" % (username, hostname, target_path) + child = pexpect.spawn("/usr/bin/scp", [file, user_hostname]) + while True: + index = child.expect(['yes\/no', 'password: ', + pexpect.EOF, + pexpect.TIMEOUT]) + if index == 0: + child.sendline("yes") + elif index == 1: + child.sendline(password) + elif index == 2: + child.close() + return 0 + elif index == 3: + child.close() + return 1 + + return 0
Agree, ACK and pushed. Guannan Ren

$ for i in $(find . -type f -name "*.py"); do \ sed -i -e '/util *= *utils\.Utils()/d' $i; \ done --- repos/domain/attach_disk.py | 1 - repos/domain/attach_interface.py | 1 - repos/domain/autostart.py | 1 - repos/domain/balloon_memory.py | 1 - repos/domain/blkstats.py | 1 - repos/domain/console_mutex.py | 1 - repos/domain/cpu_affinity.py | 1 - repos/domain/cpu_topology.py | 1 - repos/domain/create.py | 1 - repos/domain/define.py | 1 - repos/domain/destroy.py | 1 - repos/domain/detach_disk.py | 1 - repos/domain/detach_interface.py | 1 - repos/domain/domain_blkinfo.py | 1 - repos/domain/domain_id.py | 1 - repos/domain/domain_uuid.py | 1 - repos/domain/domblkinfo.py | 1 - repos/domain/dump.py | 2 -- repos/domain/eventhandler.py | 1 - repos/domain/ifstats.py | 1 - repos/domain/install_image.py | 1 - repos/domain/install_linux_cdrom.py | 2 -- repos/domain/install_linux_check.py | 1 - repos/domain/install_linux_net.py | 2 -- repos/domain/install_windows_cdrom.py | 2 -- repos/domain/migrate.py | 1 - repos/domain/ownership_test.py | 2 -- repos/domain/reboot.py | 1 - repos/domain/restore.py | 1 - repos/domain/resume.py | 1 - repos/domain/save.py | 1 - repos/domain/sched_params.py | 1 - repos/domain/shutdown.py | 1 - repos/domain/start.py | 1 - repos/domain/suspend.py | 1 - repos/domain/undefine.py | 1 - repos/domain/update_devflag.py | 1 - repos/interface/create.py | 1 - repos/interface/define.py | 1 - repos/interface/destroy.py | 1 - repos/interface/undefine.py | 1 - repos/libvirtd/qemu_hang.py | 2 -- repos/libvirtd/restart.py | 1 - repos/libvirtd/upstart.py | 2 -- repos/network/autostart.py | 1 - repos/network/create.py | 1 - repos/network/define.py | 1 - repos/network/destroy.py | 1 - repos/network/network_list.py | 1 - repos/network/network_name.py | 1 - repos/network/network_uuid.py | 1 - repos/network/start.py | 1 - repos/network/undefine.py | 1 - repos/nodedevice/detach.py | 1 - repos/nodedevice/reattach.py | 1 - repos/nodedevice/reset.py | 1 - repos/npiv/create_virtual_hba.py | 1 - .../multiple_thread_block_on_domain_create.py | 1 - repos/remoteAccess/tcp_setup.py | 2 -- repos/remoteAccess/tls_setup.py | 2 -- repos/remoteAccess/unix_perm_sasl.py | 1 - repos/sVirt/domain_nfs_start.py | 2 -- repos/snapshot/delete.py | 1 - repos/snapshot/file_flag.py | 2 -- repos/snapshot/flag_check.py | 1 - repos/snapshot/internal_create.py | 1 - repos/snapshot/revert.py | 1 - repos/storage/activate_pool.py | 1 - repos/storage/build_dir_pool.py | 1 - repos/storage/build_disk_pool.py | 1 - repos/storage/build_logical_pool.py | 1 - repos/storage/build_netfs_pool.py | 1 - repos/storage/create_dir_pool.py | 1 - repos/storage/create_dir_volume.py | 1 - repos/storage/create_fs_pool.py | 1 - repos/storage/create_iscsi_pool.py | 1 - repos/storage/create_logical_volume.py | 1 - repos/storage/create_netfs_pool.py | 1 - repos/storage/create_netfs_volume.py | 1 - repos/storage/create_partition_volume.py | 1 - repos/storage/define_dir_pool.py | 1 - repos/storage/define_disk_pool.py | 1 - repos/storage/define_iscsi_pool.py | 1 - repos/storage/define_logical_pool.py | 1 - repos/storage/define_mpath_pool.py | 1 - repos/storage/define_netfs_pool.py | 1 - repos/storage/define_scsi_pool.py | 1 - repos/storage/delete_dir_volume.py | 1 - repos/storage/delete_logical_pool.py | 1 - repos/storage/delete_logical_volume.py | 1 - repos/storage/delete_netfs_volume.py | 1 - repos/storage/delete_partition_volume.py | 1 - repos/storage/destroy_pool.py | 1 - repos/storage/pool_name.py | 1 - repos/storage/pool_uuid.py | 1 - repos/storage/undefine_pool.py | 1 - 96 files changed, 0 insertions(+), 107 deletions(-) diff --git a/repos/domain/attach_disk.py b/repos/domain/attach_disk.py index 7e0f94c..ad0d174 100644 --- a/repos/domain/attach_disk.py +++ b/repos/domain/attach_disk.py @@ -68,7 +68,6 @@ def attach_disk(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/attach_interface.py b/repos/domain/attach_interface.py index f5c8c26..9ef3f8a 100644 --- a/repos/domain/attach_interface.py +++ b/repos/domain/attach_interface.py @@ -52,7 +52,6 @@ def attach_interface(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index bdb85b9..ca65886 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -66,7 +66,6 @@ def autostart(params): return 1 # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py index dea516b..fea997d 100644 --- a/repos/domain/balloon_memory.py +++ b/repos/domain/balloon_memory.py @@ -161,7 +161,6 @@ def balloon_memory(params): # Connect to local hypervisor connection URI global util - util = utils.Utils() uri = params['uri'] logger.info("get the mac address of vm %s" % domname) diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index be587b4..1ab7db6 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -45,7 +45,6 @@ def blkstats(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/console_mutex.py b/repos/domain/console_mutex.py index 9ace047..edf46c1 100644 --- a/repos/domain/console_mutex.py +++ b/repos/domain/console_mutex.py @@ -24,7 +24,6 @@ def console_mutex(params): guest = params['guestname'] device = params.get('device', 'serial0') - util = utils.Utils() uri = params['uri'] try: diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index bd7d907..b4e6386 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -224,7 +224,6 @@ def cpu_affinity(params): logger.info("the vcpu given is %s" % vcpu) # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) hypervisor = uri.split(':')[0] diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py index 1bb57bc..8fca63a 100644 --- a/repos/domain/cpu_topology.py +++ b/repos/domain/cpu_topology.py @@ -196,7 +196,6 @@ def cpu_topology(params): logger.info("cores is %s" % cores) logger.info("threads is %s" % threads) - util = utils.Utils() uri = params['uri'] logger.info("the uri is %s" % uri) diff --git a/repos/domain/create.py b/repos/domain/create.py index 975b152..48fd502 100644 --- a/repos/domain/create.py +++ b/repos/domain/create.py @@ -81,7 +81,6 @@ def create(params): return 1 # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/define.py b/repos/domain/define.py index de34544..feb4abc 100644 --- a/repos/domain/define.py +++ b/repos/domain/define.py @@ -95,7 +95,6 @@ def define(params): guesttype = params['guesttype'] test_result = False - util = utils.Utils() uri = params['uri'] hostname = util.parser_uri(uri)[1] diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 025aba5..16af8c6 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -53,7 +53,6 @@ def destroy(params): flags = params['flags'] # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/detach_disk.py b/repos/domain/detach_disk.py index d894dc1..657aebb 100644 --- a/repos/domain/detach_disk.py +++ b/repos/domain/detach_disk.py @@ -56,7 +56,6 @@ def detach_disk(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(guestname) diff --git a/repos/domain/detach_interface.py b/repos/domain/detach_interface.py index 91c2729..b87b51d 100644 --- a/repos/domain/detach_interface.py +++ b/repos/domain/detach_interface.py @@ -54,7 +54,6 @@ def detach_interface(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] macs = util.get_dom_mac_addr(guestname) mac_list = macs.split("\n") diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index b320653..975173c 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -109,7 +109,6 @@ def domblkinfo(params): logger.info("the name of guest is %s" % guestname) logger.info("the block device is %s" % blockdev) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index c89eeaf..2d8f3e0 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -62,7 +62,6 @@ def domid(params): logger.info("no running guest available") return 1 - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index 41f381b..62a88ae 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -58,7 +58,6 @@ def domuuid(params): guestname = params['guestname'] logger.info("guest name is %s" % guestname) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/domblkinfo.py b/repos/domain/domblkinfo.py index b320653..975173c 100644 --- a/repos/domain/domblkinfo.py +++ b/repos/domain/domblkinfo.py @@ -109,7 +109,6 @@ def domblkinfo(params): logger.info("the name of guest is %s" % guestname) logger.info("the block device is %s" % blockdev) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/dump.py b/repos/domain/dump.py index dcbc230..c1a1592 100644 --- a/repos/domain/dump.py +++ b/repos/domain/dump.py @@ -49,7 +49,6 @@ def check_guest_kernel(*args): """Check guest kernel version""" (guestname, logger) = args - util = utils.Utils() chk = check.Check() mac = util.get_dom_mac_addr(guestname) @@ -144,7 +143,6 @@ def dump(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(guestname) diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index d01874a..30bf272 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -235,7 +235,6 @@ def eventhandler(params): loop_start() # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/ifstats.py b/repos/domain/ifstats.py index 5bb85f7..a1de55c 100644 --- a/repos/domain/ifstats.py +++ b/repos/domain/ifstats.py @@ -45,7 +45,6 @@ def ifstats(params): guestname = params['guestname'] test_result = False - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/install_image.py b/repos/domain/install_image.py index 0ef1e5e..42b1b83 100644 --- a/repos/domain/install_image.py +++ b/repos/domain/install_image.py @@ -90,7 +90,6 @@ def install_image(params): logger.info("the arch of guest is %s" % guestarch) # Connect to local hypervisor connection URI - util = utils.Utils() hypervisor = util.get_hypervisor() logger.info("the type of hypervisor is %s" % hypervisor) diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 8976119..9da0374 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -232,7 +232,6 @@ def install_linux_cdrom(params): logger.info("the name of guest is %s" % guestname) logger.info("the type of guest is %s" % guesttype) - util = utils.Utils() hypervisor = util.get_hypervisor() conn = libvirt.open(uri) @@ -445,7 +444,6 @@ def install_linux_cdrom_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - util = utils.Utils() hypervisor = util.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) diff --git a/repos/domain/install_linux_check.py b/repos/domain/install_linux_check.py index a014f9b..e5d30c5 100644 --- a/repos/domain/install_linux_check.py +++ b/repos/domain/install_linux_check.py @@ -99,7 +99,6 @@ def install_linux_check(params): logger.info("the name of guest is %s" % guestname) # Connect to local hypervisor connection URI - util = utils.Utils() hypervisor = util.get_hypervisor() logger.info("the type of hypervisor is %s" % hypervisor) diff --git a/repos/domain/install_linux_net.py b/repos/domain/install_linux_net.py index dbf6dc8..b12d132 100644 --- a/repos/domain/install_linux_net.py +++ b/repos/domain/install_linux_net.py @@ -216,7 +216,6 @@ def install_linux_net(params): logger.info("the type of guest is %s" % guesttype) logger.info("the installation method is %s" % installmethod) - util = utils.Utils() hypervisor = util.get_hypervisor() macaddr = util.get_rand_mac() @@ -440,7 +439,6 @@ def install_linux_net_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - util = utils.Utils() hypervisor = util.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) diff --git a/repos/domain/install_windows_cdrom.py b/repos/domain/install_windows_cdrom.py index 150a43b..39a733e 100644 --- a/repos/domain/install_windows_cdrom.py +++ b/repos/domain/install_windows_cdrom.py @@ -270,7 +270,6 @@ def install_windows_cdrom(params): logger.info("the name of guest is %s" % guestname) logger.info("the type of guest is %s" % guesttype) - util = utils.Utils() hypervisor = util.get_hypervisor() if not params.has_key('macaddr'): @@ -465,7 +464,6 @@ def install_windows_cdrom_clean(params): guestname = params.get('guestname') guesttype = params.get('guesttype') - util = utils.Utils() hypervisor = util.get_hypervisor() if hypervisor == 'xen': imgfullpath = os.path.join('/var/lib/xen/images', guestname) diff --git a/repos/domain/migrate.py b/repos/domain/migrate.py index 23a05a8..d1458a5 100644 --- a/repos/domain/migrate.py +++ b/repos/domain/migrate.py @@ -229,7 +229,6 @@ def migrate(params): dsturi = "qemu+%s://%s/system" % (transport, target_machine) # Connect to local hypervisor connection URI - util = utils.Utils() srcconn = libvirt.open(srcuri) dstconn = libvirt.open(dsturi) diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py index 5651412..3a85ef5 100644 --- a/repos/domain/ownership_test.py +++ b/repos/domain/ownership_test.py @@ -198,7 +198,6 @@ def ownership_test(params): dynamic_ownership = params['dynamic_ownership'] use_nfs = params['use_nfs'] - util = utils.Utils() # set env logger.info("prepare the environment") @@ -283,7 +282,6 @@ def ownership_test_clean(params): logger = params['logger'] use_nfs = params['use_nfs'] - util = utils.Utils() if use_nfs == 'enable': if os.path.ismount("/mnt"): diff --git a/repos/domain/reboot.py b/repos/domain/reboot.py index 382704d..c2d50b4 100644 --- a/repos/domain/reboot.py +++ b/repos/domain/reboot.py @@ -41,7 +41,6 @@ def reboot(params): domain_name = params['guestname'] # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] hypervisor = util.get_hypervisor() if hypervisor == "kvm": diff --git a/repos/domain/restore.py b/repos/domain/restore.py index f2adb02..a4c7917 100644 --- a/repos/domain/restore.py +++ b/repos/domain/restore.py @@ -86,7 +86,6 @@ def restore(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(guestname) diff --git a/repos/domain/resume.py b/repos/domain/resume.py index ac9e613..e737e35 100644 --- a/repos/domain/resume.py +++ b/repos/domain/resume.py @@ -54,7 +54,6 @@ def resume(params): logger = params['logger'] # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] # Resume domain diff --git a/repos/domain/save.py b/repos/domain/save.py index e2512a8..3e439d9 100644 --- a/repos/domain/save.py +++ b/repos/domain/save.py @@ -84,7 +84,6 @@ def save(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(guestname) diff --git a/repos/domain/sched_params.py b/repos/domain/sched_params.py index 549c684..b98ab0f 100644 --- a/repos/domain/sched_params.py +++ b/repos/domain/sched_params.py @@ -73,7 +73,6 @@ def sched_params(params): keys, by assigning different value to 'weight' and 'cap' to verify validity of the result """ - util = utils.Utils() uri = params['uri'] hypervisor = util.get_hypervisor() usage(params, hypervisor) diff --git a/repos/domain/shutdown.py b/repos/domain/shutdown.py index 657cdd7..014a2dd 100644 --- a/repos/domain/shutdown.py +++ b/repos/domain/shutdown.py @@ -55,7 +55,6 @@ def shutdown(params): logger = params['logger'] # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(domname) diff --git a/repos/domain/start.py b/repos/domain/start.py index 2688aba..cd82bb6 100644 --- a/repos/domain/start.py +++ b/repos/domain/start.py @@ -70,7 +70,6 @@ def start(params): return return_close(conn, logger, 1) # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) domobj = conn.lookupByName(domname) diff --git a/repos/domain/suspend.py b/repos/domain/suspend.py index 15efb1a..02ddcb7 100644 --- a/repos/domain/suspend.py +++ b/repos/domain/suspend.py @@ -54,7 +54,6 @@ def suspend(params): logger = params['logger'] # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index bb188d2..ed92f49 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -41,7 +41,6 @@ def undefine(params): test_result = False # Connect to local hypervisor connection URI - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py index 8a2a160..18bcf30 100644 --- a/repos/domain/update_devflag.py +++ b/repos/domain/update_devflag.py @@ -158,7 +158,6 @@ def check_updated_device(params, output, util, guestip, domobj, srcfile): def update_devflag(params): """Update virtual device to a domain from xml""" - util = utils.Utils() # Initiate and check parameters params_check_result = check_params(params) diff --git a/repos/interface/create.py b/repos/interface/create.py index 0491986..2ab50b3 100644 --- a/repos/interface/create.py +++ b/repos/interface/create.py @@ -69,7 +69,6 @@ def create(params): ifacename = params['ifacename'] - util = utils.Utils() uri = params['uri'] try: hostip = util.get_ip_address(ifacename) diff --git a/repos/interface/define.py b/repos/interface/define.py index 2e4512c..6f8d68c 100644 --- a/repos/interface/define.py +++ b/repos/interface/define.py @@ -50,7 +50,6 @@ def define(params): ifacename = params['ifacename'] params['dhcp'] = 'yes' - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/interface/destroy.py b/repos/interface/destroy.py index fd6d078..7bdd5d2 100644 --- a/repos/interface/destroy.py +++ b/repos/interface/destroy.py @@ -67,7 +67,6 @@ def destroy(params): ifacename = params['ifacename'] - util = utils.Utils() uri = params['uri'] try: hostip = util.get_ip_address(ifacename) diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py index 517ea21..884b7e1 100644 --- a/repos/interface/undefine.py +++ b/repos/interface/undefine.py @@ -48,7 +48,6 @@ def undefine(params): ifacename = params['ifacename'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py index 4504640..c8b12c8 100644 --- a/repos/libvirtd/qemu_hang.py +++ b/repos/libvirtd/qemu_hang.py @@ -88,7 +88,6 @@ def qemu_hang(params): logger = params['logger'] guestname = params['guestname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) @@ -127,7 +126,6 @@ def qemu_hang_clean(params): """ clean testing environment """ logger = params['logger'] guestname = params['guestname'] - util = utils.Utils() ret = get_domain_pid(util, logger, guestname) cmd = "kill -CONT %s" % ret[1] diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py index 81591f2..29f0798 100644 --- a/repos/libvirtd/restart.py +++ b/repos/libvirtd/restart.py @@ -88,7 +88,6 @@ def restart(params): logger = params['logger'] guestname = params['guestname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py index 3fa9d2b..ca9291e 100644 --- a/repos/libvirtd/upstart.py +++ b/repos/libvirtd/upstart.py @@ -43,7 +43,6 @@ def libvirtd_check(util, logger): def upstart(params): """Set libvirtd upstart""" logger = params['logger'] - util = utils.Utils() logger.info("chkconfig libvirtd off:") cmd = "chkconfig libvirtd off" @@ -159,7 +158,6 @@ def upstart(params): def upstart_clean(params): """clean testing environment""" logger = params['logger'] - util = utils.Utils() if os.path.exists(INITCTL_CMD): cmd = "initctl stop libvirtd" diff --git a/repos/network/autostart.py b/repos/network/autostart.py index 02997da..374f964 100644 --- a/repos/network/autostart.py +++ b/repos/network/autostart.py @@ -74,7 +74,6 @@ def autostart(params): logger.error("Error: autostart value is invalid") return 1 - util = utils.Utils() uri = params['uri'] logger.info("uri address is %s" % uri) diff --git a/repos/network/create.py b/repos/network/create.py index 1bb0abe..4c5298b 100644 --- a/repos/network/create.py +++ b/repos/network/create.py @@ -44,7 +44,6 @@ def create(params): logger = params['logger'] networkname = params['networkname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/define.py b/repos/network/define.py index 0b0d9a5..884f529 100644 --- a/repos/network/define.py +++ b/repos/network/define.py @@ -54,7 +54,6 @@ def define(params): networkname = params['networkname'] test_result = False - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/destroy.py b/repos/network/destroy.py index 32d95ae..665c77f 100644 --- a/repos/network/destroy.py +++ b/repos/network/destroy.py @@ -48,7 +48,6 @@ def destroy(params): test_result = False - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/network_list.py b/repos/network/network_list.py index 67db632..8ed3fc3 100644 --- a/repos/network/network_list.py +++ b/repos/network/network_list.py @@ -159,7 +159,6 @@ def network_list(params): if ret: return 1 - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/network_name.py b/repos/network/network_name.py index b097348..99773b9 100644 --- a/repos/network/network_name.py +++ b/repos/network/network_name.py @@ -53,7 +53,6 @@ def netname(params): else: networkname = params['networkname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/network_uuid.py b/repos/network/network_uuid.py index b5f9fcd..42b0dec 100644 --- a/repos/network/network_uuid.py +++ b/repos/network/network_uuid.py @@ -53,7 +53,6 @@ def netuuid(params): else: networkname = params['networkname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/network/start.py b/repos/network/start.py index 44243d2..a6212b8 100644 --- a/repos/network/start.py +++ b/repos/network/start.py @@ -45,7 +45,6 @@ def start(params): logger.info("the name of virtual network to be activated is %s" % \ networkname) - util = utils.Utils() uri = params['uri'] logger.info("uri address is %s" % uri) diff --git a/repos/network/undefine.py b/repos/network/undefine.py index a51aff5..bdb53b7 100644 --- a/repos/network/undefine.py +++ b/repos/network/undefine.py @@ -45,7 +45,6 @@ def undefine(params): logger = params['logger'] networkname = params['networkname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/nodedevice/detach.py b/repos/nodedevice/detach.py index 8fdc60f..37dbf6a 100644 --- a/repos/nodedevice/detach.py +++ b/repos/nodedevice/detach.py @@ -61,7 +61,6 @@ def detach(params): original_driver = check_node_detach(pciaddress) logger.info("original device driver: %s" % original_driver) - util = utils.Utils() uri = params['uri'] kernel_version = util.get_host_kernel_version() diff --git a/repos/nodedevice/reattach.py b/repos/nodedevice/reattach.py index 7fcd113..17a430b 100644 --- a/repos/nodedevice/reattach.py +++ b/repos/nodedevice/reattach.py @@ -60,7 +60,6 @@ def reattach(params): original_driver = check_node_reattach(pciaddress) logger.info("original device driver: %s" % original_driver) - util = utils.Utils() uri = params['uri'] kernel_version = util.get_host_kernel_version() diff --git a/repos/nodedevice/reset.py b/repos/nodedevice/reset.py index c5d953e..5e76ec3 100644 --- a/repos/nodedevice/reset.py +++ b/repos/nodedevice/reset.py @@ -39,7 +39,6 @@ def reset(params): logger = params['logger'] pciaddress = params['pciaddress'] - util = utils.Utils() uri = params['uri'] kernel_version = util.get_host_kernel_version() diff --git a/repos/npiv/create_virtual_hba.py b/repos/npiv/create_virtual_hba.py index 50d2223..b032c64 100644 --- a/repos/npiv/create_virtual_hba.py +++ b/repos/npiv/create_virtual_hba.py @@ -68,7 +68,6 @@ def create_virtual_hba(params): if not usage(params): return 1 - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/regression/multiple_thread_block_on_domain_create.py b/repos/regression/multiple_thread_block_on_domain_create.py index 5ea0fb8..035868e 100644 --- a/repos/regression/multiple_thread_block_on_domain_create.py +++ b/repos/regression/multiple_thread_block_on_domain_create.py @@ -124,7 +124,6 @@ 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) - util = utils.Utils() hypervisor = util.get_hypervisor() uri = params['uri'] diff --git a/repos/remoteAccess/tcp_setup.py b/repos/remoteAccess/tcp_setup.py index 792bf89..dd9201b 100644 --- a/repos/remoteAccess/tcp_setup.py +++ b/repos/remoteAccess/tcp_setup.py @@ -164,7 +164,6 @@ def tcp_setup(params): uri = "qemu+tcp://%s/system" % target_machine - util = utils.Utils() logger.info("the hostname of server is %s" % target_machine) logger.info("the value of listen_tcp is %s" % listen_tcp) @@ -203,7 +202,6 @@ def tcp_setup_clean(params): listen_tcp = params['listen_tcp'] auth_tcp = params['auth_tcp'] - util = utils.Utils() if auth_tcp == 'sasl': saslpasswd2_delete = "%s -a libvirt -d %s" % (SASLPASSWD2, username) diff --git a/repos/remoteAccess/tls_setup.py b/repos/remoteAccess/tls_setup.py index b8bc540..ea1bf68 100644 --- a/repos/remoteAccess/tls_setup.py +++ b/repos/remoteAccess/tls_setup.py @@ -382,7 +382,6 @@ def tls_setup(params): if pkipath: uri += "?pkipath=%s" % pkipath - util = utils.Utils() local_machine = util.get_local_hostname() logger.info("the hostname of server is %s" % target_machine) @@ -446,7 +445,6 @@ def tls_setup_clean(params): listen_tls = params['listen_tls'] auth_tls = params['auth_tls'] - util = utils.Utils() cacert_rm = "rm -f %s/cacert.pem" % CA_FOLDER ret, output = util.remote_exec_pexpect(target_machine, username, password, cacert_rm) diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py index d34ced3..6703b82 100644 --- a/repos/remoteAccess/unix_perm_sasl.py +++ b/repos/remoteAccess/unix_perm_sasl.py @@ -196,7 +196,6 @@ def unix_perm_sasl(params): def unix_perm_sasl_clean(params): """clean testing environment""" logger = params['logger'] - util = utils.Utils() auth_unix_ro = params['auth_unix_ro'] auth_unix_rw = params['auth_unix_rw'] diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py index 10cca44..39122ba 100644 --- a/repos/sVirt/domain_nfs_start.py +++ b/repos/sVirt/domain_nfs_start.py @@ -152,7 +152,6 @@ def domain_nfs_start(params): virt_use_nfs = params['virt_use_nfs'] root_squash = params['root_squash'] - util = utils.Utils() # Connect to local hypervisor connection URI uri = params['uri'] @@ -438,7 +437,6 @@ def domain_nfs_start_clean(params): logger = params['logger'] guestname = params['guestname'] - util = utils.Utils() # Connect to local hypervisor connection URI uri = params['uri'] diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 4148d77..2e142d4 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -62,7 +62,6 @@ def delete(params): guestname = params['guestname'] snapshotname = params['snapshotname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py index 9506ab2..fa22c41 100644 --- a/repos/snapshot/file_flag.py +++ b/repos/snapshot/file_flag.py @@ -73,7 +73,6 @@ def file_flag(params): username = params['username'] password = params['password'] - util = utils.Utils() chk = check.Check() uri = params['uri'] conn = libvirt.open(uri) @@ -113,5 +112,4 @@ def file_flag(params): def file_flag_clean(params): """ clean testing environment """ - util = utils.Utils() return 0 diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py index dcd7658..ae10bfb 100644 --- a/repos/snapshot/flag_check.py +++ b/repos/snapshot/flag_check.py @@ -63,7 +63,6 @@ def flag_check(params): else: expected_result = "exist" - util = utils.Utils() chk = check.Check() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py index 757c9f3..87cc0aa 100644 --- a/repos/snapshot/internal_create.py +++ b/repos/snapshot/internal_create.py @@ -67,7 +67,6 @@ def internal_create(params): if not params.has_key('snapshotname'): params['snapshotname'] = str(int(time.time())) - util = utils.Utils() uri = params['uri'] logger.info("the uri is %s" % uri) diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py index 985bdb0..6c0987e 100644 --- a/repos/snapshot/revert.py +++ b/repos/snapshot/revert.py @@ -46,7 +46,6 @@ def revert(params): guestname = params['guestname'] snapshotname = params['snapshotname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py index 665a3d0..646b396 100644 --- a/repos/storage/activate_pool.py +++ b/repos/storage/activate_pool.py @@ -44,7 +44,6 @@ def activate_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py index 10d3e1b..116a207 100644 --- a/repos/storage/build_dir_pool.py +++ b/repos/storage/build_dir_pool.py @@ -68,7 +68,6 @@ def build_dir_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/build_disk_pool.py b/repos/storage/build_disk_pool.py index 20884a8..e59b98f 100644 --- a/repos/storage/build_disk_pool.py +++ b/repos/storage/build_disk_pool.py @@ -83,7 +83,6 @@ def build_disk_pool(params): poolname = params['poolname'] logger.info("the poolname is %s" % (poolname)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/build_logical_pool.py b/repos/storage/build_logical_pool.py index 78310ef..fd8818e 100644 --- a/repos/storage/build_logical_pool.py +++ b/repos/storage/build_logical_pool.py @@ -80,7 +80,6 @@ def build_logical_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/build_netfs_pool.py b/repos/storage/build_netfs_pool.py index dfc3130..5bdddf5 100644 --- a/repos/storage/build_netfs_pool.py +++ b/repos/storage/build_netfs_pool.py @@ -57,7 +57,6 @@ def build_netfs_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_dir_pool.py b/repos/storage/create_dir_pool.py index f5ae4ce..dd7526d 100644 --- a/repos/storage/create_dir_pool.py +++ b/repos/storage/create_dir_pool.py @@ -72,7 +72,6 @@ def create_dir_pool(params): poolname = params['poolname'] pooltype = params['pooltype'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_dir_volume.py b/repos/storage/create_dir_volume.py index 6dd973e..15927f3 100644 --- a/repos/storage/create_dir_volume.py +++ b/repos/storage/create_dir_volume.py @@ -118,7 +118,6 @@ def create_dir_volume(params): volfomat is %s, capacity is %s" % \ (poolname, volname, volformat, capacity)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_fs_pool.py b/repos/storage/create_fs_pool.py index 8114dba..cad8c18 100644 --- a/repos/storage/create_fs_pool.py +++ b/repos/storage/create_fs_pool.py @@ -88,7 +88,6 @@ def create_fs_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_iscsi_pool.py b/repos/storage/create_iscsi_pool.py index 76181ff..61a1e98 100644 --- a/repos/storage/create_iscsi_pool.py +++ b/repos/storage/create_iscsi_pool.py @@ -65,7 +65,6 @@ def create_iscsi_pool(params): poolname = params['poolname'] pooltype = params['pooltype'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_logical_volume.py b/repos/storage/create_logical_volume.py index 62e513c..93f1d7f 100644 --- a/repos/storage/create_logical_volume.py +++ b/repos/storage/create_logical_volume.py @@ -93,7 +93,6 @@ def create_logical_volume(params): volname = params['volname'] capacity = params['capacity'] - util = utils.Utils() dicts = util.get_capacity_suffix_size(capacity) params['capacity'] = dicts['capacity'] diff --git a/repos/storage/create_netfs_pool.py b/repos/storage/create_netfs_pool.py index bbbc838..035a01a 100644 --- a/repos/storage/create_netfs_pool.py +++ b/repos/storage/create_netfs_pool.py @@ -103,7 +103,6 @@ def create_netfs_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_netfs_volume.py b/repos/storage/create_netfs_volume.py index 4bbe394..318878c 100644 --- a/repos/storage/create_netfs_volume.py +++ b/repos/storage/create_netfs_volume.py @@ -117,7 +117,6 @@ def create_netfs_volume(params): volfomat is %s, capacity is %s" % \ (poolname, volname, volformat, capacity)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/create_partition_volume.py b/repos/storage/create_partition_volume.py index f8d8c62..7ec9130 100644 --- a/repos/storage/create_partition_volume.py +++ b/repos/storage/create_partition_volume.py @@ -100,7 +100,6 @@ def create_partition_volume(params): volfomat is %s, capacity is %s" % \ (poolname, volname, volformat, capacity)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_dir_pool.py b/repos/storage/define_dir_pool.py index cd1997e..c1b48c3 100644 --- a/repos/storage/define_dir_pool.py +++ b/repos/storage/define_dir_pool.py @@ -65,7 +65,6 @@ def define_dir_pool(params): logger = params['logger'] poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_disk_pool.py b/repos/storage/define_disk_pool.py index 1a25e90..fe8215e 100644 --- a/repos/storage/define_disk_pool.py +++ b/repos/storage/define_disk_pool.py @@ -84,7 +84,6 @@ def define_disk_pool(params): logger.info("the poolname is %s, pooltype is %s, sourcepath is %s" % \ (poolname, pooltype, sourcepath)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_iscsi_pool.py b/repos/storage/define_iscsi_pool.py index 8372a31..7b8d19a 100644 --- a/repos/storage/define_iscsi_pool.py +++ b/repos/storage/define_iscsi_pool.py @@ -78,7 +78,6 @@ def define_iscsi_pool(params): srcname = params['sourcename'] srcpath = params['sourcepath'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_logical_pool.py b/repos/storage/define_logical_pool.py index bd9f676..b097b1d 100644 --- a/repos/storage/define_logical_pool.py +++ b/repos/storage/define_logical_pool.py @@ -56,7 +56,6 @@ def define_logical_pool(params): logger = params['logger'] poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_mpath_pool.py b/repos/storage/define_mpath_pool.py index d5d81b1..3ede935 100644 --- a/repos/storage/define_mpath_pool.py +++ b/repos/storage/define_mpath_pool.py @@ -77,7 +77,6 @@ def define_mpath_pool(params): logger.info("the poolname is %s, pooltype is %s" % (poolname, pooltype)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_netfs_pool.py b/repos/storage/define_netfs_pool.py index 372194d..e0c4694 100644 --- a/repos/storage/define_netfs_pool.py +++ b/repos/storage/define_netfs_pool.py @@ -56,7 +56,6 @@ def define_netfs_pool(params): logger = params['logger'] poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/define_scsi_pool.py b/repos/storage/define_scsi_pool.py index 834f5a0..e7dabc6 100644 --- a/repos/storage/define_scsi_pool.py +++ b/repos/storage/define_scsi_pool.py @@ -82,7 +82,6 @@ def define_scsi_pool(params): logger.info("the poolname is %s, pooltype is %s, sourcename is %s" % \ (poolname, pooltype, sourcename)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/delete_dir_volume.py b/repos/storage/delete_dir_volume.py index b961f61..1c51abe 100644 --- a/repos/storage/delete_dir_volume.py +++ b/repos/storage/delete_dir_volume.py @@ -60,7 +60,6 @@ def delete_dir_volume(params): poolname = params['poolname'] volname = params['volname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/delete_logical_pool.py b/repos/storage/delete_logical_pool.py index 9c581fb..ee28782 100644 --- a/repos/storage/delete_logical_pool.py +++ b/repos/storage/delete_logical_pool.py @@ -75,7 +75,6 @@ def delete_logical_pool(params): poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/delete_logical_volume.py b/repos/storage/delete_logical_volume.py index cd30bac..d3e69be 100644 --- a/repos/storage/delete_logical_volume.py +++ b/repos/storage/delete_logical_volume.py @@ -80,7 +80,6 @@ def delete_logical_volume(params): poolname = params['poolname'] volname = params['volname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/delete_netfs_volume.py b/repos/storage/delete_netfs_volume.py index f893c94..f284b5f 100644 --- a/repos/storage/delete_netfs_volume.py +++ b/repos/storage/delete_netfs_volume.py @@ -60,7 +60,6 @@ def delete_netfs_volume(params): poolname = params['poolname'] volname = params['volname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/delete_partition_volume.py b/repos/storage/delete_partition_volume.py index 3d01346..025a8f3 100644 --- a/repos/storage/delete_partition_volume.py +++ b/repos/storage/delete_partition_volume.py @@ -85,7 +85,6 @@ def delete_partition_volume(params): logger.info("the poolname is %s, volname is %s" % (poolname, volname)) - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/destroy_pool.py b/repos/storage/destroy_pool.py index c5797ee..762dea6 100644 --- a/repos/storage/destroy_pool.py +++ b/repos/storage/destroy_pool.py @@ -59,7 +59,6 @@ def destroy_pool(params): return 1 poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/pool_name.py b/repos/storage/pool_name.py index cf266de..e1b0138 100644 --- a/repos/storage/pool_name.py +++ b/repos/storage/pool_name.py @@ -43,7 +43,6 @@ def pool_name(params): else: poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) diff --git a/repos/storage/pool_uuid.py b/repos/storage/pool_uuid.py index 796b842..28875c1 100644 --- a/repos/storage/pool_uuid.py +++ b/repos/storage/pool_uuid.py @@ -43,7 +43,6 @@ def pool_uuid(params): else: poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) logger.info("the uri is %s" % uri) diff --git a/repos/storage/undefine_pool.py b/repos/storage/undefine_pool.py index 5e8e141..c2865c1 100644 --- a/repos/storage/undefine_pool.py +++ b/repos/storage/undefine_pool.py @@ -54,7 +54,6 @@ def undefine_pool(params): logger = params['logger'] poolname = params['poolname'] - util = utils.Utils() uri = params['uri'] conn = libvirt.open(uri) -- 1.7.7.5

On 04/10/2012 03:34 PM, Osier Yang wrote:
$ for i in $(find . -type f -name "*.py"); do \ sed -i -e '/util *= *utils\.Utils()/d' $i; \ done --- repos/domain/attach_disk.py | 1 - repos/domain/attach_interface.py | 1 - repos/domain/autostart.py | 1 - repos/domain/balloon_memory.py | 1 - repos/domain/blkstats.py | 1 - repos/domain/console_mutex.py | 1 - repos/domain/cpu_affinity.py | 1 - repos/domain/cpu_topology.py | 1 - repos/domain/create.py | 1 - repos/domain/define.py | 1 - repos/domain/destroy.py | 1 - repos/domain/detach_disk.py | 1 - repos/domain/detach_interface.py | 1 - repos/domain/domain_blkinfo.py | 1 - repos/domain/domain_id.py | 1 - repos/domain/domain_uuid.py | 1 - repos/domain/domblkinfo.py | 1 - repos/domain/dump.py | 2 -- repos/domain/eventhandler.py | 1 - repos/domain/ifstats.py | 1 - repos/domain/install_image.py | 1 - repos/domain/install_linux_cdrom.py | 2 -- repos/domain/install_linux_check.py | 1 - repos/domain/install_linux_net.py | 2 -- repos/domain/install_windows_cdrom.py | 2 -- repos/domain/migrate.py | 1 - repos/domain/ownership_test.py | 2 -- repos/domain/reboot.py | 1 - repos/domain/restore.py | 1 - repos/domain/resume.py | 1 - repos/domain/save.py | 1 - repos/domain/sched_params.py | 1 - repos/domain/shutdown.py | 1 - repos/domain/start.py | 1 - repos/domain/suspend.py | 1 - repos/domain/undefine.py | 1 - repos/domain/update_devflag.py | 1 - repos/interface/create.py | 1 - repos/interface/define.py | 1 - repos/interface/destroy.py | 1 - repos/interface/undefine.py | 1 - repos/libvirtd/qemu_hang.py | 2 -- repos/libvirtd/restart.py | 1 - repos/libvirtd/upstart.py | 2 -- repos/network/autostart.py | 1 - repos/network/create.py | 1 - repos/network/define.py | 1 - repos/network/destroy.py | 1 - repos/network/network_list.py | 1 - repos/network/network_name.py | 1 - repos/network/network_uuid.py | 1 - repos/network/start.py | 1 - repos/network/undefine.py | 1 - repos/nodedevice/detach.py | 1 - repos/nodedevice/reattach.py | 1 - repos/nodedevice/reset.py | 1 - repos/npiv/create_virtual_hba.py | 1 - .../multiple_thread_block_on_domain_create.py | 1 - repos/remoteAccess/tcp_setup.py | 2 -- repos/remoteAccess/tls_setup.py | 2 -- repos/remoteAccess/unix_perm_sasl.py | 1 - repos/sVirt/domain_nfs_start.py | 2 -- repos/snapshot/delete.py | 1 - repos/snapshot/file_flag.py | 2 -- repos/snapshot/flag_check.py | 1 - repos/snapshot/internal_create.py | 1 - repos/snapshot/revert.py | 1 - repos/storage/activate_pool.py | 1 - repos/storage/build_dir_pool.py | 1 - repos/storage/build_disk_pool.py | 1 - repos/storage/build_logical_pool.py | 1 - repos/storage/build_netfs_pool.py | 1 - repos/storage/create_dir_pool.py | 1 - repos/storage/create_dir_volume.py | 1 - repos/storage/create_fs_pool.py | 1 - repos/storage/create_iscsi_pool.py | 1 - repos/storage/create_logical_volume.py | 1 - repos/storage/create_netfs_pool.py | 1 - repos/storage/create_netfs_volume.py | 1 - repos/storage/create_partition_volume.py | 1 - repos/storage/define_dir_pool.py | 1 - repos/storage/define_disk_pool.py | 1 - repos/storage/define_iscsi_pool.py | 1 - repos/storage/define_logical_pool.py | 1 - repos/storage/define_mpath_pool.py | 1 - repos/storage/define_netfs_pool.py | 1 - repos/storage/define_scsi_pool.py | 1 - repos/storage/delete_dir_volume.py | 1 - repos/storage/delete_logical_pool.py | 1 - repos/storage/delete_logical_volume.py | 1 - repos/storage/delete_netfs_volume.py | 1 - repos/storage/delete_partition_volume.py | 1 - repos/storage/destroy_pool.py | 1 - repos/storage/pool_name.py | 1 - repos/storage/pool_uuid.py | 1 - repos/storage/undefine_pool.py | 1 - 96 files changed, 0 insertions(+), 107 deletions(-)
mechanical cleanup, ACK and pushed. Guannan Ren

$ for i in $(find . -type f -name "*.py"); do \ sed -i -e 's/utils\.Utils()/utils/g' $i; \ done --- repos/domain/cpu_affinity.py | 2 +- utils/xmlgenerator.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index b4e6386..6acf260 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -152,7 +152,7 @@ def vcpu_affinity_check(domain_name, vcpu, expected_pinned_cpu, hypervisor): """check the task in the process of the running virtual machine grep Cpus_allowed_list /proc/PID/task/*/status """ - host_kernel_version = utils.Utils().get_host_kernel_version() + host_kernel_version = utils.get_host_kernel_version() if 'qemu' in hypervisor: get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % domain_name status, pid = commands.getstatusoutput(get_pid_cmd) diff --git a/utils/xmlgenerator.py b/utils/xmlgenerator.py index 408324f..aca0062 100644 --- a/utils/xmlgenerator.py +++ b/utils/xmlgenerator.py @@ -208,7 +208,7 @@ def domain_xml(params, install = False): devices_element = domain.createElement('devices') # if params['guesttype'] == 'xenfv': # emulator_element = domain.createElement('emulator') -# host_arch = utils.Utils().get_host_arch() +# host_arch = utils.get_host_arch() # if host_arch == 'i386' or host_arch == 'ia64': # emulator_node = domain.createTextNode('/usr/lib/xen/bin/qemu-dm') # elif host_arch == 'x86_64': @@ -307,7 +307,7 @@ def disk_xml(params, cdrom = False): sys.exit(1) ### Get image path ### - hypertype = utils.Utils().get_hypervisor() + hypertype = utils.get_hypervisor() if not params.has_key('fullimagepath'): if hypertype == 'kvm': params['imagepath'] = '/var/lib/libvirt/images' @@ -431,7 +431,7 @@ def interface_xml(params): # <model> # Network device model: ne2k_isa i82551 i82557b i82559er ne2k_pci # pcnet rtl8139 e1000 virtio - host_release = utils.Utils().get_host_kernel_version() + host_release = utils.get_host_kernel_version() if 'el6' in host_release: if params.has_key('nicmodel'): model_element = interface.createElement('model') @@ -439,7 +439,7 @@ def interface_xml(params): interface_element.appendChild(model_element) # <mac> - MacAddr = utils.Utils().get_rand_mac() + MacAddr = utils.get_rand_mac() if params.has_key('macaddr'): mac_element = interface.createElement('mac') mac_element.setAttribute('address', params['macaddr']) @@ -556,9 +556,9 @@ def pool_xml(params): ### Get image path ### if not params.has_key('targetpath'): if params['pooltype'] == 'netfs' or params['pooltype'] == 'dir': - if utils.Utils().get_hypervisor() == 'kvm': + if utils.get_hypervisor() == 'kvm': params['targetpath'] = '/var/lib/libvirt/images' - elif utils.Utils().get_hypervisor() == 'xen': + elif utils.get_hypervisor() == 'xen': params['targetpath'] = '/var/lib/xen/images' else: print 'NOT supported hypervisor.' -- 1.7.7.5

On 04/10/2012 03:34 PM, Osier Yang wrote:
$ for i in $(find . -type f -name "*.py"); do \ sed -i -e 's/utils\.Utils()/utils/g' $i; \ done --- repos/domain/cpu_affinity.py | 2 +- utils/xmlgenerator.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/repos/domain/cpu_affinity.py b/repos/domain/cpu_affinity.py index b4e6386..6acf260 100644 --- a/repos/domain/cpu_affinity.py +++ b/repos/domain/cpu_affinity.py @@ -152,7 +152,7 @@ def vcpu_affinity_check(domain_name, vcpu, expected_pinned_cpu, hypervisor): """check the task in the process of the running virtual machine grep Cpus_allowed_list /proc/PID/task/*/status """ - host_kernel_version = utils.Utils().get_host_kernel_version() + host_kernel_version = utils.get_host_kernel_version() if 'qemu' in hypervisor: get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % domain_name status, pid = commands.getstatusoutput(get_pid_cmd) diff --git a/utils/xmlgenerator.py b/utils/xmlgenerator.py index 408324f..aca0062 100644 --- a/utils/xmlgenerator.py +++ b/utils/xmlgenerator.py @@ -208,7 +208,7 @@ def domain_xml(params, install = False): devices_element = domain.createElement('devices') # if params['guesttype'] == 'xenfv': # emulator_element = domain.createElement('emulator') -# host_arch = utils.Utils().get_host_arch() +# host_arch = utils.get_host_arch() # if host_arch == 'i386' or host_arch == 'ia64': # emulator_node = domain.createTextNode('/usr/lib/xen/bin/qemu-dm') # elif host_arch == 'x86_64': @@ -307,7 +307,7 @@ def disk_xml(params, cdrom = False): sys.exit(1)
### Get image path ### - hypertype = utils.Utils().get_hypervisor() + hypertype = utils.get_hypervisor() if not params.has_key('fullimagepath'): if hypertype == 'kvm': params['imagepath'] = '/var/lib/libvirt/images' @@ -431,7 +431,7 @@ def interface_xml(params): #<model> # Network device model: ne2k_isa i82551 i82557b i82559er ne2k_pci # pcnet rtl8139 e1000 virtio - host_release = utils.Utils().get_host_kernel_version() + host_release = utils.get_host_kernel_version() if 'el6' in host_release: if params.has_key('nicmodel'): model_element = interface.createElement('model') @@ -439,7 +439,7 @@ def interface_xml(params): interface_element.appendChild(model_element)
#<mac> - MacAddr = utils.Utils().get_rand_mac() + MacAddr = utils.get_rand_mac() if params.has_key('macaddr'): mac_element = interface.createElement('mac') mac_element.setAttribute('address', params['macaddr']) @@ -556,9 +556,9 @@ def pool_xml(params): ### Get image path ### if not params.has_key('targetpath'): if params['pooltype'] == 'netfs' or params['pooltype'] == 'dir': - if utils.Utils().get_hypervisor() == 'kvm': + if utils.get_hypervisor() == 'kvm': params['targetpath'] = '/var/lib/libvirt/images' - elif utils.Utils().get_hypervisor() == 'xen': + elif utils.get_hypervisor() == 'xen': params['targetpath'] = '/var/lib/xen/images' else: print 'NOT supported hypervisor.'
Thanks for the catch. pushed. Guannan Ren

$ 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

On 04/10/2012 03:34 PM, Osier Yang wrote:
$ 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(-)
ACK and pushed. Guannan Ren

--- repos/domain/autostart.py | 1 - repos/domain/blkstats.py | 1 - repos/domain/console_mutex.py | 1 - repos/domain/domain_blkinfo.py | 1 - repos/domain/domain_id.py | 1 - repos/domain/domain_uuid.py | 1 - repos/domain/domblkinfo.py | 1 - repos/domain/eventhandler.py | 1 - repos/domain/migrate.py | 1 - repos/domain/undefine.py | 1 - repos/interface/define.py | 1 - repos/interface/undefine.py | 1 - repos/network/autostart.py | 1 - repos/network/create.py | 1 - repos/network/define.py | 1 - repos/network/destroy.py | 1 - repos/network/network_name.py | 1 - repos/network/network_uuid.py | 1 - repos/network/start.py | 1 - repos/network/undefine.py | 1 - repos/npiv/create_virtual_hba.py | 1 - repos/snapshot/delete.py | 1 - repos/snapshot/revert.py | 1 - repos/storage/activate_pool.py | 1 - repos/storage/build_dir_pool.py | 1 - repos/storage/build_disk_pool.py | 1 - repos/storage/build_logical_pool.py | 1 - repos/storage/build_netfs_pool.py | 1 - repos/storage/create_dir_pool.py | 1 - repos/storage/create_dir_volume.py | 1 - repos/storage/create_fs_pool.py | 1 - repos/storage/create_iscsi_pool.py | 1 - repos/storage/create_netfs_pool.py | 1 - repos/storage/create_netfs_volume.py | 1 - repos/storage/create_partition_volume.py | 1 - repos/storage/define_dir_pool.py | 1 - repos/storage/define_disk_pool.py | 1 - repos/storage/define_iscsi_pool.py | 1 - repos/storage/define_logical_pool.py | 1 - repos/storage/define_mpath_pool.py | 1 - repos/storage/define_netfs_pool.py | 1 - repos/storage/define_scsi_pool.py | 1 - repos/storage/delete_dir_volume.py | 1 - repos/storage/delete_logical_pool.py | 1 - repos/storage/delete_logical_volume.py | 1 - repos/storage/delete_netfs_volume.py | 1 - repos/storage/delete_partition_volume.py | 1 - repos/storage/destroy_pool.py | 1 - repos/storage/pool_name.py | 1 - repos/storage/pool_uuid.py | 1 - repos/storage/undefine_pool.py | 1 - 51 files changed, 0 insertions(+), 51 deletions(-) diff --git a/repos/domain/autostart.py b/repos/domain/autostart.py index ca65886..f122f34 100644 --- a/repos/domain/autostart.py +++ b/repos/domain/autostart.py @@ -12,7 +12,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py index 1ab7db6..756a424 100644 --- a/repos/domain/blkstats.py +++ b/repos/domain/blkstats.py @@ -12,7 +12,6 @@ import libxml2 import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/domain/console_mutex.py b/repos/domain/console_mutex.py index edf46c1..052e766 100644 --- a/repos/domain/console_mutex.py +++ b/repos/domain/console_mutex.py @@ -6,7 +6,6 @@ import libvirt from libvirt import libvirtError from exception import TestError -from utils import utils def usage(params): """Verify parameter dictionary""" diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py index 975173c..6e60964 100644 --- a/repos/domain/domain_blkinfo.py +++ b/repos/domain/domain_blkinfo.py @@ -10,7 +10,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'" GET_CAPACITY = "du -b %s | awk '{print $1}'" diff --git a/repos/domain/domain_id.py b/repos/domain/domain_id.py index 2d8f3e0..570a1be 100644 --- a/repos/domain/domain_id.py +++ b/repos/domain/domain_id.py @@ -9,7 +9,6 @@ import commands import libvirt -from utils import utils VIRSH_DOMID = "virsh domid" VIRSH_IDS = "virsh --quiet list |awk '{print $1}'" diff --git a/repos/domain/domain_uuid.py b/repos/domain/domain_uuid.py index 62a88ae..b6578e4 100644 --- a/repos/domain/domain_uuid.py +++ b/repos/domain/domain_uuid.py @@ -10,7 +10,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils VIRSH_DOMUUID = "virsh domuuid" diff --git a/repos/domain/domblkinfo.py b/repos/domain/domblkinfo.py index 975173c..6e60964 100644 --- a/repos/domain/domblkinfo.py +++ b/repos/domain/domblkinfo.py @@ -10,7 +10,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'" GET_CAPACITY = "du -b %s | awk '{print $1}'" diff --git a/repos/domain/eventhandler.py b/repos/domain/eventhandler.py index 30bf272..8d31ad5 100644 --- a/repos/domain/eventhandler.py +++ b/repos/domain/eventhandler.py @@ -15,7 +15,6 @@ import threading import libvirt from libvirt import libvirtError -from utils import utils LoopThread = None looping = True diff --git a/repos/domain/migrate.py b/repos/domain/migrate.py index d1458a5..e6f7df0 100644 --- a/repos/domain/migrate.py +++ b/repos/domain/migrate.py @@ -42,7 +42,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder SSH_KEYGEN = "ssh-keygen -t rsa" diff --git a/repos/domain/undefine.py b/repos/domain/undefine.py index ed92f49..9412a72 100644 --- a/repos/domain/undefine.py +++ b/repos/domain/undefine.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/interface/define.py b/repos/interface/define.py index 6f8d68c..04f4010 100644 --- a/repos/interface/define.py +++ b/repos/interface/define.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py index 884b7e1..a759d99 100644 --- a/repos/interface/undefine.py +++ b/repos/interface/undefine.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/network/autostart.py b/repos/network/autostart.py index 374f964..4d7e65c 100644 --- a/repos/network/autostart.py +++ b/repos/network/autostart.py @@ -12,7 +12,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils def check_params(params): """Verify inputing parameter dictionary""" diff --git a/repos/network/create.py b/repos/network/create.py index 4c5298b..5e7cd1e 100644 --- a/repos/network/create.py +++ b/repos/network/create.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/network/define.py b/repos/network/define.py index 884f529..4ee5456 100644 --- a/repos/network/define.py +++ b/repos/network/define.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/network/destroy.py b/repos/network/destroy.py index 665c77f..8757e3b 100644 --- a/repos/network/destroy.py +++ b/repos/network/destroy.py @@ -9,7 +9,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/network/network_name.py b/repos/network/network_name.py index 99773b9..5aa6a5e 100644 --- a/repos/network/network_name.py +++ b/repos/network/network_name.py @@ -10,7 +10,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils VIRSH_NETNAME = "virsh net-name" diff --git a/repos/network/network_uuid.py b/repos/network/network_uuid.py index 42b0dec..79c79e5 100644 --- a/repos/network/network_uuid.py +++ b/repos/network/network_uuid.py @@ -10,7 +10,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils VIRSH_NETUUID = "virsh net-uuid" diff --git a/repos/network/start.py b/repos/network/start.py index a6212b8..5debf1b 100644 --- a/repos/network/start.py +++ b/repos/network/start.py @@ -12,7 +12,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils def return_close(conn, logger, ret): conn.close() diff --git a/repos/network/undefine.py b/repos/network/undefine.py index bdb53b7..7aaa93f 100644 --- a/repos/network/undefine.py +++ b/repos/network/undefine.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/npiv/create_virtual_hba.py b/repos/npiv/create_virtual_hba.py index b032c64..f9598f4 100644 --- a/repos/npiv/create_virtual_hba.py +++ b/repos/npiv/create_virtual_hba.py @@ -12,7 +12,6 @@ from utils import xmlbuilder import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify input parameters""" diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py index 2e142d4..4af33a0 100644 --- a/repos/snapshot/delete.py +++ b/repos/snapshot/delete.py @@ -10,7 +10,6 @@ import re import libvirt from libvirt import libvirtError -from utils import utils SNAPSHOT_DIR = "/var/lib/libvirt/qemu/snapshot" diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py index 6c0987e..7568432 100644 --- a/repos/snapshot/revert.py +++ b/repos/snapshot/revert.py @@ -10,7 +10,6 @@ import re import libvirt from libvirt import libvirtError -from utils import utils def check_params(params): """Verify the input parameter""" diff --git a/repos/storage/activate_pool.py b/repos/storage/activate_pool.py index 646b396..7725ee5 100644 --- a/repos/storage/activate_pool.py +++ b/repos/storage/activate_pool.py @@ -9,7 +9,6 @@ import time import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/build_dir_pool.py b/repos/storage/build_dir_pool.py index 116a207..07d9f5c 100644 --- a/repos/storage/build_dir_pool.py +++ b/repos/storage/build_dir_pool.py @@ -12,7 +12,6 @@ from xml.dom import minidom import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/build_disk_pool.py b/repos/storage/build_disk_pool.py index e59b98f..d65eb91 100644 --- a/repos/storage/build_disk_pool.py +++ b/repos/storage/build_disk_pool.py @@ -13,7 +13,6 @@ from xml.dom import minidom import libvirt from libvirt import libvirtError -from utils import utils def usage(): """usage information""" diff --git a/repos/storage/build_logical_pool.py b/repos/storage/build_logical_pool.py index fd8818e..6234fcb 100644 --- a/repos/storage/build_logical_pool.py +++ b/repos/storage/build_logical_pool.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/build_netfs_pool.py b/repos/storage/build_netfs_pool.py index 5bdddf5..1672b77 100644 --- a/repos/storage/build_netfs_pool.py +++ b/repos/storage/build_netfs_pool.py @@ -11,7 +11,6 @@ from xml.dom import minidom import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/create_dir_pool.py b/repos/storage/create_dir_pool.py index dd7526d..71abf3d 100644 --- a/repos/storage/create_dir_pool.py +++ b/repos/storage/create_dir_pool.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/create_dir_volume.py b/repos/storage/create_dir_volume.py index 15927f3..c0e9a7c 100644 --- a/repos/storage/create_dir_volume.py +++ b/repos/storage/create_dir_volume.py @@ -12,7 +12,6 @@ from xml.dom import minidom import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/create_fs_pool.py b/repos/storage/create_fs_pool.py index cad8c18..c3ce4a5 100644 --- a/repos/storage/create_fs_pool.py +++ b/repos/storage/create_fs_pool.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder from utils import XMLParser diff --git a/repos/storage/create_iscsi_pool.py b/repos/storage/create_iscsi_pool.py index 61a1e98..71ea3f8 100644 --- a/repos/storage/create_iscsi_pool.py +++ b/repos/storage/create_iscsi_pool.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/create_netfs_pool.py b/repos/storage/create_netfs_pool.py index 035a01a..3c90882 100644 --- a/repos/storage/create_netfs_pool.py +++ b/repos/storage/create_netfs_pool.py @@ -11,7 +11,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder from utils import XMLParser diff --git a/repos/storage/create_netfs_volume.py b/repos/storage/create_netfs_volume.py index 318878c..8aa798c 100644 --- a/repos/storage/create_netfs_volume.py +++ b/repos/storage/create_netfs_volume.py @@ -12,7 +12,6 @@ from xml.dom import minidom import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/create_partition_volume.py b/repos/storage/create_partition_volume.py index 7ec9130..68c45c4 100644 --- a/repos/storage/create_partition_volume.py +++ b/repos/storage/create_partition_volume.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/define_dir_pool.py b/repos/storage/define_dir_pool.py index c1b48c3..b22b8cd 100644 --- a/repos/storage/define_dir_pool.py +++ b/repos/storage/define_dir_pool.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder VIRSH_POOLLIST = "virsh --quiet pool-list --all|awk '{print $1}'|grep \"^%s$\"" diff --git a/repos/storage/define_disk_pool.py b/repos/storage/define_disk_pool.py index fe8215e..1e95141 100644 --- a/repos/storage/define_disk_pool.py +++ b/repos/storage/define_disk_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/define_iscsi_pool.py b/repos/storage/define_iscsi_pool.py index 7b8d19a..5387aac 100644 --- a/repos/storage/define_iscsi_pool.py +++ b/repos/storage/define_iscsi_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/define_logical_pool.py b/repos/storage/define_logical_pool.py index b097b1d..4e9b2df 100644 --- a/repos/storage/define_logical_pool.py +++ b/repos/storage/define_logical_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/define_mpath_pool.py b/repos/storage/define_mpath_pool.py index 3ede935..d3803c9 100644 --- a/repos/storage/define_mpath_pool.py +++ b/repos/storage/define_mpath_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/define_netfs_pool.py b/repos/storage/define_netfs_pool.py index e0c4694..18ee7b9 100644 --- a/repos/storage/define_netfs_pool.py +++ b/repos/storage/define_netfs_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(params): diff --git a/repos/storage/define_scsi_pool.py b/repos/storage/define_scsi_pool.py index e7dabc6..a1a9c13 100644 --- a/repos/storage/define_scsi_pool.py +++ b/repos/storage/define_scsi_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/delete_dir_volume.py b/repos/storage/delete_dir_volume.py index 1c51abe..6691eff 100644 --- a/repos/storage/delete_dir_volume.py +++ b/repos/storage/delete_dir_volume.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/delete_logical_pool.py b/repos/storage/delete_logical_pool.py index ee28782..eab40b9 100644 --- a/repos/storage/delete_logical_pool.py +++ b/repos/storage/delete_logical_pool.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/delete_logical_volume.py b/repos/storage/delete_logical_volume.py index d3e69be..53b7891 100644 --- a/repos/storage/delete_logical_volume.py +++ b/repos/storage/delete_logical_volume.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/delete_netfs_volume.py b/repos/storage/delete_netfs_volume.py index f284b5f..6ad25c5 100644 --- a/repos/storage/delete_netfs_volume.py +++ b/repos/storage/delete_netfs_volume.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" diff --git a/repos/storage/delete_partition_volume.py b/repos/storage/delete_partition_volume.py index 025a8f3..6845b9c 100644 --- a/repos/storage/delete_partition_volume.py +++ b/repos/storage/delete_partition_volume.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def usage(): diff --git a/repos/storage/destroy_pool.py b/repos/storage/destroy_pool.py index 762dea6..1fa64ec 100644 --- a/repos/storage/destroy_pool.py +++ b/repos/storage/destroy_pool.py @@ -12,7 +12,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils from utils import xmlbuilder def return_close(conn, logger, ret): diff --git a/repos/storage/pool_name.py b/repos/storage/pool_name.py index e1b0138..0757b38 100644 --- a/repos/storage/pool_name.py +++ b/repos/storage/pool_name.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils VIRSH_POOLNAME = "virsh pool-name" diff --git a/repos/storage/pool_uuid.py b/repos/storage/pool_uuid.py index 28875c1..90354b8 100644 --- a/repos/storage/pool_uuid.py +++ b/repos/storage/pool_uuid.py @@ -11,7 +11,6 @@ import commands import libvirt from libvirt import libvirtError -from utils import utils VIRSH_POOLUUID = "virsh pool-uuid" diff --git a/repos/storage/undefine_pool.py b/repos/storage/undefine_pool.py index c2865c1..2bb7400 100644 --- a/repos/storage/undefine_pool.py +++ b/repos/storage/undefine_pool.py @@ -10,7 +10,6 @@ import sys import libvirt from libvirt import libvirtError -from utils import utils def usage(params): """Verify inputing parameter dictionary""" -- 1.7.7.5

On 04/10/2012 03:34 PM, Osier Yang wrote:
--- repos/domain/autostart.py | 1 - repos/domain/blkstats.py | 1 - repos/domain/console_mutex.py | 1 - repos/domain/domain_blkinfo.py | 1 - repos/domain/domain_id.py | 1 - repos/domain/domain_uuid.py | 1 - repos/domain/domblkinfo.py | 1 - repos/domain/eventhandler.py | 1 - repos/domain/migrate.py | 1 - repos/domain/undefine.py | 1 - repos/interface/define.py | 1 - repos/interface/undefine.py | 1 - repos/network/autostart.py | 1 - repos/network/create.py | 1 - repos/network/define.py | 1 - repos/network/destroy.py | 1 - repos/network/network_name.py | 1 - repos/network/network_uuid.py | 1 - repos/network/start.py | 1 - repos/network/undefine.py | 1 - repos/npiv/create_virtual_hba.py | 1 - repos/snapshot/delete.py | 1 - repos/snapshot/revert.py | 1 - repos/storage/activate_pool.py | 1 - repos/storage/build_dir_pool.py | 1 - repos/storage/build_disk_pool.py | 1 - repos/storage/build_logical_pool.py | 1 - repos/storage/build_netfs_pool.py | 1 - repos/storage/create_dir_pool.py | 1 - repos/storage/create_dir_volume.py | 1 - repos/storage/create_fs_pool.py | 1 - repos/storage/create_iscsi_pool.py | 1 - repos/storage/create_netfs_pool.py | 1 - repos/storage/create_netfs_volume.py | 1 - repos/storage/create_partition_volume.py | 1 - repos/storage/define_dir_pool.py | 1 - repos/storage/define_disk_pool.py | 1 - repos/storage/define_iscsi_pool.py | 1 - repos/storage/define_logical_pool.py | 1 - repos/storage/define_mpath_pool.py | 1 - repos/storage/define_netfs_pool.py | 1 - repos/storage/define_scsi_pool.py | 1 - repos/storage/delete_dir_volume.py | 1 - repos/storage/delete_logical_pool.py | 1 - repos/storage/delete_logical_volume.py | 1 - repos/storage/delete_netfs_volume.py | 1 - repos/storage/delete_partition_volume.py | 1 - repos/storage/destroy_pool.py | 1 - repos/storage/pool_name.py | 1 - repos/storage/pool_uuid.py | 1 - repos/storage/undefine_pool.py | 1 - 51 files changed, 0 insertions(+), 51 deletions(-)
pushed. Thanks Guannan Ren
participants (2)
-
Guannan Ren
-
Osier Yang