def _prop_validate(self, key, value=None, validate_value=False):
     if key == BootLoader.PROP_BOOT_TARGS:
         if validate_value is True and value != 'bios':
             raise BootmgmtUnsupportedPlatformError(value + ' is not a '
                   'supported firmware type for ' + self.__class__.__name__)
         return
     super(self.__class__, self)._prop_validate(key, value, validate_value)
Exemple #2
0
    def expanded_kargs(self):
        """Expands all macros found in self.kargs and returns the string
        with all macros expanded.  Currently, only $ZFS-BOOTFS is a
        supported macro."""

        if get_current_arch_string() != 'x86':
            raise BootmgmtUnsupportedPlatformError(
                'expanded_kargs() not '
                'supported on the %s platform' % get_current_arch_string())

        if self.kargs is None:
            return

        if not "$ZFS-BOOTFS" in self.kargs:
            return self.kargs

        # ZFS-BOOTFS expands to a string that contains two elements:
        # The zfs-bootfs element and the bootpath element.  Retrieve
        # Them both from libzfs here, then perform the substitution.
        return self.kargs.replace("$ZFS-BOOTFS", self._expand_zfs_bootfs())
Exemple #3
0
    def get(fw_name):
        """Returns an instance of bootinfo.SystemFirmware corresponding to the
        firmware name passed in.  If fw_name is None, the system firmware type
        is autodetected and the appropriate child of SystemFirmware is returned
        """
        if fw_name is None:
            curarch = get_current_arch_string()
            # If this is a SPARC system, the appropriate class is obp
            if curarch == 'sparc':
                from bootmgmt.backend.fw import obp
                return obp.firmware_backend()('obp')
            elif curarch == 'x86':
                # If this is an x86 system and the efi-systype property exists,
                # then this is a UEFI system and the property value specifies the
                # bit width.
                try:
                    efisystype = pysol.di_find_root_prop('efi-systype')
                except IOError as e:
                    # Problem while trying to get the property
                    # Set efisystype to None to force BIOS
                    efisystype = None

                if efisystype is None:
                    from bootmgmt.backend.fw import bios
                    return bios.firmware_backend()('bios')
                else:
                    uefi_string = 'uefi' + efisystype
                    fwmod = __name__ + '.' + uefi_string
                    __import__(fwmod, level=0)
                    ns = sys.modules[fwmod]
                    return ns.firmware_backend()(uefi_string)
            else:
                raise BootmgmtUnsupportedPlatformError('Unknown platform '
                                                       '"%s"' % curarch)
        else:
            fwmod = __name__ + '.' + fw_name
            __import__(fwmod, level=0)
            ns = sys.modules[fwmod]
            return ns.firmware_backend()(fw_name)
 def probe_generic(**kwargs):
     """Generic probe checks for OBP boot loaders"""
     if get_current_arch_string() != 'sparc':
         raise BootmgmtUnsupportedPlatformError('SPARC-only')