# Hardware
self.disks = disk.Disks(self)
for path in disks:
- self.disks.add_disk(path)
+ self.disks.add_disk(path, selected=True)
# Initialise the text user interface
self.tui = tui.Tui(self)
step.UnattendedWarning,
step.Welcome,
timezones.SelectTimezone,
+ disk.UnattendedSelectDisk,
disk.SelectDisk,
disk.CalculatePartitionLayout,
step.RootPassword,
"""
Scans for all disks
"""
- self.disks.clear()
+ # Don't scan for disks if already done
+ if self.disks:
+ return
log.debug("Scanning for disks...")
# Sort them alphabetically
self.disks.sort()
- def add_disk(self, path):
+ def add_disk(self, path, selected=False):
"""
Adds the disk at path
"""
disk = Disk(self.bricklayer, path)
self.disks.append(disk)
+ # Select this disk
+ if selected:
+ disk.selected = True
+
return disk
def _losetup(self, path):
self.bricklayer.command(command)
+class UnattendedSelectDisk(step.UnattendedStep):
+ """
+ Scans for any disks
+ """
+ def run(self):
+ # Nothing to do if disks have already been selected on the CLI
+ if self.bricklayer.disks.selected:
+ return
+
+ # Scan for disks
+ self.bricklayer.disks.scan()
+
+ # End here if we could not find any disks
+ if not self.bricklayer.disks.supported:
+ self.tui.error(
+ _("No Disks Found"),
+ _("No supported disks were found")
+ )
+
+ raise InstallAbortedError("No disks found")
+
+ # Automatically select the first disk
+ for disk in self.bricklayer.disks.supported:
+ disk.selected = True
+ break
+
+
class SelectDisk(step.InteractiveStep):
"""
Ask the user which disk(s) to use for the installation process
return not self.bricklayer.unattended
+class UnattendedStep(Step):
+ """
+ A convenience handler that only runs this step in unattended mode
+ """
+ @property
+ def enabled(self):
+ # Enable only in unattended mode
+ return self.bricklayer.unattended
+
+
class Welcome(InteractiveStep):
"""
Shows a very warm welcome message to the user