'Test snapshot in use can be created forcibly.'

def test_create_snapshot_force(self):

    instance_uuid = '12345678-1234-5678-1234-567812345678'
    volume = tests_utils.create_volume(self.context, **self.volume_params)
    self.volume.create_volume(self.context, volume)
    values = {'volume_id': volume['id'], 'instance_uuid': instance_uuid, 'attach_status': fields.VolumeAttachStatus.ATTACHING}
    attachment = db.volume_attach(self.context, values)
    db.volume_attached(self.context, attachment['id'], instance_uuid, None, '/dev/sda1')
    volume_api = cinder.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')
    snapshot_ref.destroy()
    db.volume_destroy(self.context, volume['id'])
    volume = tests_utils.create_volume(self.context, **self.volume_params)
    self.volume.create_volume(self.context, volume)
    values = {'volume_id': volume['id'], 'attached_host': 'fake_host', 'attach_status': fields.VolumeAttachStatus.ATTACHING}
    attachment = db.volume_attach(self.context, values)
    db.volume_attached(self.context, attachment['id'], None, 'fake_host', '/dev/sda1')
    volume_api = cinder.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')
    snapshot_ref.destroy()
    db.volume_destroy(self.context, volume['id'])
