Example #1
0
    def apply_config(self, configs, skip_env_dependent=False, reconfigure=False):
        """Apply a configuration. If skip_env_dependent is True we're
        loading this locally to test the config as part of tronfig. We want to
        skip applying some settings because the local machine we're using to
        edit the config may not have the same environment as the live
        trond machine.
        """
        master_config = configs[MASTER_NAMESPACE]
        self.output_stream_dir = master_config.output_stream_dir or self.working_dir
        if not skip_env_dependent:
            ssh_options = self._ssh_options_from_config(configs[MASTER_NAMESPACE].ssh_options)
            state_persistence = configs[MASTER_NAMESPACE].state_persistence
        else:
            ssh_options = config_parse.valid_ssh_options({})
            state_persistence = config_parse.DEFAULT_STATE_PERSISTENCE

        self.state_manager = PersistenceManagerFactory.from_config(
                    state_persistence)
        self.context.base = configs[MASTER_NAMESPACE].command_context
        self.time_zone = configs[MASTER_NAMESPACE].time_zone
        self._apply_nodes(configs[MASTER_NAMESPACE].nodes, ssh_options)
        self._apply_node_pools(configs[MASTER_NAMESPACE].node_pools)
        self._apply_notification_options(configs[MASTER_NAMESPACE].notification_options)

        jobs, services = collate_jobs_and_services(configs)
        self._apply_jobs(jobs, reconfigure=reconfigure)
        self._apply_services(services)
Example #2
0
    def apply_config(self, config_container, reconfigure=False):
        """Apply a configuration."""
        master_config = config_container.get_master()
        self.output_stream_dir = master_config.output_stream_dir or self.working_dir
        ssh_options = self._ssh_options_from_config(master_config.ssh_options)
        self.update_state_watcher_config(master_config.state_persistence)

        self.context.base = master_config.command_context
        self.time_zone = master_config.time_zone
        self._apply_nodes(master_config.nodes, ssh_options)
        self._apply_node_pools(master_config.node_pools)
        self._apply_notification_options(master_config.notification_options)

        jobs, services = collate_jobs_and_services(config_container)
        self._apply_jobs(jobs, reconfigure=reconfigure)
        self._apply_services(services)