def set_xspolicy(self, xstype, xml, flags, overwrite): ref = "" xstype = int(xstype) flags = int(flags) polstate = { 'xs_ref': "", 'repr' : "", 'type' : 0, 'flags' : 0 , 'version': 0 , 'errors' : "", 'xserr' : 0 } if xstype == xsconstants.XS_POLICY_ACM: poladmin = XSPolicyAdminInstance() try: (xspol, rc, errors) = poladmin.add_acmpolicy_to_system( xml, flags, overwrite) if rc != 0: polstate.update( { 'xserr' : rc, 'errors': base64.b64encode(errors) } ) else: ref = xspol.get_ref() polstate = { 'xs_ref' : ref, 'flags' : poladmin.get_policy_flags(xspol), 'type' : xstype, 'repr' : "", 'version': xspol.get_version(), 'errors' : base64.b64encode(errors), 'xserr' : rc, } except Exception, e: raise
def get_xspolicy(self): polstate = { 'xs_ref' : "", 'repr' : "", 'type' : 0, 'flags' : 0, 'version': "", 'errors' : "", 'xserr' : 0 } poladmin = XSPolicyAdminInstance() refs = poladmin.get_policies_refs() # Will return one or no policy if refs and len(refs) > 0: ref = refs[0] xspol = XSPolicyAdminInstance().policy_from_ref(ref) if xspol: polstate = { 'xs_ref' : ref, 'repr' : xspol.toxml(), 'type' : xspol.get_type(), 'flags' : poladmin.get_policy_flags(xspol), 'version': xspol.get_version(), 'errors' : "", 'xserr' : 0, } return polstate