# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1219263328 25200
# Node ID 7d4ed16e284fe614f8f61909850db14fec0070ab
# Parent 6d3fac9485bc4f4e259d82af1c1fb7c0028b03ae
[TEST] Move get_revision() from main.py to const.py
This cleans up main.py and removes the need to pass the revision and changeset values as
environment variables.
Instead of accessing the revision and changeset values using CIM_REV and CIM_SET
respectively, tests will need to call the get_provider_revision() function.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 6d3fac9485bc -r 7d4ed16e284f suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Aug 20 13:13:46 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Aug 20 13:15:28 2008 -0700
@@ -22,20 +22,8 @@
import platform
from VirtLib.live import fv_cap
from CimTest.Globals import CIM_IP
-
-global CIM_REV
-global CIM_SET
-
-rev = os.getenv("CIM_REV").strip("+")
-if rev.isdigit():
- CIM_REV = int(rev)
-else:
- CIM_REV = 0
-CIM_SET = os.getenv("CIM_SET")
-
-if not CIM_REV or not CIM_SET:
- CIM_REV = 0
- CIM_SET = 'Unknown'
+from pywbem import WBEMConnection
+from XenKvmLib.classes import get_typed_class
# vxml.NetXML
default_bridge_name = 'testbridge'
@@ -91,3 +79,26 @@
LXC_default_mp = '/tmp'
LXC_default_source = '/tmp/lxc_files'
LXC_default_mac = '11:22:33:aa:bb:cc'
+
+def get_provider_version(virt, ip):
+ conn = WBEMConnection('http://%s' % ip,
+ (os.getenv('CIM_USER'),
os.getenv('CIM_PASS')),
+ os.getenv('CIM_NS'))
+ vsms_cn = get_typed_class(virt, 'VirtualSystemManagementService')
+ try:
+ inst = conn.EnumerateInstances(vsms_cn)
+ revision = inst[0]['Revision']
+ changeset = inst[0]['Changeset']
+ except Exception:
+ return 0, "Unknown"
+
+ if revision is None or changeset is None:
+ return 0, "Unknown"
+
+ revision.strip("+")
+ if revision.isdigit():
+ revision = int(revision)
+
+ return revision, changeset
+
+
diff -r 6d3fac9485bc -r 7d4ed16e284f suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py Wed Aug 20 13:13:46 2008 -0700
+++ b/suites/libvirt-cim/main.py Wed Aug 20 13:15:28 2008 -0700
@@ -25,15 +25,13 @@
from optparse import OptionParser
import os
import sys
-from pywbem import WBEMConnection
sys.path.append('../../lib')
import TestSuite
import commands
from VirtLib import groups
from CimTest.Globals import platform_sup
+import ConfigParser
sys.path.append('./lib')
-from XenKvmLib.classes import get_typed_class
-import ConfigParser
from XenKvmLib.reporting import gen_report, send_report
from VirtLib import utils
@@ -124,22 +122,6 @@
return addr, relay
-def get_version(virt, ip):
- conn = WBEMConnection('http://%s' % ip,
- (os.getenv('CIM_USER'),
os.getenv('CIM_PASS')),
- os.getenv('CIM_NS'))
- vsms_cn = get_typed_class(virt, 'VirtualSystemManagementService')
- try:
- inst = conn.EnumerateInstances(vsms_cn)
- revision = inst[0]['Revision']
- changeset = inst[0]['Changeset']
- except Exception:
- return '0', 'Unknown'
- if revision is None:
- revision = '0'
- if changeset is None:
- changeset = 'Unknown'
- return revision, changeset
def main():
(options, args) = parser.parse_args()
@@ -191,8 +173,6 @@
else:
dbg = ""
- revision, changeset = get_version(options.virt, options.ip)
-
print "\nTesting " + options.virt + " hypervisor"
for test in test_list:
@@ -200,10 +180,9 @@
t_path = os.path.join(TEST_SUITE, test['group'])
os.environ['CIM_TC'] = test['test']
cdto = 'cd %s' % t_path
- env = 'CIM_REV=%s CIM_SET=%s' % (revision, changeset)
run = 'python %s -i %s -v %s %s' % (test['test'], options.ip,
options.virt, dbg)
- cmd = cdto + ' && ' + env + ' ' + run
+ cmd = cdto + ' && ' + ' ' + run
status, output = commands.getstatusoutput(cmd)
os_status = os.WEXITSTATUS(status)