aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/lib
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-18 10:08:37 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-18 10:08:37 +0100
commit05a6e5c04e2b888c309d5e319344550dbad78556 (patch)
treeeb4da7f0a50832820c44a5f3cd482294196b0e86 /tools/xm-test/lib
parenta903e96fce80d3b8b61d9fae3632c72a4ffdc424 (diff)
downloadxen-05a6e5c04e2b888c309d5e319344550dbad78556.tar.gz
xen-05a6e5c04e2b888c309d5e319344550dbad78556.tar.bz2
xen-05a6e5c04e2b888c309d5e319344550dbad78556.zip
[Xm-Test] Additional tests for the xm-test suite
This adds a couple of test cases exercising the new policy management functionality to the security tests. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools/xm-test/lib')
-rw-r--r--tools/xm-test/lib/XmTestLib/XenAPIDomain.py4
-rw-r--r--tools/xm-test/lib/XmTestLib/acm.py52
2 files changed, 47 insertions, 9 deletions
diff --git a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
index d34d369f0f..2c6ae016df 100644
--- a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
+++ b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py
@@ -23,6 +23,7 @@ import os
import sys
from XmTestLib import *
from types import DictType
+from acm import *
class XenAPIConfig:
@@ -38,6 +39,9 @@ class XenAPIConfig:
'kernel' : 'PV_kernel',
'ramdisk': 'PV_ramdisk',
'root' : 'PV_args'}
+ if isACMEnabled():
+ #A default so every VM can start with ACM enabled
+ self.opts["security_label"] = "ACM:xm-test:red"
def setOpt(self, name, value):
"""Set an option in the config"""
diff --git a/tools/xm-test/lib/XmTestLib/acm.py b/tools/xm-test/lib/XmTestLib/acm.py
index c670bc039b..dc9ab1611a 100644
--- a/tools/xm-test/lib/XmTestLib/acm.py
+++ b/tools/xm-test/lib/XmTestLib/acm.py
@@ -19,6 +19,9 @@
"""
from Test import *
from xen.util import security
+from xen.xm.main import server
+from xen.util import xsconstants
+import re
try:
from acm_config import *
@@ -32,16 +35,47 @@ def isACMEnabled():
return security.on()
+def getSystemPolicyName():
+ s,o = traceCommand("xm getpolicy")
+ m = re.compile("Policy name[\s]*: ([A-z\-]+)").search(o)
+ if m:
+ polname = m.group(1)
+ return polname
+ return ""
+
+
+def ACMLoadPolicy_XenAPI(policy='xm-test'):
+ polname = getSystemPolicyName()
+ if polname != policy:
+ # Try it, maybe it's not activated
+ traceCommand("xm setpolicy %s %s" %
+ (xsconstants.XS_POLICY_ACM, policy))
+ polname = getSystemPolicyName()
+ if polname != policy:
+ FAIL("Need to have a system with no or policy '%s' active, "
+ "not %s" % (policy,polname))
+ else:
+ s, o = traceCommand("xm activatepolicy --load")
+ else:
+ s, o = traceCommand("xm activatepolicy --load")
+ if not re.search("Successfully", o):
+ FAIL("Could not set the policy '%s'." % policy)
+
+
def ACMLoadPolicy(policy='xm-test'):
- s, o = traceCommand("xm makepolicy %s" % (policy))
- if s != 0:
- FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
- (policy))
- s, o = traceCommand("xm loadpolicy %s" % (policy))
- if s != 0:
- FAIL("Could not load the required policy '%s'.\n"
- "Start the system without any policy.\n%s" %
- (policy, o))
+ from xen.xm import main
+ if main.serverType == main.SERVER_XEN_API:
+ ACMLoadPolicy_XenAPI()
+ else:
+ s, o = traceCommand("xm makepolicy %s" % (policy))
+ if s != 0:
+ FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
+ (policy))
+ s, o = traceCommand("xm loadpolicy %s" % (policy))
+ if s != 0:
+ FAIL("Could not load the required policy '%s'.\n"
+ "Start the system without any policy.\n%s" %
+ (policy, o))
def ACMPrepareSystem(resources):
if isACMEnabled():