'Fetch or create a host by given port.'

def _get_or_create_host(self, port_ids, host_type):

    try:
        host = self._get_host_with_matching_port(port_ids)
        ht_def = self._get_host_type_definition(host_type)
        if (host.get('hostTypeIndex') != ht_def.get('index')):
            try:
                host = self._client.update_host_type(host['hostRef'], ht_def)
            except exception.NetAppDriverException as e:
                LOG.warning('Unable    to    update    host    type    for    host    with    label    %(l)s.    %(e)s', {'l': host['label'], 'e': e.msg})
        return host
    except exception.NotFound as e:
        LOG.warning('Message    -    %s.', e.msg)
        return self._create_host(port_ids, host_type)
