X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Flinux%2Fns3%2Fns3simulation.py;h=0f94c4cb93a7f5d273e85f5b4849ee2a737977bf;hb=64fdda7bf665776fb043b355e989502e6c367a0c;hp=596ff02e3c837cd89650dd6db4a083c137e0ea56;hpb=4ddc9a65d2ca15a45ffbb3840a6a927b13936fbf;p=nepi.git diff --git a/src/nepi/resources/linux/ns3/ns3simulation.py b/src/nepi/resources/linux/ns3/ns3simulation.py index 596ff02e..0f94c4cb 100644 --- a/src/nepi/resources/linux/ns3/ns3simulation.py +++ b/src/nepi/resources/linux/ns3/ns3simulation.py @@ -20,7 +20,7 @@ from nepi.execution.attribute import Attribute, Flags, Types from nepi.execution.trace import Trace, TraceAttr from nepi.execution.resource import ResourceManager, clsinit_copy, \ - ResourceState, reschedule_delay + ResourceState, ResourceFactory, reschedule_delay from nepi.resources.linux.application import LinuxApplication from nepi.util.timefuncs import tnow, tdiffsec from nepi.resources.ns3.ns3simulation import NS3Simulation @@ -76,6 +76,13 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): type = Types.Bool, flags = Flags.Design) + enable_dump = Attribute("enableDump", + "Enable dumping the remote executed ns-3 commands to a script " + "in order to later reproduce and debug the experiment", + type = Types.Bool, + default = False, + flags = Flags.Design) + build_mode = Attribute("buildMode", "Mode used to build ns-3 with waf. One if: debug, release, oprimized ", default = "optimized", @@ -89,12 +96,6 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): default = "ns-3-dev", flags = Flags.Design) - enable_dce = Attribute("enableDCE", - "Install DCE source code", - default = False, - type = Types.Bool, - flags = Flags.Design) - pybindgen_version = Attribute("pybindgenVersion", "Version of pybindgen to install from bazar repo", #default = "864", @@ -111,12 +112,12 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): cls._register_attribute(sched_type) cls._register_attribute(check_sum) cls._register_attribute(ns_log) + cls._register_attribute(enable_dump) cls._register_attribute(verbose) cls._register_attribute(build_mode) cls._register_attribute(ns3_version) cls._register_attribute(pybindgen_version) cls._register_attribute(populate_routing_tables) - cls._register_attribute(enable_dce) def __init__(self, ec, guid): LinuxApplication.__init__(self, ec, guid) @@ -127,6 +128,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): self._socket_name = "ns3-%s.sock" % os.urandom(4).encode('hex') self._dce_manager_helper_uuid = None self._dce_application_helper_uuid = None + self._enable_dce = None @property def socket_name(self): @@ -156,6 +158,14 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): os.path.join(self.node.src_dir, "ns3wrapper", "ns3wrapper.py"), overwrite = False) + # upload ns3 wrapper debug python script + ns3_wrapper_debug = os.path.join(os.path.dirname(__file__), "..", "..", "ns3", + "ns3wrapper_debug.py") + + self.node.upload(ns3_wrapper_debug, + os.path.join(self.node.src_dir, "ns3wrapper", "ns3wrapper_debug.py"), + overwrite = False) + # upload ns3_server python script ns3_server = os.path.join(os.path.dirname(__file__), "..", "..", "ns3", "ns3server.py") @@ -277,7 +287,10 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): self._client.start() - # Wait until the Simulation is actually started... + """ + # XXX: IS THIS REALLY NEEDED?? + # Wait until the Simulation is actually started... + is_running = False for i in xrange(1000): is_running = self.invoke(SIMULATOR_UUID, "isRunning") @@ -291,6 +304,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): msg = " Simulation did not start" self.error(msg) raise RuntimeError + """ self.set_started() else: @@ -319,6 +333,22 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): super(LinuxApplication, self).do_release() + @property + def enable_dce(self): + if self._enable_dce is None: + from nepi.resources.ns3.ns3dceapplication import NS3BaseDceApplication + rclass = ResourceFactory.get_resource_type( + NS3BaseDceApplication.get_rtype()) + + self._enable_dce = False + for guid in self.ec.resources: + rm = self.ec.get_resource(guid) + if isinstance(rm, rclass): + self._enable_dce = True + break + + return self._enable_dce + @property def _start_command(self): command = [] @@ -332,6 +362,9 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): if ns_log: command.append("-L '%s'" % ns_log) + if self.get("enableDump"): + command.append("-D") + if self.get("verbose"): command.append("-v") @@ -403,7 +436,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): } clone_dce_cmd = " echo 'DCE will not be built' " - if self.get("enableDCE"): + if self.enable_dce: clone_dce_cmd = ( # DCE installation # Test if dce is alredy installed @@ -489,7 +522,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): @property def _install(self): install_dce_cmd = " echo 'DCE will not be installed' " - if self.get("enableDCE"): + if self.enable_dce: install_dce_cmd = ( " ( " " ((test -d %(ns3_build_home)s/bin_dce ) && "