Exemplo n.º 1
0
    def makeService(self, options):
        """Construct the MAAS Region service."""
        register_sigusr1_toggle_cprofile("regiond-all")
        register_sigusr2_thread_dump_handler()

        self._configureThreads()
        self._configureLogging(options["verbosity"])
        self._configureDjango()
        self._configurePservSettings()
        self._configureReactor()
        self._configureCrochet()
        self._ensureConnection()

        # Reconfigure the logging if required.
        self._reconfigureLogging()

        # Populate the region's event-loop with services.
        from maasserver import eventloop

        eventloop.loop.populate(
            master=True, all_in_one=True, import_services=True
        )

        # Return the eventloop's services to twistd, which will then be
        # responsible for starting them all.
        return eventloop.loop.services
Exemplo n.º 2
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
Exemplo n.º 3
0
    def makeService(self, options):
        """Construct the MAAS Region service."""
        register_sigusr1_toggle_cprofile("regiond-worker")
        register_sigusr2_thread_dump_handler()

        self._set_pdeathsig()
        self._configureThreads()
        self._configureLogging(options["verbosity"])
        self._configureDjango()
        self._configurePservSettings()
        self._configureReactor()
        self._configureCrochet()

        # Reconfigure the logging if required.
        self._reconfigureLogging()

        # Should the import services run in this worker.
        import_services = False
        if os.environ.get("MAAS_REGIOND_RUN_IMPORTER_SERVICE") == "true":
            import_services = True

        # Populate the region's event-loop with services.
        from maasserver import eventloop

        eventloop.loop.populate(master=False, import_services=import_services)

        # Return the eventloop's services to twistd, which will then be
        # responsible for starting them all.
        return eventloop.loop.services
Exemplo n.º 4
0
    def makeService(self, options, clock=reactor):
        """Construct the MAAS Cluster HTTP service."""
        register_sigusr2_thread_dump_handler()
        add_patches_to_twisted()

        self._loadSettings()
        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

        return self._makeHTTPService(5248, tftp_root, 'images')
Exemplo n.º 5
0
    def makeService(self, options):
        """Construct the MAAS Region service."""
        register_sigusr2_thread_dump_handler()

        self._set_pdeathsig()
        self._configureThreads()
        self._configureLogging(options["verbosity"])
        self._configureDjango()
        self._configureReactor()
        self._configureCrochet()

        # Populate the region's event-loop with services.
        from maasserver import eventloop
        eventloop.loop.populate(master=False)

        # Return the eventloop's services to twistd, which will then be
        # responsible for starting them all.
        return eventloop.loop.services
Exemplo n.º 6
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
Exemplo n.º 7
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