'Creates a volume from a snapshot.'

@cinder_utils.trace
def create_volume_from_snapshot(self, volume, snapshot):

    client = self._login()
    try:
        snap_info = client.getSnapshotByName(snapshot['name'])
        volume_info = client.cloneSnapshot(volume['name'], snap_info['id'])
        if (volume['size'] > snapshot['volume_size']):
            LOG.debug('Resize    the    new    volume    to    %s.', volume['size'])
            self.extend_volume(volume, volume['size'])
        model_update = self._update_provider(volume_info)
        if (self._volume_of_replicated_type(volume) and self._do_volume_replication_setup(volume, client)):
            model_update['replication_status'] = 'enabled'
            model_update['replication_driver_data'] = json.dumps({'location': self._client_conf['hpelefthand_api_url']})
        return model_update
    except Exception as ex:
        raise exception.VolumeBackendAPIException(ex)
    finally:
        self._logout(client)
