diff --git a/README.md b/README.md index b3277092045634590f128fd35acb8cc17dbd21eb..f1ca7837fbc40c68a661d237d842fe0d54304c8b 100644 --- a/README.md +++ b/README.md @@ -7,20 +7,8 @@ - [Shared work](#shared-work) - [Wait function](#wait-function) - [Experience format](#experience-format) -- [Topics](#topics) - - [Agent](#agent) - - [Scheduler](#scheduler) - - [Amas](#amas) - - [Env](#env) -- [Mosquitto (Windows)](#mosquitto-windows) -- [Mosquitto (Linux) Didn't work](#mosquitto-linux-didnt-work) - -requirement : - * paho-mqtt - * pexpect - # Reseau Port : @@ -31,8 +19,6 @@ Port : * Broker : Mosquitto (Windows) * Client : python paho-mqtt -**Configuration raspberry :** -SSH activé avec hostname et mdp **Configuration windows :** WSL (pour pouvoir démarer l'amas) @@ -40,8 +26,11 @@ WSL (pour pouvoir démarer l'amas) # Random note -First procedure : - 1. etre sur que le ssh est trust (faire un premier ssh hors du programe) +ihm : + 1. Loading (check if good format) -> Warning -> can't "start" + 2. Ping (all in config) -> Warning -> can't start, can't agent + 3. Agent -> Warning -> already running -> kill ? + 4. Whatever (start) Start procédure : @@ -186,117 +175,3 @@ Pour ajouter des attributs a l'initialisation aux agents il suffit de rajouter d **A AJOUTER** un .config dans les experience avec la version du coeur -# Topics - -## Agent - -Tout les topics des agents sont du format : -> `agent/agentid/topicname` - -Par exemple le topic `log` de l'agent 2 est : -> `agent/2/log` - -Les topics présent par défaut : -`log` : -> envoie un message qui sera print par l'amas - -`cycle_done` : -> prévient le scheduler qu'une action c'est fini - -`metric` : -> a la fin de chaque cycle envoie un dico avec tout les info a potentielement partager - - -## Scheduler - -Les topics du scheduler sont dans le format : -> `scheduler/aQui/topic` - -Par exemple, pour débloquer les agents : -> `scheduler/agent/wakeup` - -Les topics présent par défaut : -`agent/wakeup` : -> envoie a tout les agents un message pour les débloquer - -`schedulable/wakeup` : -> envoie a l'amas et l'environment un message pour les débloquer - -## Amas - -Les topics présent par défaut : -`amas/agent/new` : -> Envoie un message pour prévenir qu'un nouvel agent est crée avec son ID - -`amas/action_done` : -> Envoie un message pour prévenir le scheduleur de la fin d'une action - -`amas/agent/id/neighbor` : -> Topic to communicate to agent "id" his neighborhood - -## Env - -Les topics présent par défaut : -`env/action_done` : -> Envoie un message pour prévenir le scheduleur de la fin d'une action - - -# Mosquitto (Windows) - -Stop mosquitto in service - -Start mosquitto : `mosquitto -v -c D:\data\mosquitto\mosquitto.conf` - -Config file : -``` -allow_anonymous false - -password_file D:\data\mosquitto\pwfile - -listener 1883 -``` - -Check port 1883 : `netstat -a` - -# Mosquitto (Linux) Didn't work - - -Config file : -``` -allow_anonymous false -password_file /etc/mosquitto/pwfile -listener 1883 -``` - -Restart moquitto : -``` -sudo service mosquitto stop -// check if a pid is still running -sudo lsof -i:1883 -// or -pgrep mosquitto -// and kill it -sudo kill pid - -sudo start mosquitto -v -``` - - -**firewall (didn't work):** -``` -sudo apt update -sudo apt full-upgrade -sudo apt install ufw -sudo ufw status verbose -``` - -allow : -``` -sudo ufw allow port -sudo ufw enable -``` - -``` -sudo ufw disable -sudo apt remove ufw -``` diff --git a/dist/iotAmak-0.0.1-py3-none-any.whl b/dist/iotAmak-0.0.1-py3-none-any.whl index 9d5df61d4d4c5dacd84d9a0360412ea1f3249121..4895e53f2612b1a1293548dc04d552f4eebb50e5 100644 Binary files a/dist/iotAmak-0.0.1-py3-none-any.whl and b/dist/iotAmak-0.0.1-py3-none-any.whl differ diff --git a/iotAmak/tool/schedulable.py b/iotAmak/tool/schedulable.py index e1e1e717da68d140a43c3b0dc48d5a9899992438..3ba5e34f0d095ad743216696a78957ab82f39580 100644 --- a/iotAmak/tool/schedulable.py +++ b/iotAmak/tool/schedulable.py @@ -20,7 +20,7 @@ class Schedulable(MqttClient): MqttClient.__init__(self, broker_ip, client_id) self.exit_bool: bool = False - self.subscribe("ping/exit", self.exit_procedure) + self.subscribe("ihm/exit", self.exit_procedure) self.nbr_cycle: int = 0 self.wait_delay: float = 0.01 diff --git a/iotAmak/tool/ssh_client.py b/iotAmak/tool/ssh_client.py index 149eaa91675de4a9582c8fc83da3712464bfb360..366b9264588d3eeb7e9547f775fe3b519d310672 100644 --- a/iotAmak/tool/ssh_client.py +++ b/iotAmak/tool/ssh_client.py @@ -26,7 +26,8 @@ class SSHClient: def __init__(self, clients: List[RemoteClient]): self.clients = clients - def run_cmd(self, client: int, cmd: list): + def run_cmd(self, client: int, cmd: list) -> list[str]: + ret = [] try: s = pxssh.pxssh() dest = self.clients[client] @@ -35,13 +36,15 @@ class SSHClient: for command in cmd: s.sendline(command.cmd) s.prompt() + ret.append(s.before.decode('utf-8')) if command.do_print: - print(command.prefix, s.before.decode('utf-8')) + print(command.prefix, ret[-1]) s.logout() except pxssh.ExceptionPxssh as e: print("pxssh failed on login.") print(e) + return ret def update(self, experiment_name): for client in self.clients: