async def _init_clean(self):
        """ Must be called when the agent is starting """
        # Data about running containers
        self._containers_running = {}
        self._container_for_job = {}

        self._student_containers_running = {}
        self._student_containers_for_job = {}

        self._containers_killed = dict()

        # Delete tmp_dir, and recreate-it again
        try:
            await self._ashutil.rmtree(self._tmp_dir)
        except OSError:
            pass

        try:
            await self._aos.mkdir(self._tmp_dir)
        except OSError:
            pass

        # Docker
        self._docker = AsyncProxy(DockerInterface())

        # Auto discover containers
        self._logger.info("Discovering containers")
        self._containers = await self._docker.get_containers()

        self._assigned_external_ports = {}  # container_id : [external_ports]

        if self._address_host is None and len(self._containers) != 0:
            self._logger.info("Guessing external host IP")
            self._address_host = await self._docker.get_host_ip(next(iter(self._containers.values()))["id"])
        if self._address_host is None:
            self._logger.warning(
                "Cannot find external host IP. Please indicate it in the configuration. Remote SSH debug has been deactivated.")
            self._external_ports = None
        else:
            self._logger.info("External address for SSH remote debug is %s", self._address_host)

        # Watchers
        self._timeout_watcher = TimeoutWatcher(self._docker)
async def _init_clean ( self ) : self . _containers_running = { } self . _container_for_job = { } self . _student_containers_running = { } self . _student_containers_for_job = { } self . _containers_killed = dict ( ) try : await self . _ashutil . rmtree ( self . _tmp_dir ) except OSError : pass try : await self . _aos . mkdir ( self . _tmp_dir ) except OSError : pass self . _docker = AsyncProxy ( DockerInterface ( ) ) self . _logger . info ( "Discovering containers" ) self . _containers = await self . _docker . get_containers ( ) self . _assigned_external_ports = { } if self . _address_host is None and len ( self . _containers ) != 0 : self . _logger . info ( "Guessing external host IP" ) self . _address_host = await self . _docker . get_host_ip ( next ( iter ( self . _containers . values ( ) ) ) [ "id" ] ) if self . _address_host is None : self . _logger . warning ( "Cannot find external host IP. Please indicate it in the configuration. Remote SSH debug has been deactivated." ) self . _external_ports = None else : self . _logger . info ( "External address for SSH remote debug is %s" , self . _address_host ) self . _timeout_watcher = TimeoutWatcher ( self . _docker )
Must be called when the agent is starting