Coverage for nova/virt/libvirt/event.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12import typing as ty 

13 

14from nova.virt import event 

15 

16 

17class LibvirtEvent(event.InstanceEvent): 

18 """Base class for virt events that are specific to libvirt and therefore 

19 handled in the libvirt driver level instead of propagatig it up to the 

20 compute manager. 

21 """ 

22 

23 

24class DeviceEvent(LibvirtEvent): 

25 """Base class for device related libvirt events""" 

26 

27 def __init__(self, 

28 uuid: str, 

29 dev: str, 

30 timestamp: ty.Optional[float] = None): 

31 super().__init__(uuid, timestamp) 

32 self.dev = dev 

33 

34 def __repr__(self) -> str: 

35 return "<%s: %s, %s => %s>" % ( 

36 self.__class__.__name__, 

37 self.timestamp, 

38 self.uuid, 

39 self.dev) 

40 

41 

42class DeviceRemovedEvent(DeviceEvent): 

43 """Libvirt sends this event after a successful device detach""" 

44 

45 

46class DeviceRemovalFailedEvent(DeviceEvent): 

47 """Libvirt sends this event after an unsuccessful device detach"""