'Uses cached image as parent of a COW child in the VM directory.'

def _use_disk_image_as_linked_clone(self, vm_ref, vi):

    sized_image_disk_name = ('%s.vmdk' % vi.ii.image_id)
    if (vi.root_gb > 0):
        sized_image_disk_name = ('%s.%s.vmdk' % (vi.ii.image_id, vi.root_gb))
    sized_disk_ds_loc = vi.cache_image_folder.join(sized_image_disk_name)
    with lockutils.lock(str(sized_disk_ds_loc), lock_file_prefix='nova-vmware-image'):
        if (not self._sized_image_exists(sized_disk_ds_loc, vi.datastore.ref)):
            LOG.debug('Copying    root    disk    of    size    %sGb', vi.root_gb, instance=vi.instance)
            try:
                vm_util.copy_virtual_disk(self._session, vi.dc_info.ref, str(vi.cache_image_path), str(sized_disk_ds_loc))
            except Exception as e:
                LOG.warning('Root    disk    file    creation    failed    -    %s', e, instance=vi.instance)
                with excutils.save_and_reraise_exception():
                    LOG.error('Failed    to    copy    cached    image    %(source)s    to    %(dest)s    for    resize:    %(error)s', {'source': vi.cache_image_path, 'dest': sized_disk_ds_loc, 'error': e}, instance=vi.instance)
                    try:
                        ds_util.file_delete(self._session, sized_disk_ds_loc, vi.dc_info.ref)
                    except vexc.FileNotFoundException:
                        pass
            self._extend_if_required(vi.dc_info, vi.ii, vi.instance, str(sized_disk_ds_loc))
    self._volumeops.attach_disk_to_vm(vm_ref, vi.instance, vi.ii.adapter_type, vi.ii.disk_type, str(sized_disk_ds_loc), (vi.root_gb * units.Mi), vi.ii.linked_clone, disk_io_limits=vi._extra_specs.disk_io_limits)
