Exemple #1
0
    def test_parse_message_bad_registry(self):
        conn = mock.Mock()
        with open('sushy/tests/unit/json_samples/message_registry.json') as f:
            conn.get.return_value.json.return_value = json.load(f)
        registry = message_registry.MessageRegistry(
            conn, '/redfish/v1/Registries/Test', redfish_version='1.0.2')
        registries = {'Test.1.0.0': registry}
        message_field = sushy_base.MessageListField('Foo')
        message_field.message_id = 'BadRegistry.TooBig'

        parsed_msg = message_registry.parse_message(registries, message_field)

        self.assertEqual(message_field, parsed_msg)
    def test_parse_message_with_severity_resolution_no_args(self):
        conn = mock.Mock()
        with open('sushy/tests/unit/json_samples/message_registry.json') as f:
            conn.get.return_value.json.return_value = json.load(f)
        registry = message_registry.MessageRegistry(
            conn, '/redfish/v1/Registries/Test', redfish_version='1.0.2')
        registries = {'Test.1.0.0': registry}
        message_field = settings.MessageListField('Foo')
        message_field.message_id = 'Test.1.0.0.Success'
        message_field.severity = res_cons.SEVERITY_OK
        message_field.resolution = 'Do nothing'

        parsed_msg = message_registry.parse_message(registries, message_field)

        self.assertEqual('Do nothing', parsed_msg.resolution)
        self.assertEqual(res_cons.SEVERITY_OK, parsed_msg.severity)
        self.assertEqual('Everything done successfully.', parsed_msg.message)
    def test_parse_message(self):
        conn = mock.Mock()
        with open('sushy/tests/unit/json_samples/message_registry.json') as f:
            conn.get.return_value.json.return_value = json.load(f)
        registry = message_registry.MessageRegistry(
            conn, '/redfish/v1/Registries/Test', redfish_version='1.0.2')
        registries = {'Test.1.0.0': registry}
        message_field = settings.MessageListField('Foo')
        message_field.message_id = 'Test.1.0.0.TooBig'
        message_field.message_args = ['arg1', 10]
        message_field.severity = None
        message_field.resolution = None

        parsed_msg = message_registry.parse_message(registries, message_field)

        self.assertEqual('Try again', parsed_msg.resolution)
        self.assertEqual(res_cons.SEVERITY_WARNING, parsed_msg.severity)
        self.assertEqual('Property\'s arg1 value cannot be greater than 10.',
                         parsed_msg.message)
Exemple #4
0
    def get_status(self, registries):
        """Determines the status of last update based

        Uses message id-s and severity to determine the status.

        :param registries: registries to use to parse message
        :returns: :class:`.SettingsUpdate` object containing status
            and any messages
        """

        if not self.time:
            return SettingsUpdate(NO_UPDATES, None)

        parsed_msgs = []
        for m in self.messages:
            parsed_msgs.append(message_registry.parse_message(registries, m))
        any_errors = any(m for m in parsed_msgs
                         if not m.severity == res_cons.SEVERITY_OK)

        if any_errors:
            status = UPDATE_FAILURE
        else:
            status = UPDATE_SUCCESS
        return SettingsUpdate(status, parsed_msgs)
Exemple #5
0
 def parse_messages(self):
     """Parses the messages"""
     for m in self.messages:
         message_registry.parse_message(self._registries, m)