X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Flinux%2Fapplication.py;h=5adf1dc30d707c7dfb7134bbfa15fc5414e9d9af;hb=09b79152023e41ea1a864f854dfcbe2875c532e4;hp=d43742128f02209c5c421f157ac7c9cc21f7a5c3;hpb=04094716c3ff011e697e1e8871328a4a06aab83d;p=nepi.git diff --git a/src/nepi/resources/linux/application.py b/src/nepi/resources/linux/application.py index d4374212..5adf1dc3 100644 --- a/src/nepi/resources/linux/application.py +++ b/src/nepi/resources/linux/application.py @@ -63,14 +63,14 @@ class LinuxApplication(ResourceManager): The directory structure used by LinuxApplication RM at the Linux host is the following: - ${HOME}/nepi-usr --> Base directory for multi-experiment files + ${HOME}/.nepi/nepi-usr --> Base directory for multi-experiment files | ${LIB} |- /lib --> Base directory for libraries ${BIN} |- /bin --> Base directory for binary files ${SRC} |- /src --> Base directory for sources ${SHARE} |- /share --> Base directory for other files - ${HOME}/nepi-exp --> Base directory for single-experiment files + ${HOME}/.nepi/nepi-exp --> Base directory for single-experiment files | ${EXP_HOME} |- / --> Base directory for experiment exp-id | @@ -101,7 +101,7 @@ class LinuxApplication(ResourceManager): "Space-separated list of packages required to run the application", flags = Flags.Design) sources = Attribute("sources", - "Space-separated list of regular files to be uploaded to ${SRC} " + "semi-colon separated list of regular files to be uploaded to ${SRC} " "directory prior to building. Archives won't be expanded automatically. " "Sources are globally available for all experiments unless " "cleanHome is set to True (This will delete all sources). ", @@ -187,7 +187,7 @@ class LinuxApplication(ResourceManager): # timestamp of last state check of the application self._last_state_check = tnow() - + def log_message(self, msg): return " guid %d - host %s - %s " % (self.guid, self.node.get("hostname"), msg) @@ -274,6 +274,18 @@ class LinuxApplication(ResourceManager): return out def do_provision(self): + # take a snapshot of the system if user is root + # to assure cleanProcess kill every nepi process + if self.node.get("username") == 'root': + import pickle + procs = dict() + ps_aux = "ps aux |awk '{print $2,$11}'" + (out, err), proc = self.node.execute(ps_aux) + for line in out.strip().split("\n"): + parts = line.strip().split(" ") + procs[parts[0]] = parts[1] + pickle.dump(procs, open("/tmp/save.proc", "wb")) + # create run dir for application self.node.mkdir(self.run_home) @@ -358,15 +370,18 @@ class LinuxApplication(ResourceManager): stdout = "deploy_stdout", stderr = "deploy_stderr") - def upload_sources(self): + def upload_sources(self, src_dir = None): sources = self.get("sources") command = "" + if not src_dir: + src_dir = self.node.src_dir + if sources: self.info("Uploading sources ") - sources = sources.split(' ') + sources = map(str.strip, sources.split(";")) # Separate sources that should be downloaded from # the web, from sources that should be uploaded from @@ -379,15 +394,16 @@ class LinuxApplication(ResourceManager): command.append( " ( " # Check if the source already exists - " ls ${SRC}/%(basename)s " + " ls %(src_dir)s/%(basename)s " " || ( " # If source doesn't exist, download it and check # that it it downloaded ok - " wget -c --directory-prefix=${SRC} %(source)s && " - " ls ${SRC}/%(basename)s " + " wget -c --directory-prefix=%(src_dir)s %(source)s && " + " ls %(src_dir)s/%(basename)s " " ) ) " % { "basename": os.path.basename(source), - "source": source + "source": source, + "src_dir": src_dir }) command = " && ".join(command) @@ -396,8 +412,8 @@ class LinuxApplication(ResourceManager): command = self.replace_paths(command) if sources: - sources = ' '.join(sources) - self.node.upload(sources, self.node.src_dir, overwrite = False) + sources = ';'.join(sources) + self.node.upload(sources, src_dir, overwrite = False) return command @@ -438,8 +454,12 @@ class LinuxApplication(ResourceManager): self.info("Uploading stdin") # upload stdin file to ${SHARE_DIR} directory - basename = os.path.basename(stdin) - dst = os.path.join(self.node.share_dir, basename) + if os.path.isfile(stdin): + basename = os.path.basename(stdin) + dst = os.path.join(self.node.share_dir, basename) + else: + dst = os.path.join(self.app_home, "stdin") + self.node.upload(stdin, dst, overwrite = False, text = True) # create "stdin" symlink on ${APP_HOME} directory