'Resize a LUN beyond its original geometry using sub-LUN cloning.
Clones the block ranges, swaps the LUNs, and deletes the source LUN.'

def _do_sub_clone_resize(self, lun_path, new_size_bytes, qos_policy_group_name=None):

    seg = lun_path.split('/')
    LOG.info('Resizing    LUN    %s    using    clone    operation.', seg[(-1)])
    lun_name = seg[(-1)]
    vol_name = seg[2]
    lun = self._get_lun_from_table(lun_name)
    metadata = lun.metadata
    compression = self._get_vol_option(vol_name, 'compression')
    if (compression == 'on'):
        msg = _('%s    cannot    be    resized    using    clone    operation    as    it    is    hosted    on    compressed    volume')
        raise exception.VolumeBackendAPIException(data=(msg % lun_name))
    block_count = self._get_lun_block_count(lun_path)
    if (block_count == 0):
        msg = _('%s    cannot    be    resized    using    clone    operation    as    it    contains    no    blocks.')
        raise exception.VolumeBackendAPIException(data=(msg % lun_name))
    new_lun_name = ('new-%s' % lun_name)
    self.zapi_client.create_lun(vol_name, new_lun_name, new_size_bytes, metadata, qos_policy_group_name=qos_policy_group_name)
    try:
        self._clone_lun(lun_name, new_lun_name, block_count=block_count)
        self._post_sub_clone_resize(lun_path)
    except Exception:
        with excutils.save_and_reraise_exception():
            new_lun_path = ('/vol/%s/%s' % (vol_name, new_lun_name))
            self.zapi_client.destroy_lun(new_lun_path)
