def get_parents(ns, obj, deep=False):
    obj = str2obj(ns, obj)
    if deep:
        # use loop of get_parents(ns, xxx, deep=False)
        known_parents = set()
        todo = [obj, ]  # a TO-DO list
        while todo:
            obj = todo.pop()
            new_parents = get_parents(ns, obj, False)
            for parent in new_parents:
                if "DeviceID" in parent.properties():
                    devid = parent.DeviceID
                else:
                    devid = parent.InstanceID
                if devid not in known_parents:
                    known_parents.add(devid)
                    todo.append(parent)
                    yield parent
        return

    # only direct parents requested
    if lmi_isinstance(obj, ns.CIM_StorageExtent):
        # Try to get parent VG first
        parents = obj.associators(
                AssocClass="LMI_LVAllocatedFromStoragePool",
                Role="Dependent")
        if parents:
            for parent in parents:
                yield parent
            return
        # Try usual BasedOn next
        parents = obj.associators(AssocClass="CIM_BasedOn", Role="Dependent")
        for parent in parents:
            # Be careful with logical partitions - they are BasedOn extended
            # partition, but we want to return appropriate disk instead.
            logical = ns.LMI_DiskPartition.PartitionTypeValues.Logical
            extended = ns.LMI_DiskPartition.PartitionTypeValues.Extended
            if (lmi_isinstance(parent, ns.CIM_DiskPartition)
                    and lmi_isinstance(obj, ns.CIM_DiskPartition)
                    and obj.PartitionType == logical
                    and parent.PartitionType == extended):
                LOG().debug("Looking for disk instead of extended partition %s"
                        % (parent.DeviceID))
                for p in get_parents(ns, parent, False):
                    yield p
            else:
                # It is not logical partition
                yield parent

    elif lmi_isinstance(obj, ns.CIM_StoragePool):
        # find VGs of the thin pool
        assoc_class = "LMI_VGAllocatedFromStoragePool"
        if assoc_class in ns.classes():
            parents = obj.associators(
                    AssocClass=assoc_class,
                    Role="Dependent")
            for parent in parents:
                yield parent

        # find physical volumes of the VG
        parents = obj.associators(
                AssocClass="LMI_VGAssociatedComponentExtent",
                Role="GroupComponent")
        for parent in parents:
            yield parent

    else:
        raise LmiFailed("CIM_StorageExtent or LMI_VGStragePool expected: %s",
            obj.classname)
Return list of all parents of given LMIInstance.
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/storage/lmi/scripts/storage/common.py/get_parents