# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1225344599 25200
# Node ID 2c9e9038145f1177e5e61258ea44da9c61dc1647
# Parent 408dbb3a61b43bd0def587a9ea7e648105def002
[TEST] Delete the functions have been removed to xm_virt_util.py and update
common_util.py
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 408dbb3a61b4 -r 2c9e9038145f lib/VirtLib/live.py
--- a/lib/VirtLib/live.py Mon Oct 27 20:03:31 2008 -0700
+++ b/lib/VirtLib/live.py Wed Oct 29 22:29:59 2008 -0700
@@ -112,50 +112,6 @@
return out.splitlines()
-def xm_domname(ip, domid):
-
- cmd = "xm domname %s" % domid
-
- rc, out = utils.run_remote(ip, cmd)
- if rc != 0:
- return None
-
- return out
-
-def list_guests_on_bridge(ip, bridge):
- """Returns a list of domU names that have vifs in the
- specified bridge.
- """
-
- cmd = "brctl show %s | grep 'vif' | grep -v vif0.*" % bridge
-
- rc, out = utils.run_remote(ip, cmd)
- if rc != 0:
- return []
-
- ret = []
- lines = out.splitlines()
- for l in lines:
- vif = l.split()[-1]
- domid = vif.replace('vif', '').split('.')[0]
- domname = xm_domname(ip, domid)
- if domname != None:
- ret.append(domname)
-
- return ret
-
-def disk_list(ip, vs_name):
- """Returns the list of disk of the specified VS
- """
-
- guest_cmd = "cat /proc/partitions | awk '/^ /{ print $4 } ' "
- rc, out = utils.run_remote_guest(ip, vs_name, guest_cmd)
-
- if rc != 0:
- return None
-
- return out
-
def create_disk_file(ip, size, diskfile) :
"""Creates a disk file 1MB block-size ,and if succsess returns disk
created.
"""
@@ -181,74 +137,6 @@
return int(mfm)
-def domain_list(server, virt="Xen"):
- """Function to list all domains"""
- if virt == "XenFV":
- virt = "Xen"
-
- cmd = "virsh -c %s list --all | sed -e '1,2 d' -e '$ d'" %
\
- utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
-
- if ret != 0:
- return None
- names = []
- lines = out.split("\n")
- for line in lines:
- dinfo = line.split()
- if len(dinfo) > 1:
- names.append(dinfo[1])
-
- return names
-
-def active_domain_list(server, virt="Xen"):
- """Function to list all active domains"""
- if virt == "XenFV":
- virt = "Xen"
-
- cmd = "virsh -c %s list | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
-
- if ret != 0:
- return None
- names = []
- lines = out.split("\n")
- for line in lines:
- dinfo = line.split()
- if len(dinfo) > 1:
- names.append(dinfo[1])
-
- return names
-
-def bootloader(server, gtype = 0):
- """
- Function to find the bootloader to be used.
- It uses the following steps to determine the bootloader.
- 1) The function checks if the machine is full virt or para virt.
- 2) Checks if a Full virt guest option is set
- NOTE : gtype = 1 for FV and gtype = 0 for PV
- i) If yes, then verifies if the machine has the support to
- create the full virt guest. If both options are true then
- bootloader is set to 'hvmloader'
- ii) Otherwise, a paravirt guest creation is requested.
- a) Verfies the OS on which it is running is Red hat/Fedora/SLES.
- b) sets the bootloader to pygrub for Red hat/Fedora
- or domUloader.py for SLES.
- 3) returns the bootloader.
- """
- if fv_cap(server) and gtype == 1:
- bootloader = "/usr/lib/xen/boot/hvmloader"
- else:
- cmd = "cat /etc/issue | grep -v ^$ | egrep 'Red Hat|Fedora'"
- ret, out = utils.run_remote(server,cmd)
- if ret != 0:
- # For SLES
- bootloader = "/usr/lib/xen/boot/domUloader.py"
- else:
- # For Red Hat or Fedora
- bootloader = "/usr/bin/pygrub"
- return bootloader
def fv_cap(server):
cmd = "egrep flags /proc/cpuinfo | uniq | egrep 'vmx|svm'"
@@ -270,87 +158,3 @@
return socket.gethostbyaddr(socket.gethostname())[0]
-
-def net_list(server, virt="Xen"):
- """Function to list active network"""
- names = []
- cmd = "virsh -c %s net-list | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
-
- if ret != 0:
- return names
- lines = out.split("\n")
- for line in lines:
- virt_network = line.split()
- if len(virt_network) >= 1 and virt_network[1] == "active":
- names.append(virt_network[0])
-
- return names
-
-def get_bridge_from_network_xml(network, server, virt="Xen"):
- """Function returns bridge name for a given virtual
network"""
-
- cmd = "virsh -c %s net-dumpxml %s | awk '/bridge name/ { print $2
}'" % \
- (utils.virt2uri(virt), network)
- ret, out = utils.run_remote(server, cmd)
-
- if ret != 0:
- return None
- bridge = out.split("'")
- if len(bridge) > 1:
- return bridge[1]
-
-def network_by_bridge(bridge, server, virt="Xen"):
- """Function returns virtual network for a given
bridge"""
-
- networks = net_list(server, virt)
- if len(networks) == 0:
- return None
-
- for network in networks:
- if bridge == get_bridge_from_network_xml(network, server, virt):
- return network
-
- return None
-
-def virsh_version(server, virt="KVM"):
- cmd = "virsh -c %s -v " % utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
- if ret != 0:
- return None
- return out
-
-def diskpool_list(server, virt="KVM"):
- """Function to list active DiskPool list"""
- names = []
- cmd = "virsh -c %s pool-list | sed -e '1,2 d' -e '$ d'" %
\
- utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
-
- if ret != 0:
- return names
-
- lines = out.split("\n")
- for line in lines:
- disk_pool = line.split()
- if len(disk_pool) >= 1 and disk_pool[1] == "active":
- names.append(disk_pool[0])
-
- return names
-
-def virsh_vcpuinfo(server, dom, virt="Xen"):
- cmd = "virsh -c %s vcpuinfo %s | grep VCPU | wc -l" %
(utils.virt2uri(virt),
- dom)
- ret, out = utils.run_remote(server, cmd)
- if out.isdigit():
- return out
- return None
-
-def get_hv_ver(server, virt="Xen"):
- cmd = "virsh -c %s version | grep ^Running | cut -d ' ' -f 3,4" %
utils.virt2uri(virt)
- ret, out = utils.run_remote(server, cmd)
- if ret == 0:
- return out
- else:
- return None
diff -r 408dbb3a61b4 -r 2c9e9038145f suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Oct 27 20:03:31 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Oct 29 22:29:59 2008 -0700
@@ -36,7 +36,7 @@
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, \
CIM_ERROR_GETINSTANCE
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
-from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list
+from XenKvmLib.xm_virt_util import diskpool_list, virsh_version, net_list, domain_list
from XenKvmLib.vxml import PoolXML, NetXML
from VirtLib import utils
from XenKvmLib.const import default_pool_name, default_network_name