Beispiel #1
0
    def makeService(self, options, clock=reactor):
        """Construct the MAAS Cluster service."""
        register_sigusr1_toggle_cprofile('rackd')
        register_sigusr2_thread_dump_handler()
        clean_prometheus_dir()
        add_patches_to_txtftp()
        add_patches_to_twisted()

        self._loadSettings()
        self._configureCrochet()
        if settings.DEBUG:
            # Always log at debug level in debug mode.
            self._configureLogging(3)
        else:
            self._configureLogging(options["verbosity"])

        with ClusterConfiguration.open() as config:
            tftp_root = config.tftp_root
            tftp_port = config.tftp_port

        from provisioningserver import services
        for service in self._makeServices(tftp_root, tftp_port, clock=clock):
            service.setServiceParent(services)

        return services
Beispiel #2
0
 def test_adds_error_code_8(self):
     self.patch(tftp.datagram, "errors", {})
     add_patches_to_txtftp()
     self.assertIn(8, tftp.datagram.errors)
     self.assertEqual(
         "Terminate transfer due to option negotiation",
         tftp.datagram.errors.get(8),
     )
Beispiel #3
0
    def makeService(self, options, clock=reactor):
        """Construct the MAAS Cluster service."""
        register_sigusr2_thread_dump_handler()
        add_patches_to_txtftp()
        add_patches_to_twisted()

        self._configureCrochet()
        self._configureLogging(options["verbosity"])

        with ClusterConfiguration.open() as config:
            tftp_root = config.tftp_root
            tftp_port = config.tftp_port

        from provisioningserver import services
        for service in self._makeServices(tftp_root, tftp_port, clock=clock):
            service.setServiceParent(services)

        return services
Beispiel #4
0
    def makeService(self, options, clock=reactor, sleep=sleep):
        """Construct the MAAS Cluster service."""
        register_sigusr1_toggle_cprofile("rackd")
        register_sigusr2_thread_dump_handler()
        clean_prometheus_dir()
        add_patches_to_txtftp()
        add_patches_to_twisted()

        self._loadSettings()
        self._configureCrochet()
        if settings.DEBUG:
            # Always log at debug level in debug mode.
            self._configureLogging(3)
        else:
            self._configureLogging(options["verbosity"])

        with ClusterConfiguration.open() as config:
            tftp_root = config.tftp_root
            tftp_port = config.tftp_port

        from provisioningserver import services

        secret = None
        for elapsed, remaining, wait in retries(timeout=5 * 60, clock=clock):
            secret = get_shared_secret_from_filesystem()
            if secret is not None:
                break
            sleep(wait)
        if secret is not None:
            # only setup services if the shared secret is configured
            for service in self._makeServices(tftp_root,
                                              tftp_port,
                                              clock=clock):
                service.setServiceParent(services)

            reactor.callInThread(generate_certificate_if_needed)

        return services
Beispiel #5
0
 def test_skips_adding_error_code_if_already_present(self):
     self.patch(tftp.datagram, "errors", {8: sentinel.error_8})
     add_patches_to_txtftp()
     self.assertEqual(sentinel.error_8, tftp.datagram.errors.get(8))