예제 #1
0
 def __init__(self,
              image_aliases,
              task_directory,
              course_factory,
              task_factory,
              agent_tmp_dir="./agent_tmp",
              hook_manager=None,
              is_testing=False,
              agent_class=LocalAgent):
     AbstractJobManager.__init__(self, image_aliases, hook_manager,
                                 is_testing)
     self._agent = agent_class(image_aliases, task_directory,
                               course_factory, task_factory, agent_tmp_dir)
    def __init__(self, agents, image_aliases, task_directory, course_factory, task_factory, hook_manager=None, is_testing=False):
        """
            Starts the job manager.

            Arguments:

            :param agents:
                A list of dictionaries containing information about distant inginious.backend agents:
                ::

                    {
                        'host': "the host of the agent",
                        'port': "the port on which the agent listens"
                        'ssh_port': "the port on which the interface for accessing the debug ssh server is accessible (not mandatory, can be None)"
                    }

                If a least one ssh_port is absent or None, remote debugging will be deactivated for all agents
            :param task_directory: the task directory
            :param course_factory: a CourseFactory object
            :param task_factory: a TaskFactory object, possibly with specific task files managers attached
            :param image_aliases: a dict of image aliases, like {"default": "ingi/inginious-c-default"}.
            :param hook_manager: An instance of HookManager. If no instance is given(None), a new one will be created.
        """

        AbstractJobManager.__init__(self, image_aliases, hook_manager, is_testing)

        # Count the number of times the function _try_agent_connection is called, when testing
        if is_testing:
            self._connection_attempts = 0

        self._task_directory = task_directory

        self._agents = [None for _ in range(0, len(agents))]
        self._agents_thread = [None for _ in range(0, len(agents))]
        self._agents_info = agents

        self._course_factory = course_factory
        self._task_factory = task_factory

        self._next_agent = 0
        self._running_on_agent = [[] for _ in range(0, len(agents))]

        self._last_content_in_task_directory = None

        self._timers = {}

        # Is remote debugging activated?
        nb_ok = 0
        message = "ok"

        for info in self._agents_info:
            if info.get('ssh_port') is not None:
                nb_ok += 1
            elif nb_ok != 0:
                nb_ok = -1
                message = "one_error"

        if nb_ok == 0:
            self._remote_debugging_activated = False
            print "Remote debugging is deactivated as all agent have no ssh_port defined"
        elif nb_ok == -1:
            self._remote_debugging_activated = False
            print "Remote debugging is deactivated as one agent has no ssh_port defined"
        else:
            self._remote_debugging_activated = True
예제 #3
0
 def __init__(self, image_aliases, task_directory, course_factory, task_factory, agent_tmp_dir="./agent_tmp", hook_manager=None, is_testing=False,
              agent_class=LocalAgent):
     AbstractJobManager.__init__(self, image_aliases, hook_manager, is_testing)
     self._agent = agent_class(image_aliases, task_directory, course_factory, task_factory, agent_tmp_dir)
예제 #4
0
    def __init__(self,
                 agents,
                 image_aliases,
                 task_directory,
                 course_factory,
                 task_factory,
                 hook_manager=None,
                 is_testing=False):
        """
            Starts the job manager.

            Arguments:

            :param agents:
                A list of dictionaries containing information about distant inginious.backend agents:
                ::

                    {
                        'host': "the host of the agent",
                        'port': "the port on which the agent listens"
                        'ssh_port': "the port on which the interface for accessing the debug ssh server is accessible (not mandatory, can be None)"
                    }

                If a least one ssh_port is absent or None, remote debugging will be deactivated for all agents
            :param task_directory: the task directory
            :param course_factory: a CourseFactory object
            :param task_factory: a TaskFactory object, possibly with specific task files managers attached
            :param image_aliases: a dict of image aliases, like {"default": "ingi/inginious-c-default"}.
            :param hook_manager: An instance of HookManager. If no instance is given(None), a new one will be created.
        """

        AbstractJobManager.__init__(self, image_aliases, hook_manager,
                                    is_testing)

        # Count the number of times the function _try_agent_connection is called, when testing
        if is_testing:
            self._connection_attempts = 0

        self._task_directory = task_directory

        self._agents = [None for _ in range(0, len(agents))]
        self._agents_thread = [None for _ in range(0, len(agents))]
        self._agents_info = agents

        self._course_factory = course_factory
        self._task_factory = task_factory

        self._next_agent = 0
        self._running_on_agent = [[] for _ in range(0, len(agents))]

        self._last_content_in_task_directory = None

        self._timers = {}

        # Is remote debugging activated?
        nb_ok = 0
        message = "ok"

        for info in self._agents_info:
            if info.get('ssh_port') is not None:
                nb_ok += 1
            elif nb_ok != 0:
                nb_ok = -1
                message = "one_error"

        if nb_ok == 0:
            self._remote_debugging_activated = False
            self._logger.info(
                "Remote debugging is deactivated as all agent have no ssh_port defined"
            )
        elif nb_ok == -1:
            self._remote_debugging_activated = False
            self._logger.info(
                "Remote debugging is deactivated as one agent has no ssh_port defined"
            )
        else:
            self._remote_debugging_activated = True