示例#1
0
    def _do_check(self):
        self.clear_errors()
        StorageCheckHandler.errors = []
        StorageCheckHandler.warnings = []

        # We can't overwrite the main Storage instance because all the other
        # spokes have references to it that would get invalidated, but we can
        # achieve the same effect by updating/replacing a few key attributes.
        self.storage.devicetree._devices = self._storage_playground.devicetree._devices
        self.storage.devicetree._actions = self._storage_playground.devicetree._actions
        self.storage.devicetree._hidden = self._storage_playground.devicetree._hidden
        self.storage.devicetree.names = self._storage_playground.devicetree.names
        self.storage.roots = self._storage_playground.roots

        # set up bootloader and check the configuration
        try:
            configure_storage(self.storage, interactive=True)
        except BootloaderConfigurationError as e:
            StorageCheckHandler.errors = str(e).split("\n")
            reset_bootloader(self.storage)

        StorageCheckHandler.checkStorage(self)

        if self.errors:
            self.set_warning(_("Error checking storage configuration.  <a href=\"\">Click for details</a> or press Done again to continue."))
        elif self.warnings:
            self.set_warning(_("Warning checking storage configuration.  <a href=\"\">Click for details</a> or press Done again to continue."))

        # on_info_bar_clicked requires self._error to be set, so set it to the
        # list of all errors and warnings that storage checking found.
        self._error = "\n".join(self.errors + self.warnings)

        return self._error == ""
示例#2
0
    def _do_check(self):
        self.clear_errors()
        StorageCheckHandler.errors = []
        StorageCheckHandler.warnings = []

        # We can't overwrite the main Storage instance because all the other
        # spokes have references to it that would get invalidated, but we can
        # achieve the same effect by updating/replacing a few key attributes.
        self.storage.devicetree._devices = self._storage_playground.devicetree._devices
        self.storage.devicetree._actions = self._storage_playground.devicetree._actions
        self.storage.devicetree._hidden = self._storage_playground.devicetree._hidden
        self.storage.devicetree.names = self._storage_playground.devicetree.names
        self.storage.roots = self._storage_playground.roots

        # set up bootloader and check the configuration
        try:
            configure_storage(self.storage, interactive=True)
        except BootloaderConfigurationError as e:
            StorageCheckHandler.errors = str(e).split("\n")
            reset_bootloader(self.storage)

        StorageCheckHandler.checkStorage(self)

        if self.errors:
            self.set_warning(_("Error checking storage configuration.  <a href=\"\">Click for details</a> or press Done again to continue."))
        elif self.warnings:
            self.set_warning(_("Warning checking storage configuration.  <a href=\"\">Click for details</a> or press Done again to continue."))

        # on_info_bar_clicked requires self._error to be set, so set it to the
        # list of all errors and warnings that storage checking found.
        self._error = "\n".join(self.errors + self.warnings)

        return self._error == ""
示例#3
0
    def _run(self):
        # Set up disks/blivet.
        try:
            # Parse the kickstart using anaconda's parser, since it has more
            # advanced error detection.  This also requires having storage set
            # up first.
            parser = AnacondaKSParser(AnacondaKSHandler())
            parser.readKickstartFromString(self.ks)

            self.setupDisks(parser.handler)

            configure_storage(self._storage, parser.handler)
            update_storage_ksdata(self._storage, parser.handler)
            self._storage.devicetree.teardown_all()
            self._storage.do_it()
        except (StorageConfigurationError, BootloaderConfigurationError) as e:
            # anaconda handles expected kickstart errors (like parsing busted
            # input files) by printing the error and quitting.  For testing, an
            # error might be expected so we should compare the result here with
            # what is expected.
            if self.expectedExceptionType and isinstance(
                    e, self.expectedExceptionType):
                # We expected an exception, and we got one of the correct type.
                # If it also contains the string we were expecting, then the
                # test case passes.  Otherwise, it's a failure.
                if self.expectedExceptionText and self._text_matches(str(e)):
                    return
                else:
                    raise FailedTest(str(e), self.expectedExceptionText)
            else:
                # We either got an exception when we were not expecting one,
                # or we got one of a type other than what we were expecting.
                # Either of these cases indicates a failure of the test case.
                raise FailedTest(e, self.expectedExceptionType)
        finally:
            self.tearDownDisks()

        if self.expectedExceptionType:
            raise FailedTest(None, self.expectedExceptionType)
示例#4
0
    def _run(self):
        # Set up disks/blivet.
        try:
            # Parse the kickstart using anaconda's parser, since it has more
            # advanced error detection.  This also requires having storage set
            # up first.
            parser = AnacondaKSParser(AnacondaKSHandler())
            parser.readKickstartFromString(self.ks)

            self.setupDisks(parser.handler)

            configure_storage(self._storage, parser.handler)
            update_storage_ksdata(self._storage, parser.handler)
            self._storage.devicetree.teardown_all()
            self._storage.do_it()
        except (StorageConfigurationError, BootloaderConfigurationError) as e:
            # anaconda handles expected kickstart errors (like parsing busted
            # input files) by printing the error and quitting.  For testing, an
            # error might be expected so we should compare the result here with
            # what is expected.
            if self.expectedExceptionType and isinstance(e, self.expectedExceptionType):
                # We expected an exception, and we got one of the correct type.
                # If it also contains the string we were expecting, then the
                # test case passes.  Otherwise, it's a failure.
                if self.expectedExceptionText and self._text_matches(str(e)):
                    return
                else:
                    raise FailedTest(str(e), self.expectedExceptionText)
            else:
                # We either got an exception when we were not expecting one,
                # or we got one of a type other than what we were expecting.
                # Either of these cases indicates a failure of the test case.
                raise FailedTest(e, self.expectedExceptionType)
        finally:
            self.tearDownDisks()

        if self.expectedExceptionType:
            raise FailedTest(None, self.expectedExceptionType)
示例#5
0
 def execute(self):
     print(_("Generating updated storage configuration"))
     try:
         configure_storage(self.storage, self.data)
     except StorageConfigurationError as e:
         print(_("storage configuration failed: %s") % e)
         self.errors = [str(e)]
         reset_bootloader(self.storage)
         reset_storage(self.storage, scan_all=True)
     except BootloaderConfigurationError as e:
         print(_("storage configuration failed: %s") % e)
         self.errors = [str(e)]
         reset_bootloader(self.storage)
     else:
         print(_("Checking storage configuration..."))
         report = storage_checker.check(self.storage)
         print("\n".join(report.all_errors))
         report.log(log)
         self.errors = report.errors
         self.warnings = report.warnings
     finally:
         reset_custom_storage_data(self.data)
         self._ready = True
示例#6
0
 def execute(self):
     print(_("Generating updated storage configuration"))
     try:
         configure_storage(self.storage, self.data)
     except StorageConfigurationError as e:
         print(_("storage configuration failed: %s") % e)
         self.errors = [str(e)]
         reset_bootloader(self.storage)
         reset_storage(self.storage, scan_all=True)
     except BootloaderConfigurationError as e:
         print(_("storage configuration failed: %s") % e)
         self.errors = [str(e)]
         reset_bootloader(self.storage)
     else:
         print(_("Checking storage configuration..."))
         report = storage_checker.check(self.storage)
         print("\n".join(report.all_errors))
         report.log(log)
         self.errors = report.errors
         self.warnings = report.warnings
     finally:
         reset_custom_storage_data(self.data)
         self._ready = True