コード例 #1
0
    def test_clear_error_list(self):
        '''Testing: clear_error_list().'''

        # Make sure there is some error stored,
        errsvc.ErrorInfo(self.mod_id, self.error_types[0])

        # before clearing the error list.
        errsvc.clear_error_list()
        errors = errsvc.get_all_errors()

        self.assertEqual(len(errors), 0)
コード例 #2
0
    def test_clear_error_list_by_mod_id(self):
        '''Testing: clear_error_list_by_mod_id(mod_id)'''

        errsvc.clear_error_list()

        # add two errors, each with their own mod_id
        error1 = errsvc.ErrorInfo(self.mod_id, self.error_types[0])
        error2 = errsvc.ErrorInfo("mod2", self.error_types[0])

        # verify there are 2 errors in the list
        self.assertEqual(len(errsvc.get_all_errors()), 2)

        # remove all "mod1" mod_ids from the list
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # verify there is only 1 error in the list and that it's mod_id is
        # correct
        self.assertEqual(len(errsvc.get_all_errors()), 1)

        errors = errsvc.get_errors_by_mod_id("mod2")
        self.assertEqual(len(errors), 1)
        self.assertEqual(errors[0].mod_id, "mod2")
コード例 #3
0
    def test_get_all_errors(self):
        '''Testing: get_all_errors().'''

        errsvc.clear_error_list()
        for error_type in self.error_types:
            errsvc.ErrorInfo(self.mod_id, error_type)

        errors = errsvc.get_all_errors()

        for error in errors:
            mod_id = error.get_mod_id()
            error_type = error.get_error_type()
            self.assertEqual(mod_id, self.mod_id)
            self.assertEqual(error_type, self.error_types[error_type])
コード例 #4
0
def perform_final_validation(doc):

    LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)

    LOGGER.info("Going to perform final validation of desired target")

    desired_root = doc.persistent.get_descendants(name=Target.DESIRED,
                                                  class_type=Target,
                                                  max_depth=2,
                                                  not_found_is_err=True)[0]

    LOGGER.debug(str(desired_root))

    errsvc.clear_error_list()

    if not desired_root.final_validation():
        all_errors = errsvc.get_all_errors()

        for err in all_errors:

            if not isinstance(err.error_data[liberrsvc.ES_DATA_EXCEPTION],
                              ShadowPhysical.SliceInUseError):
                LOGGER.error("Error module ID: %s.. error type: %s" % \
                             (err.get_mod_id(), str(err.get_error_type())))
                LOGGER.error("Error class: %r",
                             err.error_data[liberrsvc.ES_DATA_EXCEPTION])
                LOGGER.error("Exception value: %s",
                             err.error_data[liberrsvc.ES_DATA_EXCEPTION].value)
                raise ValueError("Desired target doesn't pass "
                                 "final validation")
            else:
                LOGGER.debug("SliceInUseError is OK")
                LOGGER.debug("Error module ID: %s.. error type: %s" % \
                             (err.get_mod_id(), str(err.get_error_type())))
                LOGGER.debug("Exception value: %s",
                             err.error_data[liberrsvc.ES_DATA_EXCEPTION].value)
    else:
        LOGGER.debug("No error from final validation")