def _validate_grub2_configuration(self, data): """Validate the GRUB2 configuration. :raise: KickstartParseError if not valid """ # Skip other types of the bootloader. if self.bootloader_type is not BootloaderType.DEFAULT: return if not issubclass(get_bootloader_class(), GRUB2): return # Check the location support. if self.preferred_location == BOOTLOADER_LOCATION_PARTITION: raise KickstartParseError( _("GRUB2 does not support installation to a partition."), lineno=data.bootloader.lineno) # Check the password format. if self.password_is_set \ and self.password_is_encrypted \ and not self.password.startswith("grub.pbkdf2."): raise KickstartParseError( _("GRUB2 encrypted password must be in grub.pbkdf2 format."), lineno=data.bootloader.lineno)
def get_bootloader_class_test(self): """Test get_bootloader_class.""" bootloader_by_platform = { platform.X86: GRUB2, platform.EFI: EFIGRUB, platform.MacEFI: MacEFIGRUB, platform.PPC: GRUB2, platform.IPSeriesPPC: IPSeriesGRUB2, platform.PowerNV: PowerNVGRUB2, platform.S390: ZIPL, platform.Aarch64EFI: Aarch64EFIGRUB, platform.ARM: EXTLINUX, platform.ArmEFI: ArmEFIGRUB, Mock(): BootLoader } for platform_type, bootloader_type in bootloader_by_platform.items(): # Get the bootloader class. cls = get_bootloader_class(platform_type) self.assertEqual(cls, bootloader_type) # Get the bootloader instance. obj = cls() self.assertIsInstance(obj, BootLoader)
def _validate_grub2_configuration(self, data): """Validate the GRUB2 configuration. :raise: KickstartParseError if not valid """ # Skip other types of the bootloader. if self.bootloader_type is not BootloaderType.DEFAULT: return if not issubclass(get_bootloader_class(), GRUB2): return # Check the location support. if self.preferred_location == BOOTLOADER_LOCATION_PARTITION: raise KickstartParseError(_("GRUB2 does not support installation to a partition."), lineno=data.bootloader.lineno) # Check the password format. if self.password_is_set \ and self.password_is_encrypted \ and not self.password.startswith("grub.pbkdf2."): raise KickstartParseError(_("GRUB2 encrypted password must be in grub.pbkdf2 format."), lineno=data.bootloader.lineno)
def get_bootloader_class_test(self): """Test get_bootloader_class.""" bootloader_by_platform = { platform.X86: GRUB2, platform.EFI: EFIGRUB, platform.MacEFI: MacEFIGRUB, platform.PPC: GRUB2, platform.IPSeriesPPC: IPSeriesGRUB2, platform.S390: ZIPL, platform.Aarch64EFI: Aarch64EFIGRUB, platform.ARM: EXTLINUX, platform.ArmEFI: ArmEFIGRUB, Mock(): BootLoader } for platform_type, bootloader_type in bootloader_by_platform.items(): # Get the bootloader class. cls = get_bootloader_class(platform_type) self.assertEqual(cls, bootloader_type) # Get the bootloader instance. obj = cls() self.assertIsInstance(obj, BootLoader)