ns-3 CCN tests
[nepi.git] / src / nepi / resources / linux / ns3 / ns3dceapplication.py
index bf1a6e3..ca32b6f 100644 (file)
@@ -41,12 +41,26 @@ class NS3LinuxDceApplication(NS3BaseDceApplication):
                 "binaries to the ${BIN_DCE} directory. ",
                 flags = Flags.Design)
 
+        depends = Attribute("depends", 
+                "Space-separated list of packages required to run the application",
+                flags = Flags.Design)
+
+        files = Attribute("files", 
+                "Semi-colon separated list of 'key=value' pairs to set as "
+                "DCE files (AddFile). The key should be a path to a local file "
+                "and the key is the path to be set in DCE for that file" ,
+                flags = Flags.Design)
+
+        stdinfile = Attribute("stdinFile", 
+                "File to set as StdinFile. The value shoudl be either an empty "
+                "or a path to a local file ",
+                flags = Flags.Design)
+
         starttime = Attribute("StartTime",
             "Time at which the application will start",
             default = "+0.0ns",  
             flags = Flags.Reserved | Flags.Construct)
 
-
         stoptime = Attribute("StopTime",
             "Time at which the application will stop",
             default = "+0.0ns",  
@@ -54,19 +68,53 @@ class NS3LinuxDceApplication(NS3BaseDceApplication):
 
         cls._register_attribute(sources)
         cls._register_attribute(build)
+        cls._register_attribute(depends)
+        cls._register_attribute(files)
         cls._register_attribute(stoptime)
         cls._register_attribute(starttime)
+        cls._register_attribute(stdinfile)
 
     def _instantiate_object(self):
         command = []
-        
+
+        # Install package dependencies required to run the binary 
+        depends = self.get("depends")
+        if depends:
+            dcmd = self.simulation.install_dependencies(depends = depends)
+            if dcmd:
+                command.append(dcmd)
+       
+        # Upload sources to generate the binary
         sources = self.get("sources")
         if sources:
-            self.info("Uploading sources %s " % sources)
             scmd = self.simulation.upload_extra_sources(sources = sources)
             if scmd:
                 command.append(scmd)
                 
+        # Upload files to the remote machine. These files will 
+        # be added to the DceApplication by invoking dce.AddFile()
+        files = self.get("files") or ""
+        if files:
+            upfiles = []
+            for files in map(str.strip, files.split(";")):
+                localpath, dcepath = env.split("=")
+                upfiles.append(localpath)
+
+            if upfiles:
+                fcmd = self.siumlation.upload_files(files = upfiles)
+                if fcmd:
+                    command.append(fcmd)
+
+        # Upload files to the remote machine. These files will 
+        # be added to the DceApplication by invoking dce.AddFile()
+        stdinfile = self.get("stdinFile")
+        if stdinfile and stdinfile != "":
+            stdincmd = self.siumlation.upload_files(files = stdinfile)
+            if stdincmd:
+                command.append(stdincmd)
+
+
+        # Upload instructions to build the binary
         build = self.get("build")
         if build:
             bcmd = self.simulation.build(build = build)