2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_delay
22 from nepi.resources.ns3.ns3ccndceapplication import NS3BaseCCNDceApplication
25 class LinuxNS3CCNDceApplication(NS3BaseCCNDceApplication):
26 _rtype = "ns3::LinuxCCNDceApplication"
29 def _register_attributes(cls):
30 sources = Attribute("sources",
31 "Path to tar.gz file with sources for the application execute in DCE. "
32 "Sources will be uploaded to ${SRC} and it is the responsibility of "
33 "the build instructions (in the build attribute) to copy the compiled "
34 "binaries to the ${BIN_DCE} directory",
37 build = Attribute("build",
38 "Instructions to compile sources DCE-compatible way. "
39 "Note that sources will be uploaded to ${SRC} and the "
40 "build instructions are responsible for copying the "
41 "binaries to the ${BIN_DCE} directory. ",
44 depends = Attribute("depends",
45 "Space-separated list of packages required to run the application",
48 files = Attribute("files",
49 "Semi-colon separated list of 'key=value' pairs to set as "
50 "DCE files (AddFile). The key should be a path to a local file "
51 "and the key is the path to be set in DCE for that file" ,
54 stdinfile = Attribute("stdinFile",
55 "File to set as StdinFile. The value shoudl be either an empty "
56 "or a path to a local file ",
59 cls._register_attribute(sources)
60 cls._register_attribute(build)
61 cls._register_attribute(depends)
62 cls._register_attribute(files)
63 cls._register_attribute(stdinfile)
65 def _instantiate_object(self):
68 # Install package dependencies required to run the binary
69 depends = self.get("depends")
71 dcmd = self.simulation.install_dependencies(depends = depends)
75 # Upload sources to generate the binary
76 sources = self.get("sources")
78 scmd = self.simulation.upload_extra_sources(sources = sources)
82 # Upload instructions to build the binary
83 build = self.get("build")
85 bcmd = self.simulation.build(build = build)
89 # Upload CCN files (e.g. repo)
90 files = self.get("files")
93 for file in map(str.strip, files.split(";")):
94 localpath, dcepath = files.split("=")
95 upload.append(localpath)
97 sources = ";".join(upload)
98 fcmd = self.simulation.upload_extra_sources(sources = sources,
99 src_dir = self.simulation.app_home)
105 deploy_command = ";".join(command)
106 prefix = "%d_deploy" % self.guid
107 self.simulation.execute_deploy_command(deploy_command, prefix=prefix)