'Create volume from snapshot internal implementation.
used for regular snapshot and cgsnapshot'

def _create_volume_from_snapshot(self, volume, snapshot_name, snapshot_size):

    LOG.debug('_create_volume_from_snapshot:    %(volume)s    from    %(name)s', {'volume': volume['name'], 'name': snapshot_name})
    volume_size = float(volume['size'])
    if (volume_size < snapshot_size):
        error = (_('Volume    size    (%(vol_size)sGB)    cannot    be    smaller    than    the    snapshot    size    (%(snap_size)sGB)..') % {'vol_size': volume_size, 'snap_size': snapshot_size})
        LOG.error(error)
        raise self._get_exception()(error)
    self.create_volume(volume)
    try:
        self._call_xiv_xcli('vol_copy', vol_src=snapshot_name, vol_trg=volume['name'])
    except errors.XCLIError as e:
        error = (_('Fatal    error    in    copying    volume:    %(details)s') % {'details': self._get_code_and_status_or_message(e)})
        LOG.error(error)
        self._silent_delete_volume(volume)
        raise self._get_exception()(error)
    if (snapshot_size == volume_size):
        return
    size = storage.gigabytes_to_blocks(volume_size)
    try:
        self._call_xiv_xcli('vol_resize', vol=volume['name'], size_blocks=size)
    except errors.XCLIError as e:
        error = (_('Fatal    error    in    resize    volume:    %(details)s') % {'details': self._get_code_and_status_or_message(e)})
        LOG.error(error)
        self._silent_delete_volume(volume)
        raise self._get_exception()(error)
