'Reference count check for end devices.
Looks up the reference count for each initiator-target pair from the
map and returns a filtered list based on the operation type
add_control - operation type can be true for add connection control
and false for remove connection control'

def get_valid_initiator_target_map(self, initiator_target_map, add_control):

    filtered_i_t_map = {}
    for initiator in initiator_target_map.keys():
        t_list = initiator_target_map[initiator]
        for target in t_list:
            count = self.get_zoning_state_ref_count(initiator, target)
            if add_control:
                if (count > 0):
                    t_list.remove(target)
            elif (count > 1):
                t_list.remove(target)
        if t_list:
            filtered_i_t_map[initiator] = t_list
        else:
            LOG.info('No    targets    to    add    or    remove    connection    for    initiator:    %(init_wwn)s', {'init_wwn': initiator})
    return filtered_i_t_map
