# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1225682193 28800
# Node ID a13401dd0d0f52a72e6d82f13c0b2142c47a869a
# Parent d1614c101c281b57bd2bc98dfb6625f790748e54
[TEST]#2 Delete the functions have been removed to xm_virt_util.py and update related tc
and library
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r d1614c101c28 -r a13401dd0d0f lib/VirtLib/live.py
--- a/lib/VirtLib/live.py Wed Oct 29 20:11:47 2008 -0700
+++ b/lib/VirtLib/live.py Sun Nov 02 19:16:33 2008 -0800
@@ -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.
"""
@@ -180,75 +136,6 @@
return None
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'"
@@ -269,88 +156,3 @@
"""To return the fully qualifiec domain name(FQDN) of the
system"""
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 d1614c101c28 -r a13401dd0d0f
suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py
--- a/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Wed Oct 29 20:11:47
2008 -0700
+++ b/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Sun Nov 02 19:16:33
2008 -0800
@@ -26,7 +26,7 @@
#
import sys
-from VirtLib.live import domain_list
+from XenKvmLib.xm_virt_util import domain_list
from XenKvmLib.enumclass import EnumInstances
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.classes import get_typed_class
diff -r d1614c101c28 -r a13401dd0d0f
suites/libvirt-cim/cimtest/RedirectionService/02_enum_crscap.py
--- a/suites/libvirt-cim/cimtest/RedirectionService/02_enum_crscap.py Wed Oct 29 20:11:47
2008 -0700
+++ b/suites/libvirt-cim/cimtest/RedirectionService/02_enum_crscap.py Sun Nov 02 19:16:33
2008 -0800
@@ -26,7 +26,7 @@
#
import sys
-from VirtLib.live import domain_list
+from XenKvmLib.xm_virt_util import domain_list
from XenKvmLib.enumclass import EnumInstances
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.classes import get_typed_class
diff -r d1614c101c28 -r a13401dd0d0f suites/libvirt-cim/cimtest/VSSD/01_enum.py
--- a/suites/libvirt-cim/cimtest/VSSD/01_enum.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VSSD/01_enum.py Sun Nov 02 19:16:33 2008 -0800
@@ -27,7 +27,7 @@
# Date : 25-10-2007
import sys
-from VirtLib import live
+from XenKvmLib.xm_virt_util import domain_list
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
from XenKvmLib.test_doms import destroy_and_undefine_all
@@ -53,7 +53,7 @@
status = FAIL
try:
- live_cs = live.domain_list(options.ip, options.virt)
+ live_cs = domain_list(options.ip, options.virt)
vssd_class = get_typed_class(options.virt, "VirtualSystemSettingData")
syslst = enumclass.EnumInstances(options.ip, vssd_class)
found = 0
diff -r d1614c101c28 -r a13401dd0d0f suites/libvirt-cim/cimtest/VSSD/02_bootldr.py
--- a/suites/libvirt-cim/cimtest/VSSD/02_bootldr.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VSSD/02_bootldr.py Sun Nov 02 19:16:33 2008 -0800
@@ -30,7 +30,7 @@
from XenKvmLib import enumclass
from XenKvmLib.vxml import get_class
from VirtLib import utils
-from VirtLib.live import bootloader
+from XenKvmLib.xm_virt_util import bootloader
from XenKvmLib.test_doms import destroy_and_undefine_all
from CimTest.Globals import logger
from XenKvmLib.const import do_main
diff -r d1614c101c28 -r a13401dd0d0f suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Nov 02 19:16:33 2008 -0800
@@ -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
diff -r d1614c101c28 -r a13401dd0d0f suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Sun Nov 02 19:16:33 2008 -0800
@@ -27,7 +27,7 @@
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
-from VirtLib.live import domain_list
+from XenKvmLib.xm_virt_util import domain_list
class CIM_VirtualSystemMigrationService(CIMMethodClass):
conn = None
diff -r d1614c101c28 -r a13401dd0d0f suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Nov 02 19:16:33 2008 -0800
@@ -24,8 +24,8 @@
from CimTest import Globals
from CimTest.ReturnCodes import FAIL, PASS
from CimTest.Globals import logger
-from VirtLib.live import network_by_bridge, virsh_vcpuinfo, \
- get_bridge_from_network_xml
+from XenKvmLib.xm_virt_util import network_by_bridge, virsh_vcpuinfo, \
+get_bridge_from_network_xml
def print_mod_err_msg(func_str, details):
logger.error('Error invoking ModifyRS: %s' % func_str)