'Import all volume backup metadata details to the backup db.
:param context: running context
:param backup: The new backup object for the import
:param backup_service: The needed backup driver for import
:param backup_url: An identifier string to locate the backup
:param backup_hosts: Potential hosts to execute the import
:raises InvalidBackup:
:raises ServiceNotFound:'

def import_record(self, context, backup, backup_service, backup_url, backup_hosts):

    LOG.info('Import    record    started,    backup_url:    %s.', backup_url)
    if (backup_service != self.driver_name):
        if (len(backup_hosts) > 0):
            first_host = backup_hosts.pop()
            self.backup_rpcapi.import_record(context, first_host, backup, backup_service, backup_url, backup_hosts)
        else:
            err = (_('Import    record    failed,    cannot    find    backup    service    to    perform    the    import.    Request    service    %(service)s.') % {'service': backup_service})
            self._update_backup_error(backup, err)
            raise exception.ServiceNotFound(service_id=backup_service)
    else:
        try:
            backup_options = backup.decode_record(backup_url)
            driver_options = backup_options.pop('driver_info', {})
            backup_service = self.service.get_backup_driver(context)
            backup_service.import_record(backup, driver_options)
        except Exception as err:
            msg = six.text_type(err)
            self._update_backup_error(backup, msg)
            raise exception.InvalidBackup(reason=msg)
        required_import_options = {'display_name', 'display_description', 'container', 'size', 'service_metadata', 'object_count', 'id'}
        missing_opts = (required_import_options - set(backup_options))
        if missing_opts:
            msg = (_('Driver    successfully    decoded    imported    backup    data,    but    there    are    missing    fields    (%s).') % ',    '.join(missing_opts))
            self._update_backup_error(backup, msg)
            raise exception.InvalidBackup(reason=msg)
        backup_id = backup_options['id']
        if (backup_id != backup.id):
            msg = (_('Trying    to    import    backup    metadata    from    id    %(meta_id)s    into    backup    %(id)s.') % {'meta_id': backup_id, 'id': backup.id})
            self._update_backup_error(backup, msg)
            raise exception.InvalidBackup(reason=msg)
        backup_options['service'] = self.driver_name
        backup_options['availability_zone'] = self.az
        backup_options['host'] = self.host
        for key in ('name', 'user_id', 'project_id', 'deleted_at', 'deleted', 'fail_reason', 'status'):
            backup_options.pop(key, None)
        backup.update(backup_options)
        backup.save()
        try:
            if isinstance(backup_service, driver.BackupDriverWithVerify):
                backup_service.verify(backup.id)
            else:
                LOG.warning('Backup    service    %(service)s    does    not    support    verify.    Backup    id    %(id)s    is    not    verified.    Skipping    verify.', {'service': self.driver_name, 'id': backup.id})
        except exception.InvalidBackup as err:
            with excutils.save_and_reraise_exception():
                self._update_backup_error(backup, six.text_type(err))
        backup.update({'status': fields.BackupStatus.AVAILABLE})
        backup.save()
        LOG.info('Import    record    id    %s    metadata    from    driver    finished.', backup.id)
