예제 #1
0
    def test_create_snapshot_force(self):
        """Test snapshot in use can be created forcibly."""
        def fake_cast(ctxt, topic, msg):
            pass

        self.stubs.Set(rpc, 'cast', fake_cast)

        volume_id = self._create_volume()
        self.volume.create_volume(self.context, volume_id)
        db.volume_attached(self.context, volume_id, self.instance_id,
                           '/dev/sda1')

        volume_api = volume.api.API()
        self.assertRaises(exception.ApiError, volume_api.create_snapshot,
                          self.context, volume_id, 'fake_name',
                          'fake_description')
        snapshot_ref = volume_api.create_snapshot_force(
            self.context, volume_id, 'fake_name', 'fake_description')
        db.snapshot_destroy(self.context, snapshot_ref['id'])
        db.volume_destroy(self.context, volume_id)
예제 #2
0
    def test_create_snapshot_force(self):
        """Test snapshot in use can be created forcibly."""

        def fake_cast(ctxt, topic, msg):
            pass

        self.stubs.Set(rpc, "cast", fake_cast)

        volume = self._create_volume()
        self.volume.create_volume(self.context, volume["id"])
        db.volume_attached(self.context, volume["id"], self.instance_uuid, "/dev/sda1")

        volume_api = nova.volume.api.API()
        volume = volume_api.get(self.context, volume["id"])
        self.assertRaises(
            exception.InvalidVolume, volume_api.create_snapshot, self.context, volume, "fake_name", "fake_description"
        )
        snapshot_ref = volume_api.create_snapshot_force(self.context, volume, "fake_name", "fake_description")
        db.snapshot_destroy(self.context, snapshot_ref["id"])
        db.volume_destroy(self.context, volume["id"])
예제 #3
0
    def test_create_snapshot_force(self):
        """Test snapshot in use can be created forcibly."""

        def fake_cast(ctxt, topic, msg):
            pass
        self.stubs.Set(rpc, 'cast', fake_cast)

        volume_id = self._create_volume()
        self.volume.create_volume(self.context, volume_id)
        db.volume_attached(self.context, volume_id, self.instance_id,
                           '/dev/sda1')

        volume_api = volume.api.API()
        self.assertRaises(exception.ApiError,
                          volume_api.create_snapshot,
                          self.context, volume_id,
                          'fake_name', 'fake_description')
        snapshot_ref = volume_api.create_snapshot_force(self.context,
                                                        volume_id,
                                                        'fake_name',
                                                        'fake_description')
        db.snapshot_destroy(self.context, snapshot_ref['id'])
        db.volume_destroy(self.context, volume_id)