Exemplo n.º 1
0
    def update(self, req, id, body):
        """Update a snapshot."""
        context = req.environ['cinder.context']
        snapshot_body = body['snapshot']
        self.validate_name_and_description(snapshot_body, check_length=False)

        if 'name' in snapshot_body:
            snapshot_body['display_name'] = snapshot_body.pop('name')

        if 'description' in snapshot_body:
            snapshot_body['display_description'] = snapshot_body.pop(
                'description')

        # Not found exception will be handled at the wsgi level
        snapshot = self.volume_api.get_snapshot(context, id)
        volume_utils.notify_about_snapshot_usage(context, snapshot,
                                                 'update.start')
        self.volume_api.update_snapshot(context, snapshot, snapshot_body)

        snapshot.update(snapshot_body)
        req.cache_db_snapshot(snapshot)
        volume_utils.notify_about_snapshot_usage(context, snapshot,
                                                 'update.end')

        return self._view_builder.detail(req, snapshot)
Exemplo n.º 2
0
    def update(self, req, id, body):
        """Update a snapshot."""
        context = req.environ['cinder.context']
        snapshot_body = body['snapshot']
        self.validate_name_and_description(snapshot_body, check_length=False)

        if 'name' in snapshot_body:
            snapshot_body['display_name'] = snapshot_body.pop('name')

        if 'description' in snapshot_body:
            snapshot_body['display_description'] = snapshot_body.pop(
                'description')

        # Not found exception will be handled at the wsgi level
        snapshot = self.volume_api.get_snapshot(context, id)
        volume_utils.notify_about_snapshot_usage(context, snapshot,
                                                 'update.start')
        self.volume_api.update_snapshot(context, snapshot, snapshot_body)

        snapshot.update(snapshot_body)
        req.cache_db_snapshot(snapshot)
        volume_utils.notify_about_snapshot_usage(context, snapshot,
                                                 'update.end')

        return self._view_builder.detail(req, snapshot)