diff --git a/subiquity/controllers/filesystem.py b/subiquity/controllers/filesystem.py index ec03274c..9565a74a 100644 --- a/subiquity/controllers/filesystem.py +++ b/subiquity/controllers/filesystem.py @@ -83,12 +83,15 @@ class FilesystemController(SubiquityController): def load_autoinstall_data(self, data): log.debug("load_autoinstall_data %s", data) - if not self.interactive() and data is None: - data = { - 'layout': { - 'name': 'lvm', - }, - } + if data is None: + if not self.interactive(): + data = { + 'layout': { + 'name': 'lvm', + }, + } + else: + data = {} log.debug("self.ai_data = %s", data) self.ai_data = data @@ -154,6 +157,10 @@ class FilesystemController(SubiquityController): disks = self.model.all_disks() disks.sort(key=lambda x: x.size) meth(disks[-1]) + elif 'config' in self.ai_data: + with self.context.child("applying_autoinstall"): + # needs to account for grub and swap data too. + self.model.apply_autoinstall_config(self.ai_data['config']) def start(self): self._start_task = schedule_task(self._start()) @@ -661,7 +668,7 @@ class FilesystemController(SubiquityController): } self.partition_disk_handler(disk, None, result) - def guided_lvm(self, disk, lvm_options): + def guided_lvm(self, disk, lvm_options=None): self.reformat(disk) if DeviceAction.MAKE_BOOT in disk.supported_actions: self.make_boot_disk(disk) @@ -677,7 +684,7 @@ class FilesystemController(SubiquityController): fstype=None, )) spec = dict(name="ubuntu-vg", devices=set([part])) - if lvm_options['encrypt']: + if lvm_options and lvm_options['encrypt']: spec['password'] = lvm_options['luks_options']['password'] # create volume group on partition vg = self.create_volgroup(spec) diff --git a/subiquity/controllers/ssh.py b/subiquity/controllers/ssh.py index 40674a67..368d4f1e 100644 --- a/subiquity/controllers/ssh.py +++ b/subiquity/controllers/ssh.py @@ -43,9 +43,9 @@ class SSHController(SubiquityController): if data is None: return self.model.install_server = data.get('install_server', False) - self.model.authorized_keys = self.autoinstall_data.get( + self.model.authorized_keys = data.get( 'authorized-keys', []) - self.model.pwauth = self.autoinstall_data.get( + self.model.pwauth = data.get( 'allow-pw', not self.model.authorized_keys) def start_ui(self): diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 5d67208a..82b0928d 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1257,7 +1257,11 @@ class FilesystemModel(object): self._actions = [] self.grub_install_device = None - def _actions_from_config(self, config, blockdevs): + def apply_autoinstall_config(self, ai_config): + self._actions = self._actions_from_config( + ai_config, self._probe_data['blockdev'], is_autoinstall=True) + + def _actions_from_config(self, config, blockdevs, is_autoinstall=False): """Convert curtin storage config into action instances. curtin represents storage "actions" as defined in @@ -1284,7 +1288,7 @@ class FilesystemModel(object): exclusions = set() seen_multipaths = set() for action in config: - if action['type'] == 'mount': + if not is_autoinstall and action['type'] == 'mount': exclusions.add(byid[action['device']]) continue c = _type_to_cls.get(action['type'], None) @@ -1313,7 +1317,8 @@ class FilesystemModel(object): if kw['type'] == 'disk': path = kw['path'] kw['info'] = StorageInfo({path: blockdevs[path]}) - kw['preserve'] = True + if not is_autoinstall: + kw['preserve'] = True obj = byid[action['id']] = c(m=self, **kw) multipath = kw.get('multipath') if multipath: