'Creates a volume from a snapshot - clone a snapshot.'

def create_volume_from_snapshot(self, volume, snapshot):

    LOG.debug('zfssa.create_volume_from_snapshot:    volume=%s', volume['name'])
    LOG.debug('zfssa.create_volume_from_snapshot:    snapshot=%s', snapshot['name'])
    lcfg = self.configuration
    parent_lun = self.zfssa.get_lun(lcfg.zfssa_pool, lcfg.zfssa_project, snapshot['volume_name'])
    parent_size = parent_lun['size']
    child_size = (volume['size'] * units.Gi)
    if (child_size < parent_size):
        exception_msg = (_('Error    clone    [%(clone_id)s]    size    [%(clone_size)d]    cannot    be    smaller    than    parent    volume    [%(parent_id)s]    size    [%(parent_size)d]') % {'parent_id': snapshot['volume_name'], 'parent_size': (parent_size / units.Gi), 'clone_id': volume['name'], 'clone_size': volume['size']})
        LOG.error(exception_msg)
        raise exception.InvalidInput(reason=exception_msg)
    specs = self._get_voltype_specs(volume)
    specs.update({'custom:cinder_managed': True})
    self.zfssa.clone_snapshot(lcfg.zfssa_pool, lcfg.zfssa_project, snapshot['volume_name'], snapshot['name'], lcfg.zfssa_project, volume['name'], specs)
    if (child_size > parent_size):
        LOG.debug('zfssa.create_volume_from_snapshot:        Parent    size    [%(parent_size)d],    Child    size    [%(child_size)d]    -    resizing', {'parent_size': parent_size, 'child_size': child_size})
        self.zfssa.set_lun_props(lcfg.zfssa_pool, lcfg.zfssa_project, volume['name'], volsize=child_size)
