Commit b18e2c6721e4b0aeabfe99e095aab68f645065f8
1 parent
48476f39
Exists in
dev
Remove go to parent folder to get agent protocol
Showing
1 changed file
with
14 additions
and
4 deletions
Show diff stats
src/core/pyros_django/majordome/agent/A_SST.py
... | ... | @@ -149,7 +149,7 @@ class A_SST(Agent): |
149 | 149 | agent_informations = obs_config.get_agent_information(obs_config.unit_name,agent) |
150 | 150 | protocol = agent_informations.get("protocol") |
151 | 151 | if protocol: |
152 | - protocol_folder_abs_path = os.path.join(os.environ.get("PATH_TO_OBSCONF_FOLDER"), "..", "agents") | |
152 | + protocol_folder_abs_path = os.path.join(os.environ.get("PATH_TO_OBSCONF_FOLDER"), "agents") | |
153 | 153 | protocol_script_name = protocol |
154 | 154 | protocol = os.path.join(protocol_folder_abs_path, protocol_script_name) |
155 | 155 | else: |
... | ... | @@ -159,9 +159,11 @@ class A_SST(Agent): |
159 | 159 | if general_agent_name[0] in agent: |
160 | 160 | protocol_folder_abs_path = os.path.abspath(os.path.dirname(general_agent)) |
161 | 161 | protocol_script_name = os.path.basename(general_agent) |
162 | + print(protocol_folder_abs_path) | |
163 | + print(protocol_script_name) | |
162 | 164 | protocol = os.path.join(protocol_folder_abs_path, protocol_script_name) |
163 | 165 | break |
164 | - | |
166 | + print(protocol) | |
165 | 167 | if os.path.exists(protocol): |
166 | 168 | cmd = self.VENV_PYTHON +" "+ protocol_folder_abs_path + os.sep + protocol_script_name |
167 | 169 | if not agent in self.agent_in_mode_test: |
... | ... | @@ -204,7 +206,7 @@ class A_SST(Agent): |
204 | 206 | protocol_script_name = "" |
205 | 207 | protocol_folder_abs_path = "" |
206 | 208 | if protocol and is_active == True: |
207 | - protocol_folder_abs_path = os.path.join(os.environ.get("PATH_TO_OBSCONF_FOLDER"), "..", "agents") | |
209 | + protocol_folder_abs_path = os.path.join(os.environ.get("PATH_TO_OBSCONF_FOLDER"), "agents") | |
208 | 210 | protocol_script_name = protocol |
209 | 211 | protocol = os.path.join(protocol_folder_abs_path, protocol_script_name) |
210 | 212 | else: |
... | ... | @@ -217,7 +219,7 @@ class A_SST(Agent): |
217 | 219 | protocol_script_name = os.path.basename(general_agent) |
218 | 220 | protocol = os.path.join(protocol_folder_abs_path, protocol_script_name) |
219 | 221 | break |
220 | - if os.path.exists(protocol): | |
222 | + if protocol and os.path.exists(protocol): | |
221 | 223 | |
222 | 224 | cmd = self.VENV_PYTHON +" "+ protocol |
223 | 225 | if not agent in self.agent_in_mode_test: |
... | ... | @@ -393,9 +395,17 @@ class A_SST(Agent): |
393 | 395 | self.send_cmd_to(self.name,"do_restart_agent", agent) |
394 | 396 | |
395 | 397 | log.info("Check status of process") |
398 | + nb_stopped_agent = 0 | |
396 | 399 | for agent in self.subprocess_dict: |
397 | 400 | proc = self.subprocess_dict.get(agent).get("process") |
398 | 401 | log.info(f"{agent} poll result is {proc.poll()}") |
402 | + if proc.poll() is not None: | |
403 | + nb_stopped_agent +=1 | |
404 | + if self.TEST_MODE: | |
405 | + if nb_stopped_agent == len(self.subprocess_dict.keys()): | |
406 | + print("All launched agents have finished their test modes, A_SST will stop") | |
407 | + self.do_stop("asap") | |
408 | + | |
399 | 409 | |
400 | 410 | |
401 | 411 | ... | ... |