'Copies from the image service using copy offload.'

def _copy_from_img_service(self, context, volume, image_service, image_id):

    LOG.debug('Trying    copy    from    image    service    using    copy    offload.')
    image_loc = image_service.get_location(context, image_id)
    locations = self._construct_image_nfs_url(image_loc)
    src_ip = None
    selected_loc = None
    for location in locations:
        (conn, dr) = self._check_get_nfs_path_segs(location)
        if conn:
            try:
                src_ip = self._get_ip_verify_on_cluster(conn.split(':')[0])
                selected_loc = location
                break
            except exception.NotFound:
                pass
    if (src_ip is None):
        raise exception.NotFound(_('Source    host    details    not    found.'))
    (__, ___, img_file) = selected_loc.rpartition('/')
    src_path = os.path.join(dr, img_file)
    dst_ip = self._get_ip_verify_on_cluster(self._get_host_ip(volume['id']))
    tmp_img_file = six.text_type(uuid.uuid4())
    col_path = self.configuration.netapp_copyoffload_tool_path
    img_info = image_service.show(context, image_id)
    dst_share = self._get_provider_location(volume['id'])
    self._check_share_can_hold_size(dst_share, img_info['size'])
    run_as_root = self._execute_as_root
    dst_dir = self._get_mount_point_for_share(dst_share)
    dst_img_local = os.path.join(dst_dir, tmp_img_file)
    try:
        if (('%s:%s' % (src_ip, dr)) != ('%s:%s' % (dst_ip, self._get_export_path(volume['id'])))):
            dst_img_serv_path = os.path.join(self._get_export_path(volume['id']), tmp_img_file)
            self._execute(col_path, src_ip, dst_ip, src_path, dst_img_serv_path, run_as_root=False, check_exit_code=0)
        else:
            self._clone_file_dst_exists(dst_share, img_file, tmp_img_file)
        self._discover_file_till_timeout(dst_img_local, timeout=120)
        LOG.debug('Copied    image    %(img)s    to    tmp    file    %(tmp)s.', {'img': image_id, 'tmp': tmp_img_file})
        dst_img_cache_local = os.path.join(dst_dir, ('img-cache-%s' % image_id))
        if (img_info['disk_format'] == 'raw'):
            LOG.debug('Image    is    raw    %s.', image_id)
            self._clone_file_dst_exists(dst_share, tmp_img_file, volume['name'], dest_exists=True)
            self._move_nfs_file(dst_img_local, dst_img_cache_local)
            LOG.debug('Copied    raw    image    %(img)s    to    volume    %(vol)s.', {'img': image_id, 'vol': volume['id']})
        else:
            LOG.debug('Image    will    be    converted    to    raw    %s.', image_id)
            img_conv = six.text_type(uuid.uuid4())
            dst_img_conv_local = os.path.join(dst_dir, img_conv)
            self._check_share_can_hold_size(dst_share, img_info['size'])
            try:
                image_utils.convert_image(dst_img_local, dst_img_conv_local, 'raw', run_as_root=run_as_root)
                data = image_utils.qemu_img_info(dst_img_conv_local, run_as_root=run_as_root)
                if (data.file_format != 'raw'):
                    raise exception.InvalidResults((_('Converted    to    raw,    but    format    is    now    %s.') % data.file_format))
                else:
                    self._clone_file_dst_exists(dst_share, img_conv, volume['name'], dest_exists=True)
                    self._move_nfs_file(dst_img_conv_local, dst_img_cache_local)
                    LOG.debug('Copied    locally    converted    raw    image    %(img)s    to    volume    %(vol)s.', {'img': image_id, 'vol': volume['id']})
            finally:
                if os.path.exists(dst_img_conv_local):
                    self._delete_file_at_path(dst_img_conv_local)
        self._post_clone_image(volume)
    finally:
        if os.path.exists(dst_img_local):
            self._delete_file_at_path(dst_img_local)
