Ejemplo n.º 1
0
newpolicyxml = None
f = open("xm-test-new-security_policy.xml", 'r')
if f:
    newpolicyxml = f.read()
    f.close()
else:
    FAIL("Could not read 'xm-test-new' policy")

cur_acmpol = ACMPolicy(xml=policystate['repr'])
new_acmpol = ACMPolicy(xml=newpolicyxml)

new_acmpol.update_frompolicy(cur_acmpol)

policystate = session.xenapi.XSPolicy.set_xspolicy(
    xsconstants.XS_POLICY_ACM, new_acmpol.toxml(),
    xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT, 1)

f = open("xm-test-security_policy.xml", 'r')
if f:
    newpolicyxml = f.read()
    f.close()
else:
    FAIL("Could not read 'xm-test-new' policy")

cur_acmpol = new_acmpol
new_acmpol = ACMPolicy(xml=newpolicyxml)

new_acmpol.update_frompolicy(cur_acmpol)

policystate = session.xenapi.XSPolicy.set_xspolicy(
Ejemplo n.º 2
0
print "policystate %s" % policystate

if int(policystate['xserr']) == 0:
    FAIL("(6) Should not have been able to set this policy.")

#
# End the test by installing the initial policy again
#

cur_version = hdr['version']
(maj, min) = cur_version.split(".")
cur_version = "%s.%s" % (maj, str(int(min) - 1))

orig_acmpol = ACMPolicy(xml=xml_good)
orig_acmpol.set_frompolicy_version(cur_version)
orig_acmpol.set_policy_version(hdr['version'])

policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
                                                   orig_acmpol.toxml(),
                                                   xsconstants.XS_INST_LOAD,
                                                   True)

if int(policystate['xserr']) != 0:
    FAIL("(END) Should have been able to set this policy.")

domain1.stop()
domain2.stop()
domain1.destroy()
domain2.destroy()