Exemple #1
0
    def run(self):
        """
        Executes action dispatching process.
        """
        self.log.info("Action dispatching started.")
        self.update_process_title()

        redis = get_redis_connection(self.opts)
        worker_manager = ActionWorkerManager(
            redis_connection=redis,
            log=self.log,
            max_workers=self.opts.actions_max_workers)
        worker_manager.frontend_client = FrontendClient(self.opts, self.log)

        timeout = self.opts.sleeptime

        while True:
            self.log.info("getting actions from frontend")
            start = time.time()
            for task in self.get_frontend_actions():
                worker_manager.add_task(task)

            # Execute the actions.
            worker_manager.run(timeout=timeout)

            sleep_more = timeout - (time.time() - start)
            if sleep_more > 0:
                time.sleep(sleep_more)
Exemple #2
0
    def __init__(self, opts):
        multiprocessing.Process.__init__(self, name="action-dispatcher")

        self.opts = opts
        self.log = get_redis_logger(self.opts, "backend.action_dispatcher",
                                    "action_dispatcher")
        self.frontend_client = FrontendClient(self.opts, self.log)
Exemple #3
0
 def __init__(self, opts, cmdline_opts=None):
     self.opts = opts
     self.prune_days = getattr(self.opts, "prune_days", DEF_DAYS)
     self.chroots = {}
     self.frontend_client = FrontendClient(self.opts)
     self.mtime_optimization = True
     if cmdline_opts:
         self.mtime_optimization = not cmdline_opts.no_mtime_optimization
Exemple #4
0
    def __init__(self, config_file=None, ext_opts=None):
        if not config_file:
            raise CoprBackendError("Must specify config_file")

        self.config_file = config_file
        self.ext_opts = ext_opts  # to show our cli options for read_conf()

        self.config_reader = BackendConfigReader(self.config_file,
                                                 self.ext_opts)
        self.opts = None
        self.update_conf()

        self.log = get_redis_logger(self.opts, "backend.main", "backend")
        self.frontend_client = FrontendClient(self.opts, self.log)
Exemple #5
0
    def __init__(self, opts):
        multiprocessing.Process.__init__(self, name="build-dispatcher")

        self.opts = opts
        self.log = get_redis_logger(self.opts, "backend.build_dispatcher",
                                    "build_dispatcher")
        self.frontend_client = FrontendClient(self.opts, self.log)
        self.vm_manager = VmManager(self.opts)

        # Maps e.g. x86_64 && i386 => PC
        self.arch_to_group = dict()
        # PC => max N builders per user
        self.group_to_usermax = dict()

        self.init_internal_structures()
Exemple #6
0
    def setup_method(self, method):
        self.opts = Munch(
            frontend_base_url="http://example.com/",
            frontend_auth="12345678",
        )
        self.fc = FrontendClient(self.opts)

        self.data = {
            "foo": "bar",
            "bar": [1, 3, 5],
        }
        self.url_path = "sub_path"

        self.build_id = 12345
        self.chroot_name = "fedora-20-x86_64"
Exemple #7
0
    def __init__(self, opts):
        multiprocessing.Process.__init__(self, name="build-dispatcher")

        self.opts = opts
        self.log = get_redis_logger(self.opts, "backend.build_dispatcher", "build_dispatcher")
        self.frontend_client = FrontendClient(self.opts, self.log)
        self.vm_manager = VmManager(self.opts)
        self.workers = []
        self.next_worker_id = 1

        self.arch_to_groups = defaultdict(list)
        # PC => max N builders per user
        self.group_to_usermax = dict()

        self.init_internal_structures()
Exemple #8
0
    def __init__(self, opts):
        """ base class initialization """

        self.opts = opts

        # Maps e.g. x86_64 && i386 => PC (.
        self.arch_to_group_id_map = dict()
        # PC => max N builders per user
        self.group_to_usermax = dict()
        # task_id -> task dict
        self.added_jobs_dict = dict()

        self.rc = None
        self.channel = None
        self.ps_thread = None

        self.log = get_redis_logger(self.opts, "backend.job_grab", "job_grab")
        self.jg_control = jobgrabcontrol.Channel(self.opts, self.log)
        self.frontend_client = FrontendClient(self.opts, self.log)
Exemple #9
0
    def __init__(self, config_file=None, ext_opts=None):
        # read in config file
        # put all the config items into a single self.opts munch

        if not config_file:
            raise CoprBackendError("Must specify config_file")

        self.config_file = config_file
        self.ext_opts = ext_opts  # to stow our cli options for read_conf()
        self.workers_by_group_id = defaultdict(list)
        self.max_worker_num_by_group_id = defaultdict(int)

        self.config_reader = BackendConfigReader(self.config_file,
                                                 self.ext_opts)
        self.opts = None
        self.update_conf()

        self.task_queues = {}

        self.frontend_client = FrontendClient(self.opts)
        self.is_running = False

        self.log = get_redis_logger(self.opts, "backend.main", "backend")
Exemple #10
0
def main():
    opts = get_backend_opts()
    fc = FrontendClient(opts)
    grabber = CoprJobGrab(opts, frontend_client=fc)
    grabber.run()