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.ns3dceapplication import NS3BaseDceApplication
25 class NS3LinuxDceApplication(NS3BaseDceApplication):
26 _rtype = "ns3::LinuxDceApplication"
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 starttime = Attribute("StartTime",
45 "Time at which the application will start",
47 flags = Flags.Reserved | Flags.Construct)
50 stoptime = Attribute("StopTime",
51 "Time at which the application will stop",
53 flags = Flags.Reserved | Flags.Construct)
55 cls._register_attribute(sources)
56 cls._register_attribute(build)
57 cls._register_attribute(stoptime)
58 cls._register_attribute(starttime)
60 def _instantiate_object(self):
63 sources = self.get("sources")
65 self.info("Uploading sources %s " % sources)
66 scmd = self.simulation.upload_extra_sources(sources = sources)
70 build = self.get("build")
72 bcmd = self.simulation.build(build = build)
77 deploy_command = ";".join(command)
78 prefix = "%d_deploy" % self.guid
79 self.simulation.execute_deploy_command(deploy_command, prefix=prefix)