예제 #1
0
    def test_snapshot_metadata_update_delete(self):
        metadata1 = {'a': '1', 'c': '2'}
        metadata2 = {'a': '3', 'd': '5'}
        should_be = metadata2

        db.volume_create(self.ctxt, {'id': 1})
        db.snapshot_create(self.ctxt,
                           {'id': 1, 'volume_id': 1, 'metadata': metadata1})
        db.snapshot_metadata_update(self.ctxt, 1, metadata2, True)

        self.assertEquals(should_be, db.snapshot_metadata_get(self.ctxt, 1))
예제 #2
0
파일: snapshot.py 프로젝트: C2python/cinder
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'volume' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('volume changed'))
            if 'cgsnapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cgsnapshot changed'))

            if 'cluster' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cluster changed'))

            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.snapshot_metadata_update(self._context,
                                                            self.id, metadata,
                                                            True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()
예제 #3
0
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'volume' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('volume changed'))
            if 'cgsnapshot' in updates:
                # NOTE(xyang): Allow this to pass if 'cgsnapshot' is
                # set to None. This is to support backward compatibility.
                if updates.get('cgsnapshot'):
                    raise exception.ObjectActionError(
                        action='save', reason=_('cgsnapshot changed'))
            if 'group_snapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('group_snapshot changed'))

            if 'cluster' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cluster changed'))

            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.snapshot_metadata_update(self._context,
                                                            self.id, metadata,
                                                            True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()
예제 #4
0
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'volume' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('volume changed'))
            if 'cgsnapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cgsnapshot changed'))
            if 'group_snapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('group_snapshot changed'))

            if 'cluster' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cluster changed'))

            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.snapshot_metadata_update(self._context,
                                                            self.id, metadata,
                                                            True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()
예제 #5
0
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'volume' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('volume changed'))
            if 'cgsnapshot' in updates:
                # NOTE(xyang): Allow this to pass if 'cgsnapshot' is
                # set to None. This is to support backward compatibility.
                if updates.get('cgsnapshot'):
                    raise exception.ObjectActionError(
                        action='save', reason=_('cgsnapshot changed'))
            if 'group_snapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('group_snapshot changed'))

            if 'cluster' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('cluster changed'))

            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.snapshot_metadata_update(
                    self._context, self.id, metadata, True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()
예제 #6
0
    def test_snapshot_metadata_update_delete(self):
        metadata1 = {"a": "1", "c": "2"}
        metadata2 = {"a": "3", "d": "5"}
        should_be = metadata2

        db.volume_create(self.ctxt, {"id": 1})
        db.snapshot_create(self.ctxt, {"id": 1, "volume_id": 1, "metadata": metadata1})
        db_meta = db.snapshot_metadata_update(self.ctxt, 1, metadata2, True)

        self.assertEqual(should_be, db_meta)
예제 #7
0
파일: test_db_api.py 프로젝트: afliu/cinder
    def test_snapshot_metadata_update(self):
        metadata1 = {'a': '1', 'c': '2'}
        metadata2 = {'a': '3', 'd': '5'}
        should_be = {'a': '3', 'c': '2', 'd': '5'}

        db.volume_create(self.ctxt, {'id': 1})
        db.snapshot_create(self.ctxt,
                           {'id': 1, 'volume_id': 1, 'metadata': metadata1})
        db_meta = db.snapshot_metadata_update(self.ctxt, 1, metadata2, False)

        self.assertEqual(should_be, db_meta)
예제 #8
0
    def test_snapshot_metadata_update(self):
        metadata1 = {'a': '1', 'c': '2'}
        metadata2 = {'a': '3', 'd': '5'}
        should_be = {'a': '3', 'c': '2', 'd': '5'}

        db.volume_create(self.ctxt, {'id': 1})
        db.snapshot_create(self.ctxt, {
            'id': 1,
            'volume_id': 1,
            'metadata': metadata1
        })
        db_meta = db.snapshot_metadata_update(self.ctxt, 1, metadata2, False)

        self.assertEqual(should_be, db_meta)
예제 #9
0
    def save(self):
        updates = self.obj_get_changes()
        if updates:
            if "volume" in updates:
                raise exception.ObjectActionError(action="save", reason=_("volume changed"))

            if "metadata" in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop("metadata", None)
                self.metadata = db.snapshot_metadata_update(self._context, self.id, metadata, True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()