Beispiel #1
0
 def test_destroy_volume_mapping_by_uuid(self, mock_delete, mock_write,
                                         mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     volume_mapping = utils.create_test_volume_mapping(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(volume_mapping.
                                                          as_dict())
     dbapi.destroy_volume_mapping(self.context, volume_mapping.uuid)
     mock_delete.assert_called_once_with('/volume_mappings/%s' %
                                         volume_mapping.uuid)
Beispiel #2
0
    def destroy(self, context=None):
        """Delete the VolumeMapping from the DB.

        :param context: Security context. NOTE: This should only
                        be used internally by the indirection_api.
                        Unfortunately, RPC requires context as the first
                        argument, even though we don't use it.
                        A context should be set when instantiating the
                        object.
        """
        if not self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='already destroyed')
        dbapi.destroy_volume_mapping(context, self.uuid)
        delattr(self, 'id')
        self.obj_reset_changes()
Beispiel #3
0
    def destroy(self, context=None):
        """Delete the VolumeMapping from the DB.

        :param context: Security context. NOTE: This should only
                        be used internally by the indirection_api.
                        Unfortunately, RPC requires context as the first
                        argument, even though we don't use it.
                        A context should be set when instantiating the
                        object.
        """
        context = context or self._context
        if not self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='already destroyed')
        dbapi.destroy_volume_mapping(context, self.uuid)
        self._destroy_volume(context)
        delattr(self, 'id')
        self.obj_reset_changes()
Beispiel #4
0
 def test_destroy_volume_mapping_by_uuid(self):
     volume_mapping = utils.create_test_volume_mapping(context=self.context)
     dbapi.destroy_volume_mapping(self.context, volume_mapping.uuid)
     self.assertRaises(exception.VolumeMappingNotFound,
                       dbapi.get_volume_mapping_by_uuid, self.context,
                       volume_mapping.uuid)
 def test_destroy_volume_mapping_by_uuid(self):
     volume_mapping = utils.create_test_volume_mapping(context=self.context)
     dbapi.destroy_volume_mapping(self.context, volume_mapping.uuid)
     self.assertRaises(exception.VolumeMappingNotFound,
                       dbapi.get_volume_mapping_by_uuid,
                       self.context, volume_mapping.uuid)