def list_elements(ns, kind):
    try:
        for element in sorted(ns.LMI_SELinuxElement.instances(client_filtering=True),
                key=lambda i: i.ElementName):
            if kind == 'booleans' and "SELinuxBoolean" not in element.InstanceID:
                continue
            if kind == 'ports' and "SELinuxPort" not in element.InstanceID:
                continue
            yield element
    except LMIExceptions.CIMError as err:
        if err.args[0] == wbem.CIM_ERR_NOT_SUPPORTED:
            raise LmiFailed('Service provider is not installed or registered.')
        raise LmiFailed('Failed to list services: %s' % err.args[1])
List SELinux elements (booleans and ports).
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/selinux/lmi/scripts/selinux/__init__.py/list_elements