'Gets or creates a host with given port id.'

def _get_host_with_matching_port(self, port_ids):

    port_ids = [six.text_type(wwpn).replace(':', '') for wwpn in port_ids]
    hosts = self._client.list_hosts()
    for port_id in port_ids:
        for host in hosts:
            if host.get('hostSidePorts'):
                ports = host.get('hostSidePorts')
                for port in ports:
                    address = port.get('address').upper().replace(':', '')
                    if (address == port_id.upper()):
                        return host
    msg = _('Host    with    ports    %(ports)s    not    found.')
    raise exception.NotFound((msg % {'ports': port_ids}))
