Coverage for drivers/vditype.py : 100%
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/>.
17from sm_typing import Final
19# TODO: Use StrEnum in python 3.11.
20class VdiType(object):
21 RAW = "aio"
22 VHD = "vhd"
23 QCOW2 = "qcow2"
24 ISO = "iso"
25 FILE = "file"
26 CBTLOG = "cbtlog"
28 @classmethod
29 def isCowImage(cls, vdi_type) -> bool:
30 return vdi_type in VDI_COW_TYPES
32# TODO: Use StrEnum in python 3.11.
33class VdiTypeExtension(object):
34 RAW = ".raw"
35 VHD = ".vhd"
36 QCOW2 = ".qcow2"
37 ISO = ".iso"
38 FILE = ".file"
39 CBTLOG = ".cbtlog"
41VDI_COW_TYPES: Final = (VdiType.VHD, VdiType.QCOW2)
43VDI_TYPE_TO_EXTENSION: Final = {
44 VdiType.RAW: VdiTypeExtension.RAW,
45 VdiType.VHD: VdiTypeExtension.VHD,
46 VdiType.QCOW2: VdiTypeExtension.QCOW2,
47 VdiType.ISO: VdiTypeExtension.ISO,
48 VdiType.FILE: VdiTypeExtension.FILE,
49 VdiType.CBTLOG: VdiTypeExtension.CBTLOG
50}