From: Alina Quereilhac Date: Wed, 3 Sep 2014 09:35:58 +0000 (+0200) Subject: Fixing nasty ugly bug in DCE ccndc RM. Fix: Adding missing HOME environment set to... X-Git-Tag: nepi-3.2.0~91 X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=commitdiff_plain;h=96ce55552a850e2fc155710a80c8453e0f201783 Fixing nasty ugly bug in DCE ccndc RM. Fix: Adding missing HOME environment set to /root when configuring DCE FibEntry --- diff --git a/examples/ccn_emu_live/dce.py b/examples/ccn_emu_live/dce.py index 06c34050..693293aa 100644 --- a/examples/ccn_emu_live/dce.py +++ b/examples/ccn_emu_live/dce.py @@ -45,6 +45,8 @@ def get_simulator(ec): ec.set(node, "hostname", "localhost") simu = ec.register_resource("LinuxNS3Simulation") + ec.set(simu, "enableDump", True) + ec.set(simu, "StopTime", STOP_TIME) ec.register_connection(simu, node) return simu @@ -79,7 +81,6 @@ def add_dce_ccnd(ec, nid): ec.set (ccnd, "debug", 7) ec.set (ccnd, "capacity", 50000) ec.set (ccnd, "StartTime", "1s") - ec.set (ccnd, "StopTime", STOP_TIME) ec.register_connection(ccnd, host) # Collector to retrieve ccnd log @@ -98,7 +99,6 @@ def add_dce_ccnr(ec, nid): ec.set (ccnr, "repoFile1", repofile) ec.set (ccnr, "stackSize", 1<<20) ec.set (ccnr, "StartTime", "2s") - ec.set (ccnr, "StopTime", STOP_TIME) ec.register_connection(ccnr, host) def add_dce_ccncat(ec, nid): @@ -110,7 +110,6 @@ def add_dce_ccncat(ec, nid): ec.set (ccncat, "contentName", content_name) ec.set (ccncat, "stackSize", 1<<20) ec.set (ccncat, "StartTime", "8s") - ec.set (ccncat, "StopTime", STOP_TIME) ec.register_connection(ccncat, host) def add_dce_fib_entry(ec, nid1, nid2): @@ -125,8 +124,7 @@ def add_dce_fib_entry(ec, nid1, nid2): ec.set (ccndc, "uri", "ccnx:/") ec.set (ccndc, "host", ip2) ec.set (ccndc, "stackSize", 1<<20) - ec.set (ccndc, "StartTime", "2s") - ec.set (ccndc, "StopTime", STOP_TIME) + ec.set (ccndc, "StartTime", "4s") ec.register_connection(ccndc, host1) def add_dce_net_iface(ec, nid1, nid2): @@ -172,7 +170,7 @@ def avg_interests(ec, run): # TODO: DUMP RESULTS TO FILE # TODO: DUMP GRAPH DELAYS! - f = open("/tmp/metric", "w+") + f = open("/tmp/metric", "a+") f.write("%.2f\n" % metric) f.close() print " METRIC", metric @@ -211,7 +209,7 @@ if __name__ == '__main__': #### Create NEPI Experiment Description with LINEAR topology ec = ExperimentController("dce_ccn", topo_type = TopologyType.LINEAR, - node_count = 4, + node_count = 2, assign_st = True, assign_ips = True, add_node_callback = add_dce_node, diff --git a/examples/linux/ns3/wifi_ping.py b/examples/linux/ns3/wifi_ping.py index 47bc335b..f0be5485 100644 --- a/examples/linux/ns3/wifi_ping.py +++ b/examples/linux/ns3/wifi_ping.py @@ -126,7 +126,7 @@ ec.set(node, "hostname", "localhost") simu = ec.register_resource("LinuxNS3Simulation") ec.set(simu, "verbose", True) ec.set(simu, "enableDump", True) -ec.set (simu, "stopTime", "22s") +ec.set (simu, "StopTime", "22s") ec.register_connection(simu, node) x = 30 diff --git a/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py index 8bf4ab13..226acf07 100644 --- a/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py +++ b/src/nepi/resources/linux/ns3/ccn/ns3ccnddceapplication.py @@ -145,15 +145,15 @@ class LinuxNS3DceCCND(LinuxNS3CCNDceApplication): " ecryptfs-utils-devel libxml2-devel automake gawk " " gcc gcc-c++ git pcre-devel make ") elif self.simulation.node.use_deb: - return ( " autoconf libssl-dev libexpat-dev libpcap-dev " + return ( " autoconf libssl-dev libexpat1-dev libpcap-dev " " libecryptfs0 libxml2-utils automake gawk gcc g++ " " git-core pkg-config libpcre3-dev make ") return "" - @property def _sources(self): - return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz" + #return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz" + return "http://www.ccnx.org/releases/ccnx-0.8.2.tar.gz" @property def _build(self): diff --git a/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py b/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py index 63e5d19a..61378256 100644 --- a/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py +++ b/src/nepi/resources/linux/ns3/ccn/ns3fibentrydceapplication.py @@ -53,11 +53,16 @@ class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication): "Peer host public IP used in network connection for this FIB entry. ", flags = Flags.Design) + home = Attribute("home", "Sets HOME environmental variable. ", + default = "/root", + flags = Flags.Design) + cls._register_attribute(uri) cls._register_attribute(protocol) cls._register_attribute(host) cls._register_attribute(port) cls._register_attribute(ip) + cls._register_attribute(home) def _instantiate_object(self): if not self.get("binary"): @@ -66,8 +71,22 @@ class LinuxNS3DceFIBEntry(LinuxNS3CCNDceApplication): if not self.get("arguments"): self.set("arguments", self._arguments) + if not self.get("environment"): + self.set("environment", self._environment) + super(LinuxNS3DceFIBEntry, self)._instantiate_object() + @property + def _environment(self): + envs = dict({ + "home": "HOME", + }) + + env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))), + [k for k in envs.keys() if self.get(k)])) + + return env + @property def _arguments(self): args = ["-v", "add"] diff --git a/src/nepi/resources/linux/ns3/ns3simulation.py b/src/nepi/resources/linux/ns3/ns3simulation.py index dae024f3..63d8d375 100644 --- a/src/nepi/resources/linux/ns3/ns3simulation.py +++ b/src/nepi/resources/linux/ns3/ns3simulation.py @@ -114,7 +114,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): type = Types.Bool, flags = Flags.Design) - stoptime = Attribute("stopTime", + stoptime = Attribute("StopTime", "Time at which the simulation will stop", flags = Flags.Design) @@ -306,6 +306,10 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): if self.get("populateRoutingTables") == True: self.invoke(IPV4_GLOBAL_ROUTING_HELPER_UUID, "PopulateRoutingTables") + time = self.get("StopTime") + if time: + self._client.stop(time=time) + self._client.start() self.set_started() @@ -319,11 +323,8 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation): """ if self.state == ResourceState.STARTED: - time = None - if self.get("stopTime"): - time = self.get("stopTime") - - self._client.stop(time=time) + if not self.get("StopTime"): + self._client.stop() self.set_stopped() def do_release(self): diff --git a/src/nepi/resources/ns3/ns3base.py b/src/nepi/resources/ns3/ns3base.py index 455e546f..ef345ff1 100644 --- a/src/nepi/resources/ns3/ns3base.py +++ b/src/nepi/resources/ns3/ns3base.py @@ -51,7 +51,7 @@ class NS3Base(ResourceManager): if not self._node: from nepi.resources.ns3.ns3node import NS3BaseNode nodes = self.get_connected(NS3BaseNode.get_rtype()) - if nodes: self._nodes[0] + if nodes: self._node = nodes[0] return self._node diff --git a/test/resources/linux/ns3/ccn/ns3dceccn.py b/test/resources/linux/ns3/ccn/ns3dceccn.py index f215fa35..78d517e6 100755 --- a/test/resources/linux/ns3/ccn/ns3dceccn.py +++ b/test/resources/linux/ns3/ccn/ns3dceccn.py @@ -81,9 +81,9 @@ class LinuxNS3CCNDceApplicationTest(unittest.TestCase): #ec.set(node, "cleanHome", True) simu = ec.register_resource("LinuxNS3Simulation") - ec.set(simu, "verbose", True) - ec.set(simu, "buildMode", "debug") - ec.set(simu, "nsLog", "DceApplication") + #ec.set(simu, "verbose", True) + #ec.set(simu, "buildMode", "debug") + #ec.set(simu, "nsLog", "DceApplication") ec.register_connection(simu, node) nsnode1 = add_ns3_node(ec, simu)