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.ns3dceapplication import NS3BaseDceApplication
24 class LinuxNS3DceApplication(NS3BaseDceApplication):
25 _rtype = "linux::ns3::dce::Application"
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 cls._register_attribute(sources)
48 cls._register_attribute(build)
49 cls._register_attribute(depends)
51 def _instantiate_object(self):
54 # Install package dependencies required to run the binary
55 depends = self.get("depends")
57 dcmd = self.simulation.install_dependencies(depends = depends)
61 # Upload sources to generate the binary
62 sources = self.get("sources")
64 scmd = self.simulation.upload_extra_sources(sources = sources)
68 # Upload instructions to build the binary
69 build = self.get("build")
71 bcmd = self.simulation.build(build = build)
76 deploy_command = ";".join(command)
77 prefix = "%d_deploy" % self.guid
78 self.simulation.execute_deploy_command(deploy_command, prefix=prefix)