+@clsinit
+class LinuxApplication(ResourceManager):
+ _rtype = "LinuxApplication"
+
+ @classmethod
+ def _register_attributes(cls):
+ command = Attribute("command", "Command to execute",
+ flags = Flags.ReadOnly)
+ env = Attribute("env", "Environment variables string for command execution",
+ flags = Flags.ReadOnly)
+ sudo = Attribute("sudo", "Run with root privileges",
+ flags = Flags.ReadOnly)
+ depends = Attribute("depends",
+ "Space-separated list of packages required to run the application",
+ flags = Flags.ReadOnly)
+ sources = Attribute("sources",
+ "Space-separated list of regular files to be deployed in the working "
+ "path prior to building. Archives won't be expanded automatically.",
+ flags = Flags.ReadOnly)
+ build = Attribute("build",
+ "Build commands to execute after deploying the sources. "
+ "Sources will be in the ${SOURCES} folder. "
+ "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
+ "Try to make the commands return with a nonzero exit code on error.\n"
+ "Also, do not install any programs here, use the 'install' attribute. This will "
+ "help keep the built files constrained to the build folder (which may "
+ "not be the home folder), and will result in faster deployment. Also, "
+ "make sure to clean up temporary files, to reduce bandwidth usage between "
+ "nodes when transferring built packages.",
+ flags = Flags.ReadOnly)
+ install = Attribute("install",
+ "Commands to transfer built files to their final destinations. "
+ "Sources will be in the initial working folder, and a special "
+ "tag ${SOURCES} can be used to reference the experiment's "
+ "home folder (where the application commands will run).\n"
+ "ALL sources and targets needed for execution must be copied there, "
+ "if building has been enabled.\n"
+ "That is, 'slave' nodes will not automatically get any source files. "
+ "'slave' nodes don't get build dependencies either, so if you need "
+ "make and other tools to install, be sure to provide them as "
+ "actual dependencies instead.",
+ flags = Flags.ReadOnly)
+ stdin = Attribute("stdin", "Standard input", flags = Flags.ReadOnly)
+ stdout = Attribute("stdout", "Standard output", flags = Flags.ReadOnly)
+ stderr = Attribute("stderr", "Standard error", flags = Flags.ReadOnly)
+
+ tear_down = Attribute("tearDown", "Bash script to be executed before
+ releasing the resource", flags = Flags.ReadOnly)
+
+ cls._register_attribute(command)
+ cls._register_attribute(env)
+ cls._register_attribute(sudo)
+ cls._register_attribute(depends)
+ cls._register_attribute(sources)
+ cls._register_attribute(build)
+ cls._register_attribute(install)
+ cls._register_attribute(stdin)
+ cls._register_attribute(stdout)
+ cls._register_attribute(stderr)
+ cls._register_attribute(tear_down)
+
+ def __init__(self, ec, guid):
+ super(LinuxApplication, self).__init__(ec, guid)
+ self._pid = None
+ self._ppid = None
+ self._home = "${HOME}/app-%s" % self.box.guid