diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index fe60f4e029d587a1bd9644a8de1c15444cfa64d0..fef9351ec834eefdfa176ce46da27781928b61db 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -1749,11 +1749,22 @@ class Autosubmit: @staticmethod def restore_platforms(platform_to_test): - Log.result("Checking the connection to all platforms in use") + Log.info("Checking the connection to all platforms in use") + issues = "" for platform in platform_to_test: - platform.test_connection() - Log.result("[{1}] Connection successfull to host {0}", - platform.host, platform.name) + try: + platform.test_connection() + except BaseException: + issues += "\n[{1}] Connection Unsuccessful to host {0}".format(platform.host, platform.name) + continue + Log.result("[{1}] Connection successfull to host {0}",platform.host, platform.name) + if platform.check_remote_permissions(): + Log.result("[{1}] Correct user privileges for host {0}", platform.host, platform.name) + else: + issues += "\n[{0}] has configuration issues. Check the parameters that build the root_path are correct:{{scratch_dir/project/user}} = {{{3}/{2}/{1}}}".format(platform.name, platform.user, platform.project, platform.scratch) + if issues != "": + raise AutosubmitCritical("Issues while checking the connectivity of platforms.", 7010, issues) + @staticmethod def submit_ready_jobs(as_conf, job_list, platforms_to_test, packages_persistence, inspect=False, diff --git a/autosubmit/platforms/ecplatform.py b/autosubmit/platforms/ecplatform.py index 0441405d623856ab65b0ea8dd58c01415aefd9b6..b5bfdc8e7b0506a09eca83a08b8457530a208475 100644 --- a/autosubmit/platforms/ecplatform.py +++ b/autosubmit/platforms/ecplatform.py @@ -77,6 +77,8 @@ class EcPlatform(ParamikoPlatform): self.mkdir_cmd = ("ecaccess-file-mkdir " + self.host + ":" + self.scratch + "/" + self.project + "/" + self.user + "/" + self.expid + "; " + "ecaccess-file-mkdir " + self.host + ":" + self.remote_log_dir) + self.check_remote_permissions_cmd = "ecaccess-file-mkdir " + os.path.join(self.scratch,self.project,self.user,"_permission_checker_azxbyc") + self.check_remote_permissions_remove_cmd = "ecaccess-file-rmdir " + os.path.join(self.scratch,self.project,self.user,"_permission_checker_azxbyc") def get_checkhost_cmd(self): return self._checkhost_cmd @@ -137,6 +139,16 @@ class EcPlatform(ParamikoPlatform): :rtype: bool """ self.connected = True + + def check_remote_permissions(self): + try: + output = subprocess.check_output(self.check_remote_permissions_cmd, shell=True) + pass + output = subprocess.check_output(self.check_remote_permissions_remove_cmd, shell=True) + return True + except: + return False + def send_command(self, command, ignore_log=False): try: output = subprocess.check_output(command, shell=True) @@ -158,6 +170,30 @@ class EcPlatform(ParamikoPlatform): raise AutosubmitError('Could not send file {0} to {1}'.format(os.path.join(self.tmp_path, filename),os.path.join(self.get_files_path(), filename)),6005,e.message) return True + def move_file(self, src, dest, must_exist = False): + command = "ecaccess-file-move {0}:{1} {0}:{2}".format(self.host,os.path.join(self.remote_log_dir,src) , os.path.join(self.remote_log_dir,dest)) + try: + retries = 0 + sleeptime = 5 + process_ok = False + FNULL = open(os.devnull, 'w') + while not process_ok and retries < 5: + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=FNULL) + out, _ = process.communicate() + if 'No such file' in out or process.returncode != 0: + retries = retries + 1 + process_ok = False + sleeptime = sleeptime + 5 + sleep(sleeptime) + else: + process_ok = True + except Exception as e: + process_ok = False + if not process_ok: + Log.printlog("Log file don't recovered {0}".format(src), 6004) + return process_ok + + def get_file(self, filename, must_exist=True, relative_path='',ignore_log = False,wrapper_failed=False): local_path = os.path.join(self.tmp_path, relative_path) if not os.path.exists(local_path): diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index ff99edc21bedcfa7459e9b8b869e8186662074f9..c62d7145e488d3233ab9fe523d6ac2595e53a213 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -849,7 +849,13 @@ class ParamikoPlatform(Platform): return False except Exception as e: return False - + def check_remote_permissions(self): + try: + self._ftpChannel.mkdir(self.remote_log_dir+"_permission_checker_azxbyc") + self._ftpChannel.rmdir(self.remote_log_dir+"_permission_checker_azxbyc") + return True + except: + return False def check_remote_log_dir(self): """ Creates log dir on remote host