Esempio n. 1
0
 def test_discard_persistent_error_can_be_called_many_times(self):
     error_message = factory.make_string()
     component = get_random_component()
     register_persistent_error(component, error_message)
     discard_persistent_error(component)
     discard_persistent_error(component)
     self.assertItemsEqual([], get_persistent_errors())
Esempio n. 2
0
    def _check_rack_controller_connectivity(self):
        """Check each rack controller to see if it's connected.

        If any rack controllers are disconnected, add a persistent error.
        """
        controllers = RackController.objects.all()
        connected_ids = {client.ident for client in getAllClients()}
        disconnected_controllers = {
            controller
            for controller in controllers
            if controller.system_id not in connected_ids
        }
        if len(disconnected_controllers) == 0:
            discard_persistent_error(COMPONENT.RACK_CONTROLLERS)
        else:
            if len(disconnected_controllers) == 1:
                message = (
                    "One rack controller is not yet connected to the region")
            else:
                message = (
                    "%d rack controllers are not yet connected to the region" %
                    len(disconnected_controllers))
            message = ('%s. Visit the <a href="/MAAS/#/controllers">'
                       "rack controllers page</a> for "
                       "more information." % message)
            register_persistent_error(COMPONENT.RACK_CONTROLLERS, message)
Esempio n. 3
0
 def test_discard_persistent_error_can_be_called_many_times(self):
     error_message = factory.getRandomString()
     component = get_random_component()
     register_persistent_error(component, error_message)
     discard_persistent_error(component)
     discard_persistent_error(component)
     self.assertItemsEqual([], get_persistent_errors())
Esempio n. 4
0
    def test_start_up_warns_about_missing_boot_images(self):
        # If no boot images have been registered yet, that may mean that
        # the import script has not been successfully run yet, or that
        # the master worker is having trouble reporting its images.  And
        # so start_up registers a persistent warning about this.
        BootImage.objects.all().delete()
        discard_persistent_error(COMPONENT.IMPORT_PXE_FILES)
        recorder = self.patch(start_up, 'register_persistent_error')

        start_up.start_up()

        self.assertIn(COMPONENT.IMPORT_PXE_FILES,
                      [args[0][0] for args in recorder.call_args_list])
Esempio n. 5
0
    def test_start_up_warns_about_missing_boot_images(self):
        # If no boot images have been registered yet, that may mean that
        # the import script has not been successfully run yet, or that
        # the master worker is having trouble reporting its images.  And
        # so start_up registers a persistent warning about this.
        BootImage.objects.all().delete()
        discard_persistent_error(COMPONENT.IMPORT_PXE_FILES)
        recorder = self.patch(start_up, 'register_persistent_error')

        start_up.start_up()

        self.assertIn(
            COMPONENT.IMPORT_PXE_FILES,
            [args[0][0] for args in recorder.call_args_list])
Esempio n. 6
0
 def test_discard_persistent_error_discards_error(self):
     error_message = factory.getRandomString()
     component = get_random_component()
     register_persistent_error(component, error_message)
     discard_persistent_error(component)
     self.assertItemsEqual([], get_persistent_errors())