From: Alina Quereilhac Date: Fri, 19 Jul 2013 17:20:55 +0000 (-0700) Subject: Adding scope to CCN content RM X-Git-Tag: nepi-3.0.0~67 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=1b2cd32d38b14ee42f944a43e0596f7f277655fe;p=nepi.git Adding scope to CCN content RM --- diff --git a/src/nepi/resources/linux/ccn/ccncontent.py b/src/nepi/resources/linux/ccn/ccncontent.py index 62bc55d4..35d15635 100644 --- a/src/nepi/resources/linux/ccn/ccncontent.py +++ b/src/nepi/resources/linux/ccn/ccncontent.py @@ -40,8 +40,17 @@ class LinuxCCNContent(LinuxApplication): "The content to publish. It can be a path to a file or plain text ", flags = Flags.ExecReadOnly) + scope = Attribute("scope", + "Use the given scope on the start-write request (if -r specified). " + "scope can be 1 (local), 2 (neighborhood), or 3 (unlimited). " + "Note that a scope of 3 is encoded as the absence of any scope in the interest. ", + type = Types.Integer, + default = 1, + flags = Flags.ExecReadOnly) + cls._register_attribute(content_name) cls._register_attribute(content) + cls._register_attribute(scope) def __init__(self, ec, guid): super(LinuxCCNContent, self).__init__(ec, guid) @@ -138,8 +147,13 @@ class LinuxCCNContent(LinuxApplication): @property def _start_command(self): - return "ccnseqwriter -r %s < %s" % (self.get("contentName"), - os.path.join(self.app_home, 'stdin')) + command = ["ccnseqwriter"] + command.append("-r %s" % self.get("contentName")) + command.append("-s %d" % self.get("scope")) + command.append("< %s" % os.path.join(self.app_home, 'stdin')) + + command = " ".join(command) + return command @property def _environment(self): diff --git a/src/nepi/resources/linux/ccn/fibentry.py b/src/nepi/resources/linux/ccn/fibentry.py index 91e58dec..0e4a6875 100644 --- a/src/nepi/resources/linux/ccn/fibentry.py +++ b/src/nepi/resources/linux/ccn/fibentry.py @@ -66,17 +66,20 @@ class LinuxFIBEntry(LinuxApplication): @classmethod def _register_traces(cls): - ping = Trace("ping", "Continuous ping to the peer end") - mtr = Trace("mtr", "Continuous mtr to the peer end") + ping = Trace("ping", "Ping to the peer end") + mtr = Trace("mtr", "Mtr to the peer end") + traceroute = Trace("traceroute", "Tracerout to the peer end") cls._register_trace(ping) cls._register_trace(mtr) + cls._register_trace(traceroute) def __init__(self, ec, guid): super(LinuxFIBEntry, self).__init__(ec, guid) self._home = "fib-%s" % self.guid self._ping = None self._mtr = None + self._traceroute = None @property def ccnd(self): @@ -94,6 +97,8 @@ class LinuxFIBEntry(LinuxApplication): return self.ec.trace(self._ping, "stdout", attr, block, offset) if name == "mtr": return self.ec.trace(self._mtr, "stdout", attr, block, offset) + if name == "traceroute": + return self.ec.trace(self._traceroute, "stdout", attr, block, offset) return super(LinuxFIBEntry, self).trace(name, attr, block, offset) @@ -160,20 +165,32 @@ class LinuxFIBEntry(LinuxApplication): self.ec.deploy(group=[self._ping]) if self.trace_enabled("mtr"): - self.info("Configuring TRACE trace") + self.info("Configuring MTR trace") self._mtr = self.ec.register_resource("LinuxMtr") self.ec.set(self._mtr, "noDns", True) self.ec.set(self._mtr, "printTimestamp", True) self.ec.set(self._mtr, "continuous", True) self.ec.set(self._mtr, "target", self.get("host")) self.ec.register_connection(self._mtr, self.node.guid) - self.ec.deploy(group=[self._mtr]) # force waiting until mtr is READY before we starting the FIB self.ec.register_condition(self.guid, ResourceAction.START, self._mtr, ResourceState.READY) # schedule mtr deploy self.ec.deploy(group=[self._mtr]) - + + if self.trace_enabled("traceroute"): + self.info("Configuring TRACEROUTE trace") + self._traceroute = self.ec.register_resource("LinuxTraceroute") + self.ec.set(self._traceroute, "printTimestamp", True) + self.ec.set(self._traceroute, "continuous", True) + self.ec.set(self._traceroute, "target", self.get("host")) + self.ec.register_connection(self._traceroute, self.node.guid) + # force waiting until mtr is READY before we starting the FIB + self.ec.register_condition(self.guid, ResourceAction.START, + self._traceroute, ResourceState.READY) + # schedule mtr deploy + self.ec.deploy(group=[self._traceroute]) + def start(self): if self._state in [ResourceState.READY, ResourceState.STARTED]: command = self.get("command") diff --git a/src/nepi/resources/linux/traceroute.py b/src/nepi/resources/linux/traceroute.py index 80ca3b93..ea42514a 100644 --- a/src/nepi/resources/linux/traceroute.py +++ b/src/nepi/resources/linux/traceroute.py @@ -73,7 +73,7 @@ class LinuxTraceroute(LinuxApplication): args.append("traceroute") args.append(self.get("target")) if self.get("continuous") == True: - args.append("; done ") + args.append("; sleep 5 ; done ") command = " ".join(args)