allow an autoinstall file to request creation of a recovery partition
This commit is contained in:
parent
607eb80bdc
commit
0dca036101
|
@ -451,6 +451,7 @@ class GuidedChoiceV2:
|
||||||
password: Optional[str] = attr.ib(default=None, repr=False)
|
password: Optional[str] = attr.ib(default=None, repr=False)
|
||||||
sizing_policy: Optional[SizingPolicy] = \
|
sizing_policy: Optional[SizingPolicy] = \
|
||||||
attr.ib(default=SizingPolicy.SCALED)
|
attr.ib(default=SizingPolicy.SCALED)
|
||||||
|
reset_partition: bool = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_guided_choice(choice: GuidedChoice):
|
def from_guided_choice(choice: GuidedChoice):
|
||||||
|
|
|
@ -38,6 +38,7 @@ from subiquitycore.async_helpers import (
|
||||||
)
|
)
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.utils import (
|
from subiquitycore.utils import (
|
||||||
|
arun_command,
|
||||||
run_command,
|
run_command,
|
||||||
)
|
)
|
||||||
from subiquitycore.lsb_release import lsb_release
|
from subiquitycore.lsb_release import lsb_release
|
||||||
|
@ -83,6 +84,8 @@ from subiquity.models.filesystem import (
|
||||||
align_down,
|
align_down,
|
||||||
_Device,
|
_Device,
|
||||||
Disk as ModelDisk,
|
Disk as ModelDisk,
|
||||||
|
MiB,
|
||||||
|
Partition as ModelPartition,
|
||||||
LVM_CHUNK_SIZE,
|
LVM_CHUNK_SIZE,
|
||||||
Raid,
|
Raid,
|
||||||
)
|
)
|
||||||
|
@ -194,6 +197,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
# If probe data come in while we are doing partitioning, store it in
|
# If probe data come in while we are doing partitioning, store it in
|
||||||
# this variable. It will be picked up on next reset.
|
# this variable. It will be picked up on next reset.
|
||||||
self.queued_probe_data: Optional[Dict[str, Any]] = None
|
self.queued_probe_data: Optional[Dict[str, Any]] = None
|
||||||
|
self.reset_partition: Optional[ModelPartition] = None
|
||||||
|
|
||||||
def is_core_boot_classic(self):
|
def is_core_boot_classic(self):
|
||||||
return self._info.is_core_boot_classic()
|
return self._info.is_core_boot_classic()
|
||||||
|
@ -491,6 +495,16 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
if gap is None:
|
if gap is None:
|
||||||
raise Exception('failed to locate gap after adding boot')
|
raise Exception('failed to locate gap after adding boot')
|
||||||
|
|
||||||
|
if choice.reset_partition:
|
||||||
|
cp = await arun_command(['du', '-sb', '/cdrom'])
|
||||||
|
reset_size = int(cp.stdout.strip().split()[0])
|
||||||
|
reset_size = align_up(int(reset_size * 1.10), 256 * MiB)
|
||||||
|
reset_gap, gap = gap.split(reset_size)
|
||||||
|
self.reset_partition = self.create_partition(
|
||||||
|
device=reset_gap.device, gap=reset_gap,
|
||||||
|
spec={'fstype': 'fat32'})
|
||||||
|
# Should probably set some kind of flag on reset_partition
|
||||||
|
|
||||||
if choice.capability.is_lvm():
|
if choice.capability.is_lvm():
|
||||||
self.guided_lvm(gap, choice)
|
self.guided_lvm(gap, choice)
|
||||||
elif choice.capability == GuidedCapability.DIRECT:
|
elif choice.capability == GuidedCapability.DIRECT:
|
||||||
|
@ -1114,8 +1128,10 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
log.info(f'autoinstall: running guided {capability} install in '
|
log.info(f'autoinstall: running guided {capability} install in '
|
||||||
f'mode {mode} using {target}')
|
f'mode {mode} using {target}')
|
||||||
await self.guided(
|
await self.guided(
|
||||||
GuidedChoiceV2(target=target, capability=capability,
|
GuidedChoiceV2(
|
||||||
password=password, sizing_policy=sizing_policy))
|
target=target, capability=capability,
|
||||||
|
password=password, sizing_policy=sizing_policy,
|
||||||
|
reset_partition=layout.get('reset-partition', False)))
|
||||||
|
|
||||||
def validate_layout_mode(self, mode):
|
def validate_layout_mode(self, mode):
|
||||||
if mode not in ('reformat_disk', 'use_gap'):
|
if mode not in ('reformat_disk', 'use_gap'):
|
||||||
|
|
Loading…
Reference in New Issue