ia64/xen-unstable

changeset 15672:55fb4c6e7702

[ACM] Some more fixes

- don't reload the policy if it has been loaded
- don't always load the policy in the test suite when the policy is
already loaded
- skip tests 07 and 09 when ACM is not enabled and xm is not using the
Xen-API
- fix a problem when trying to remove an invalid label

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Jul 30 16:03:16 2007 +0100 (2007-07-30)
parents 9cd309378326
children 8daf61f4d89d
files tools/python/xen/util/acmpolicy.py tools/xm-test/lib/XmTestLib/acm.py tools/xm-test/tests/security-acm/07_security-acm_pol_update.py tools/xm-test/tests/security-acm/09_security-acm_pol_update.py
line diff
     1.1 --- a/tools/python/xen/util/acmpolicy.py	Mon Jul 30 11:28:16 2007 +0100
     1.2 +++ b/tools/python/xen/util/acmpolicy.py	Mon Jul 30 16:03:16 2007 +0100
     1.3 @@ -818,12 +818,13 @@ class ACMPolicy(XSPolicy):
     1.4              if successful,the policy's flags will indicate that the
     1.5              policy is the one loaded into the hypervisor
     1.6          """
     1.7 -        (ret, output) = commands.getstatusoutput(
     1.8 +        if not self.isloaded():
     1.9 +            (ret, output) = commands.getstatusoutput(
    1.10                                     security.xensec_tool +
    1.11                                     " loadpolicy " +
    1.12                                     self.get_filename(".bin"))
    1.13 -        if ret != 0:
    1.14 -            return -xsconstants.XSERR_POLICY_LOAD_FAILED
    1.15 +            if ret != 0:
    1.16 +                return -xsconstants.XSERR_POLICY_LOAD_FAILED
    1.17          return xsconstants.XSERR_SUCCESS
    1.18  
    1.19      def isloaded(self):
     2.1 --- a/tools/xm-test/lib/XmTestLib/acm.py	Mon Jul 30 11:28:16 2007 +0100
     2.2 +++ b/tools/xm-test/lib/XmTestLib/acm.py	Mon Jul 30 16:03:16 2007 +0100
     2.3 @@ -67,6 +67,10 @@ def ACMLoadPolicy(policy='xm-test'):
     2.4      if main.serverType == main.SERVER_XEN_API:
     2.5          ACMLoadPolicy_XenAPI()
     2.6      else:
     2.7 +        cmd='xm dumppolicy | grep -E "^POLICY REFERENCE = ' + policy + '.$"'
     2.8 +        s, o = traceCommand(cmd)
     2.9 +        if o != "":
    2.10 +            return
    2.11          s, o = traceCommand("xm makepolicy %s" % (policy))
    2.12          if s != 0:
    2.13              FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
     3.1 --- a/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py	Mon Jul 30 11:28:16 2007 +0100
     3.2 +++ b/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py	Mon Jul 30 16:03:16 2007 +0100
     3.3 @@ -12,11 +12,20 @@ from xen.xend import XendAPIConstants
     3.4  from xen.util import acmpolicy, security, xsconstants
     3.5  from xen.util.acmpolicy import ACMPolicy
     3.6  from xen.xend.XendDomain import DOM0_UUID
     3.7 +from XmTestLib.acm import *
     3.8  
     3.9  import commands
    3.10  import os
    3.11  import base64
    3.12  
    3.13 +if not isACMEnabled():
    3.14 +    SKIP("Not running this test since ACM not enabled.")
    3.15 +
    3.16 +try:
    3.17 +    session = xapi.connect()
    3.18 +except:
    3.19 +    SKIP("Skipping this test since xm is not using the Xen-API.")
    3.20 +
    3.21  xm_test = {}
    3.22  xm_test['policyname'] = "xm-test"
    3.23  xm_test['date'] = "Fri Sep 29 14:44:38 2006"
     4.1 --- a/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py	Mon Jul 30 11:28:16 2007 +0100
     4.2 +++ b/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py	Mon Jul 30 16:03:16 2007 +0100
     4.3 @@ -7,6 +7,7 @@
     4.4  
     4.5  from XmTestLib import xapi
     4.6  from XmTestLib.XenAPIDomain import XmTestAPIDomain
     4.7 +from XmTestLib.acm import *
     4.8  from XmTestLib import *
     4.9  from xen.xend import XendAPIConstants
    4.10  from xen.util import security, xsconstants
    4.11 @@ -16,6 +17,14 @@ import base64
    4.12  import struct
    4.13  import time
    4.14  
    4.15 +if not isACMEnabled():
    4.16 +    SKIP("Not running this test since ACM not enabled.")
    4.17 +
    4.18 +try:
    4.19 +    session = xapi.connect()
    4.20 +except:
    4.21 +    SKIP("Skipping this test since xm is not using the Xen-API.")
    4.22 +
    4.23  def typestoxml(types):
    4.24      res = ""
    4.25      for t in types: