xm-test: various fixes
authorKeir Fraser <keir@xensource.com>
Thu, 25 Oct 2007 08:22:28 +0000 (09:22 +0100)
committerKeir Fraser <keir@xensource.com>
Thu, 25 Oct 2007 08:22:28 +0000 (09:22 +0100)
- recently I added an other_config field to the VTPM record which now
needs to be accounted for otherwise the test determines a bad key
- the dry-run command was throwing a different type of exception
(ACMError) than what was caught (XSMError)
- the tests based on the raw Xen-API need to build the PV_args
parameters from the old 'root' and 'extra' parameters.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
tools/python/xen/xm/create.py
tools/xm-test/lib/XmTestLib/XenAPIDomain.py
tools/xm-test/tests/security-acm/08_security-acm_xapi.py
tools/xm-test/tests/vtpm/09_vtpm-xapi.py

index 67a3c9418a8453f4612c019acdf9a33f1911baab..b9bd16258d3c514a4edf37765fb899cf72a50425 100644 (file)
@@ -1228,7 +1228,7 @@ def config_security_check(config, verbose):
             if verbose:
                 print "   %s: PERMITTED" % (resource)
 
-        except security.XSMError:
+        except security.ACMError:
             print "   %s: DENIED" % (resource)
             (poltype, res_label, res_policy) = security.get_res_label(resource)
             if not res_label:
index 2c6ae016dfdbc4f30236ea173421a4e6f5cd5629..31b91eed68034cb54e13d65fb92ceb756871516b 100644 (file)
@@ -38,7 +38,8 @@ class XenAPIConfig:
                                         'memory_dynamic_max' ],
                            'kernel' : 'PV_kernel',
                            'ramdisk': 'PV_ramdisk',
-                           'root'   : 'PV_args'}
+                           'root'   : 'PV_args',
+                           'extra'  : 'PV_args' }
         if isACMEnabled():
             #A default so every VM can start with ACM enabled
             self.opts["security_label"] = "ACM:xm-test:red"
@@ -47,6 +48,8 @@ class XenAPIConfig:
         """Set an option in the config"""
         if name == "memory":
             value <<= 20
+        if name == "root":
+            value = "root=" + value
         if name in self.opttrlate.keys():
             _name = self.opttrlate[name]
         else:
@@ -56,7 +59,11 @@ class XenAPIConfig:
             for _n in _name:
                 self.opts[_n] = value
         else:
-            self.opts[_name] = value
+            if not self.opts.get(_name) or \
+               not _name in [ "PV_args" ]:
+                self.opts[_name] = value
+            else:
+                self.opts[_name] += " " + value
 
     def getOpt(self, name):
         """Return the value of a config option"""
index 44e2fce0084fa74ea45029d95b29cfb740439f69..469bf35a91ed5515ddef10112dace49babbb4564 100644 (file)
@@ -19,6 +19,9 @@ vm_label_green  = xsconstants.ACM_POLICY_ID + ":xm-test:green"
 vdi_label_red   = xsconstants.ACM_POLICY_ID + ":xm-test:red"
 vdi_label_green = xsconstants.ACM_POLICY_ID + ":xm-test:green"
 
+vm_label_unlabeled = xsconstants.ACM_POLICY_ID + ":xm-test:" + \
+                     acmpolicy.ACM_LABEL_UNLABELED
+
 vdi_file = "/dev/ram0"
 vdi_path = "phy:" + vdi_file
 
@@ -105,7 +108,7 @@ if int(res) != 0:
     FAIL("Should be able to unlabel the domain while it's halted.")
 
 res = session.xenapi.VM.get_security_label(vm_uuid)
-if res != "":
+if res != vm_label_unlabeled:
     FAIL("Unexpected VM security label after removal: %s" % res)
 
 res = session.xenapi.VM.set_security_label(vm_uuid, vm_label_red, res)
index 5c8fb1188023090e94ccecb14182e8e782efab27..a1aa8b3c703470030aaa1a4bec1e610dc5ca2a56 100644 (file)
@@ -17,7 +17,7 @@ from vtpm_utils import *
 import commands
 import os
 
-VTPM_RECORD_KEYS = [ 'backend', 'VM', 'uuid' ]
+VTPM_RECORD_KEYS = [ 'backend', 'VM', 'uuid', 'other_config' ]
 
 try:
     # XmTestAPIDomain tries to establish a connection to XenD