Exemplo n.º 1
0
    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