diff --git a/subiquity/common/types.py b/subiquity/common/types.py index 31cc981f..0ffe7f5a 100644 --- a/subiquity/common/types.py +++ b/subiquity/common/types.py @@ -26,8 +26,6 @@ import attr from subiquitycore.models.network import NetDevInfo -from subiquity.common.serialize import named_field - class ErrorReportState(enum.Enum): INCOMPLETE = enum.auto() @@ -339,36 +337,6 @@ class GuidedChoice: password: Optional[str] = attr.ib(default=None, repr=False) -class StorageEncryptionSupport(enum.Enum): - DISABLED = 'disabled' - AVAILABLE = 'available' - UNAVAILABLE = 'unavailable' - DEFECTIVE = 'defective' - - -class StorageSafety(enum.Enum): - UNSET = 'unset' - ENCRYPTED = 'encrypted' - PREFER_ENCRYPTED = 'prefer-encrypted' - PREFER_UNENCRYPTED = 'prefer-unencrypted' - - -class EncryptionType(enum.Enum): - NONE = '' - CRYPTSETUP = 'cryptsetup' - DEVICE_SETUP_HOOK = 'device-setup-hook' - - -@attr.s(auto_attribs=True) -class StorageEncryption: - support: StorageEncryptionSupport - storage_safety: StorageSafety = named_field('storage-safety') - encryption_type: EncryptionType = named_field( - 'encryption-type', default=EncryptionType.NONE) - unavailable_reason: str = named_field( - 'unavailable-reason', default='') - - @attr.s(auto_attribs=True) class GuidedStorageResponse: status: ProbeStatus diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index 100316aa..289fc855 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -70,11 +70,8 @@ from subiquity.common.types import ( ModifyPartitionV2, ProbeStatus, ReformatDisk, - StorageEncryption, - StorageEncryptionSupport, StorageResponse, StorageResponseV2, - StorageSafety, ) from subiquity.models.filesystem import ( ActionRenderMode, @@ -91,6 +88,11 @@ from subiquity.server.controller import ( ) from subiquity.server import snapdapi from subiquity.server.mounter import Mounter +from subiquity.server.snapdapi import ( + StorageEncryption, + StorageEncryptionSupport, + StorageSafety, + ) from subiquity.server.types import InstallerChannels diff --git a/subiquity/server/snapdapi.py b/subiquity/server/snapdapi.py index b44ab0ca..1eb421b1 100644 --- a/subiquity/server/snapdapi.py +++ b/subiquity/server/snapdapi.py @@ -23,7 +23,7 @@ from typing import Dict, List, Optional from subiquity.common.api.client import make_client from subiquity.common.api.defs import api, path_parameter, Payload from subiquity.common.serialize import named_field, Serializer -from subiquity.common.types import Change, StorageEncryption, TaskStatus +from subiquity.common.types import Change, TaskStatus import attr @@ -178,6 +178,36 @@ class OnVolume(Volume): return cls(**kw) +class StorageEncryptionSupport(enum.Enum): + DISABLED = 'disabled' + AVAILABLE = 'available' + UNAVAILABLE = 'unavailable' + DEFECTIVE = 'defective' + + +class StorageSafety(enum.Enum): + UNSET = 'unset' + ENCRYPTED = 'encrypted' + PREFER_ENCRYPTED = 'prefer-encrypted' + PREFER_UNENCRYPTED = 'prefer-unencrypted' + + +class EncryptionType(enum.Enum): + NONE = '' + CRYPTSETUP = 'cryptsetup' + DEVICE_SETUP_HOOK = 'device-setup-hook' + + +@attr.s(auto_attribs=True) +class StorageEncryption: + support: StorageEncryptionSupport + storage_safety: StorageSafety = named_field('storage-safety') + encryption_type: EncryptionType = named_field( + 'encryption-type', default=EncryptionType.NONE) + unavailable_reason: str = named_field( + 'unavailable-reason', default='') + + @attr.s(auto_attribs=True) class SystemDetails: current: bool = False