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 version 2 as
7 # published by the Free Software Foundation;
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19 from nepi.execution.attribute import Attribute, Flags, Types
20 from nepi.execution.resource import clsinit_copy, ResourceState
21 from nepi.resources.ns3.ns3ccndceapplication import NS3BaseCCNDceApplication
24 class LinuxNS3CCNDceApplication(NS3BaseCCNDceApplication):
25 _rtype = "linux::ns3::dce::CCNApplication"
28 def _register_attributes(cls):
29 sources = Attribute("sources",
30 "Path to tar.gz file with sources for the application execute in DCE. "
31 "Sources will be uploaded to ${SRC} and it is the responsibility of "
32 "the build instructions (in the build attribute) to copy the compiled "
33 "binaries to the ${BIN_DCE} directory",
36 build = Attribute("build",
37 "Instructions to compile sources DCE-compatible way. "
38 "Note that sources will be uploaded to ${SRC} and the "
39 "build instructions are responsible for copying the "
40 "binaries to the ${BIN_DCE} directory. ",
43 depends = Attribute("depends",
44 "Space-separated list of packages required to run the application",
47 files = Attribute("files",
48 "Semi-colon separated list of 'key=value' pairs to set as "
49 "DCE files (AddFile). The key should be a path to a local file "
50 "and the key is the path to be set in DCE for that file" ,
53 stdinfile = Attribute("stdinFile",
54 "File to set as StdinFile. The value shoudl be either an empty "
55 "or a path to a local file ",
58 cls._register_attribute(sources)
59 cls._register_attribute(build)
60 cls._register_attribute(depends)
61 cls._register_attribute(files)
62 cls._register_attribute(stdinfile)
64 def _instantiate_object(self):
67 # Install package dependencies required to run the binary
68 depends = self.get("depends")
70 dcmd = self.simulation.install_dependencies(depends = depends)
74 # Upload sources to generate the binary
75 sources = self.get("sources")
77 scmd = self.simulation.upload_extra_sources(sources = sources)
81 # Upload instructions to build the binary
82 build = self.get("build")
84 bcmd = self.simulation.build(build = build)
88 # Upload CCN files (e.g. repo)
89 files = self.get("files")
92 for file in map(str.strip, files.split(";")):
93 localpath, dcepath = files.split("=")
94 upload.append(localpath)
96 sources = ";".join(upload)
97 fcmd = self.simulation.upload_extra_sources(sources = sources,
98 src_dir = self.simulation.app_home)
104 deploy_command = ";".join(command)
105 prefix = "%d_deploy" % self.guid
106 self.simulation.execute_deploy_command(deploy_command, prefix=prefix)