def set_state(ns, new_state, default):
    service = get_service(ns)

    try:
        (rval, _, errorstr) = service.SyncSetSELinuxState(
            NewState=proc_state(new_state),
            MakeDefault=default,
        )
    except LMIExceptions.CIMError as err:
        msg = 'Failed to set SELinux state'
        if err[1]:
            msg += err[1][err[1].index(':'):]
        raise LmiFailed(msg)
    else:
        if default:
            LOG().info('SELinux default state changed to "%s".',
                state2str(proc_state(new_state)))
        else:
            LOG().info('SELinux state changed to "%s".',
                state2str(proc_state(new_state)))
Set SELinux state.
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/selinux/lmi/scripts/selinux/__init__.py/set_state