Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python3 

2# 

3# Copyright (C) 2024 Vates SAS 

4# 

5# This program is free software: you can redistribute it and/or modify 

6# it under the terms of the GNU General Public License as published by 

7# the Free Software Foundation, either version 3 of the License, or 

8# (at your option) any later version. 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU General Public License for more details. 

13# 

14# You should have received a copy of the GNU General Public License 

15# along with this program. If not, see <https://www.gnu.org/licenses/>. 

16 

17from sm_typing import Final 

18 

19# TODO: Use StrEnum in python 3.11. 

20class VdiType(object): 

21 RAW = "aio" 

22 PHY = "phy" 

23 VHD = "vhd" 

24 QCOW2 = "qcow2" 

25 ISO = "iso" 

26 FILE = "file" 

27 CBTLOG = "cbtlog" 

28 

29 @classmethod 

30 def isCowImage(cls, vdi_type) -> bool: 

31 return vdi_type in VDI_COW_TYPES 

32 

33# TODO: Use StrEnum in python 3.11. 

34class VdiTypeExtension(object): 

35 RAW = ".raw" 

36 VHD = ".vhd" 

37 QCOW2 = ".qcow2" 

38 ISO = ".iso" 

39 FILE = ".file" 

40 CBTLOG = ".cbtlog" 

41 

42VDI_COW_TYPES: Final = (VdiType.VHD, VdiType.QCOW2) 

43 

44VDI_TYPE_TO_EXTENSION: Final = { 

45 VdiType.RAW: VdiTypeExtension.RAW, 

46 VdiType.VHD: VdiTypeExtension.VHD, 

47 VdiType.QCOW2: VdiTypeExtension.QCOW2, 

48 VdiType.ISO: VdiTypeExtension.ISO, 

49 VdiType.FILE: VdiTypeExtension.FILE, 

50 VdiType.CBTLOG: VdiTypeExtension.CBTLOG 

51}