Add Copy Offload support for Glance Image Cache to netapp unified driver

Registered by Takeshi.K

I know that a copy offload does not run when I use a glance image cache directory (image_cache_dir) for a filesystem.
I would like to propose to support it.

I tried to edit nfs.py and add one metadata to metadata.json.
It appeared that it works good.
If some glance image has already been prefetched to a cache directory from the glance repository and the cached directory exists on flex volume of clustered Data ONTAP, the netapp driver can do copy from a cached to cinder volume by using the copy offload.

Edit nfs.py

# diff -c orig_nfs.py nfs.py
*** orig_nfs.py 2014-10-03 09:59:56.200632632 +0900
--- nfs.py 2014-10-07 13:12:28.673414532 +0900
***************
*** 1199,1210 ****
--- 1199,1219 ----
          (vserver, exp_volume) = self._get_vserver_and_exp_vol(share=share)
          self._clone_file(exp_volume, src_name, dst_name, vserver,
                           dest_exists=dest_exists)
+ def _get_img_cache(self, image_location):
+ direct_url, locations = image_location
+ if not direct_url and not locations:
+ raise exception.NotFound(_('Image location not present.'))
+ location = locations[0]
+ location_cache_path = location['metadata'].get('cache_path')
+ return (location_cache_path)

      def _copy_from_img_service(self, context, volume, image_service,
                                 image_id):
          """Copies from the image service using copy offload."""
          LOG.debug(_("Trying copy from image service using copy offload."))
          image_loc = image_service.get_location(context, image_id)
+ img_cache_path = self._get_img_cache(image_loc)
+ LOG.debug(_("Image Cache Path %s"), img_cache_path)
          image_loc = self._construct_image_nfs_url(image_loc)
          conn, dr = self._check_get_nfs_path_segs(image_loc)
          if conn:
***************
*** 1212,1218 ****
          else:
              raise exception.NotFound(_("Source host details not found."))
          (__, ___, img_file) = image_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 file is required to deal with img formats
--- 1221,1230 ----
          else:
              raise exception.NotFound(_("Source host details not found."))
          (__, ___, img_file) = image_loc.rpartition('/')
! if img_cache_path:
! src_path = os.path.join(img_cache_path, img_file)
! else:
! src_path = os.path.join(dr, img_file)
          dst_ip = self._get_ip_verify_on_cluster(self._get_host_ip(
              volume['id']))
          # tmp file is required to deal with img formats

for example : glance-api.conf
filesystem_store_datadir = /var/lib/glance/images
show_image_direct_url = True
show_multiple_locations = True
filesystem_store_metadata_file = /etc/glance/metadata.json

for example : metadata.json
{
        "share_location": "nfs://192.168.30.20/images",
        "mount_point": "/var/lib/glance/images",
        "type": "nfs",
   "cache_path": "/cache_vol"
}

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
Takeshi.K
Direction:
Needs approval
Assignee:
Bob Callaway
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Sean McGinnis

Related branches

Sprints

Whiteboard

(smcginnis): Marking obsolete as this has been sitting out there for a long time. If this is still needed, please submit a new bp.

None

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.