'Find mapped ports, memorize them and return unmapped port count.'

def find_targets_from_storage(self, targets, connector, target_ports):

    nr_not_found = 0
    target_name = (utils.TARGET_PREFIX + connector['ip'])
    success_code = horcm.HORCM_EXIT_CODE.union([horcm.EX_ENOOBJ])
    iqn = self.get_hba_ids_from_connector(connector)
    iqn_pattern = re.compile(('^CL\\w-\\w+    +\\d+    +\\S+    +%s    ' % iqn), re.M)
    for port in target_ports:
        targets['info'][port] = False
        result = self.run_raidcom('get', 'hba_iscsi', '-port', port, target_name, success_code=success_code)
        if iqn_pattern.search(result[1]):
            gid = result[1].splitlines()[1].split()[1]
            targets['info'][port] = True
            targets['list'].append((port, gid))
            continue
        result = self.run_raidcom('get', 'host_grp', '-port', port)
        for (gid, iqn) in _ISCSI_TARGETS_PATTERN.findall(result[1]):
            result = self.run_raidcom('get', 'hba_iscsi', '-port', '-'.join([port, gid]))
            if iqn_pattern.search(result[1]):
                targets['info'][port] = True
                targets['list'].append((port, gid))
                targets['iqns'][(port, gid)] = iqn
                break
        else:
            nr_not_found += 1
    return nr_not_found
