From: Stefan Berger Subject: [PATCH] [ACM] Some more fixes Date: Mon, 30 Jul 2007 10:36:29 -0400 Message-ID: <1185806189.16233.2.camel@gsal-3.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-Dq6WL+QTwic0//dWk3Wj" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-Dq6WL+QTwic0//dWk3Wj Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch fixes a couple of problems: - 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 --=-Dq6WL+QTwic0//dWk3Wj Content-Disposition: attachment; filename=acm_fixes.diff Content-Type: text/x-patch; name=acm_fixes.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/util/acmpolicy.py +++ root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py @@ -818,12 +818,13 @@ class ACMPolicy(XSPolicy): if successful,the policy's flags will indicate that the policy is the one loaded into the hypervisor """ - (ret, output) = commands.getstatusoutput( + if not self.isloaded(): + (ret, output) = commands.getstatusoutput( security.xensec_tool + " loadpolicy " + self.get_filename(".bin")) - if ret != 0: - return -xsconstants.XSERR_POLICY_LOAD_FAILED + if ret != 0: + return -xsconstants.XSERR_POLICY_LOAD_FAILED return xsconstants.XSERR_SUCCESS def isloaded(self): Index: root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py =================================================================== --- root.orig/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py +++ root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py @@ -67,6 +67,10 @@ def ACMLoadPolicy(policy='xm-test'): if main.serverType == main.SERVER_XEN_API: ACMLoadPolicy_XenAPI() else: + cmd='xm dumppolicy | grep -E "^POLICY REFERENCE = ' + policy + '.$"' + s, o = traceCommand(cmd) + if o != "": + return s, o = traceCommand("xm makepolicy %s" % (policy)) if s != 0: FAIL("Need to be able to do 'xm makepolicy %s' but could not" % Index: root/xen-unstable.hg/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py =================================================================== --- root.orig/xen-unstable.hg/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py +++ root/xen-unstable.hg/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py @@ -12,11 +12,20 @@ from xen.xend import XendAPIConstants from xen.util import acmpolicy, security, xsconstants from xen.util.acmpolicy import ACMPolicy from xen.xend.XendDomain import DOM0_UUID +from XmTestLib.acm import * import commands import os import base64 +if not isACMEnabled(): + SKIP("Not running this test since ACM not enabled.") + +try: + session = xapi.connect() +except: + SKIP("Skipping this test since xm is not using the Xen-API.") + xm_test = {} xm_test['policyname'] = "xm-test" xm_test['date'] = "Fri Sep 29 14:44:38 2006" Index: root/xen-unstable.hg/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py =================================================================== --- root.orig/xen-unstable.hg/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py +++ root/xen-unstable.hg/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py @@ -7,6 +7,7 @@ from XmTestLib import xapi from XmTestLib.XenAPIDomain import XmTestAPIDomain +from XmTestLib.acm import * from XmTestLib import * from xen.xend import XendAPIConstants from xen.util import security, xsconstants @@ -16,6 +17,14 @@ import base64 import struct import time +if not isACMEnabled(): + SKIP("Not running this test since ACM not enabled.") + +try: + session = xapi.connect() +except: + SKIP("Skipping this test since xm is not using the Xen-API.") + def typestoxml(types): res = "" for t in types: Index: root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/util/acmpolicy.py +++ root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py @@ -818,12 +818,13 @@ class ACMPolicy(XSPolicy): if successful,the policy's flags will indicate that the policy is the one loaded into the hypervisor """ - (ret, output) = commands.getstatusoutput( + if not self.isloaded(): + (ret, output) = commands.getstatusoutput( security.xensec_tool + " loadpolicy " + self.get_filename(".bin")) - if ret != 0: - return -xsconstants.XSERR_POLICY_LOAD_FAILED + if ret != 0: + return -xsconstants.XSERR_POLICY_LOAD_FAILED return xsconstants.XSERR_SUCCESS def isloaded(self): Index: root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py =================================================================== --- root.orig/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py +++ root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py @@ -67,6 +67,10 @@ def ACMLoadPolicy(policy='xm-test'): if main.serverType == main.SERVER_XEN_API: ACMLoadPolicy_XenAPI() else: + cmd='xm dumppolicy | grep -E "^POLICY REFERENCE = ' + policy + '.$"' + s, o = traceCommand(cmd) + if o != "": + return s, o = traceCommand("xm makepolicy %s" % (policy)) if s != 0: FAIL("Need to be able to do 'xm makepolicy %s' but could not" % --=-Dq6WL+QTwic0//dWk3Wj Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-Dq6WL+QTwic0//dWk3Wj--