Added trace netref to lookup for trace[trace_id].[attribute]
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 19 Aug 2011 15:33:32 +0000 (17:33 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Fri, 19 Aug 2011 15:33:32 +0000 (17:33 +0200)
src/nepi/core/execute.py
src/nepi/core/testbed_impl.py
src/nepi/testbeds/netns/execute.py
src/nepi/testbeds/ns3/execute.py
src/nepi/testbeds/planetlab/application.py
src/nepi/testbeds/planetlab/execute.py
src/nepi/testbeds/planetlab/metadata.py

index ede295e..2af29f1 100644 (file)
@@ -15,7 +15,7 @@ import functools
 import time
 import logging
 
-ATTRIBUTE_PATTERN_BASE = re.compile(r"\{#\[(?P<label>[-a-zA-Z0-9._]*)\](?P<expr>(?P<component>\.addr\[[0-9]+\]|\.route\[[0-9]+\]|\.trace\[[0-9]+\])?.\[(?P<attribute>[-a-zA-Z0-9._]*)\])#}")
+ATTRIBUTE_PATTERN_BASE = re.compile(r"\{#\[(?P<label>[-a-zA-Z0-9._]*)\](?P<expr>(?P<component>\.addr\[[0-9]+\]|\.route\[[0-9]+\]|\.trace\[[-a-zA-Z0-9._]+\])?.\[(?P<attribute>[-a-zA-Z0-9._]*)\])#}")
 ATTRIBUTE_PATTERN_GUID_SUB = r"{#[%(guid)s]%(expr)s#}"
 COMPONENT_PATTERN = re.compile(r"(?P<kind>[a-z]*)\[(?P<index>.*)\]")
 
@@ -710,7 +710,7 @@ class ExperimentController(object):
                 testbed.get_route(guid, int(index), name),
         'trace' :
             lambda testbed, guid, index, name: 
-                testbed.trace(guid, index, name),
+                testbed.trace(guid, index, attribute = name),
         '' : 
             lambda testbed, guid, index, name: 
                 testbed.get(guid, name),
@@ -1048,4 +1048,43 @@ class ExperimentController(object):
                     elem_cross_data[attr_name] = _undefer(attr_value)
         
         return cross_data
-    
+
+    """
+class ExperimentSuite(object):
+    def __init__(self, experiment_xml, access_config, nexp,
+            duration, wait_guids):
+        self._experiment_xml = experiment_xml
+        self._access_config = access_config
+        self._experiments = dict()
+        self._nexp = nexp
+        self._duration = duration
+        self._wait_guids = wait_guids
+        self._curr = None
+
+
+    def _run_one_exp(self):
+        access_config = proxy.AccessConfiguration()
+        controller = proxy.create_experiment_controller(self._experiment_xml,
+                access_config)
+        self._experiments[self._curr] = controller
+        controller.start()
+        started_at = time.time()
+        if self._wait_guids:
+            while not controller.is_finished(92) and \
+                    not controller.is_finished(108) and \
+                    not controller.is_finished(126) and \
+                    not controller.is_finished(84):
+                time.sleep(0.5)
+        # add results to instructions
+        controller.stop()
+        #download results!!
+        controller.shutdown()
+    """
+
+
+
+
+
+
+
+
index 57afb2c..d94b6f8 100644 (file)
@@ -468,6 +468,8 @@ class TestbedController(execute.TestbedController):
             fd.close()
         elif attribute == 'path':
             content = self.trace_filepath(guid, trace_id)
+        elif attribute == 'filename':
+            content = self.trace_filename(guid, trace_id)
         else:
             content = None
         return content
@@ -493,6 +495,13 @@ class TestbedController(execute.TestbedController):
         """
         raise NotImplementedError
 
+    def trace_filename(self, guid, trace_id):
+        """
+        Return a trace's file name, for TestbedController's default 
+        implementation of trace()
+        """
+        raise NotImplementedError
+
     #shutdown: NotImplementedError
 
     def get_connected(self, guid, connector_type_name, 
index f9e330f..e06295f 100644 (file)
@@ -127,6 +127,11 @@ class TestbedController(testbed_impl.TestbedController):
             (trace, filename) = self._traces[guid][trace_id]
         return os.path.join(self.home_directory, filename)
 
+    def trace_filename(self, guid, trace_id):
+        (trace, filename) = self._traces[guid][trace_id]
+        return filename
+
+
     def follow_trace(self, guid, trace_id, trace, filename):
         if not guid in self._traces:
             self._traces[guid] = dict()
index f94a063..928002f 100644 (file)
@@ -152,6 +152,9 @@ class TestbedController(testbed_impl.TestbedController):
         filename = self._traces[guid][trace_id]
         return os.path.join(self.home_directory, filename)
 
+    def trace_filename(self, guid, trace_id):
+        return self._traces[guid][trace_id]
+
     def follow_trace(self, guid, trace_id, filename):
         if not guid in self._traces:
             self._traces[guid] = dict()
index 27c56f3..0cde967 100644 (file)
@@ -111,7 +111,12 @@ class Dependency(object):
             tracefile = None
         
         return tracefile
-    
+
+    def remote_trace_name(self, whichtrace):
+        if whichtrace in self.TRACES:
+            return whichtrace
+        return None
+
     def sync_trace(self, local_dir, whichtrace):
         tracefile = self.remote_trace_path(whichtrace)
         if not tracefile:
@@ -581,7 +586,7 @@ class Application(Dependency):
     It adds the output of that command as traces.
     """
     
-    TRACES = ('stdout','stderr','buildlog')
+    TRACES = ('stdout','stderr','buildlog', 'output')
     
     def __init__(self, api=None):
         super(Application,self).__init__(api)
@@ -593,6 +598,7 @@ class Application(Dependency):
         self.stdin = None
         self.stdout = None
         self.stderr = None
+        self.output = None
         
         # Those are filled when the app is started
         #   Having both pid and ppid makes it harder
index 427a1b3..292b92e 100644 (file)
@@ -556,6 +556,8 @@ class TestbedController(testbed_impl.TestbedController):
                 content = None
         elif attribute == 'path':
             content = app.remote_trace_path(trace_id)
+        elif attribute == 'name':
+            content = app.remote_trace_name(trace_id)
         else:
             content = None
         return content
index c17ba42..9009774 100644 (file)
@@ -331,6 +331,7 @@ def start_application(testbed_instance, guid):
     app.stdout = "stdout" in traces
     app.stderr = "stderr" in traces
     app.buildlog = "buildlog" in traces
+    app.outout = "output" in traces
     
     app.start()
 
@@ -1164,6 +1165,10 @@ traces = dict({
                 "name": "pcap",
                 "help": "PCAP trace of all packets going through the interface",
               }),
+    "output": dict({
+                "name": "output",
+                "help": "Extra output trace for applications. When activated this trace can be referenced with wildcard a reference from an Application command line. Ex: command: 'tcpdump -w {#[elemet-label].trace[trace-id].[name|path]#}' ",
+              }),
     })
 
 create_order = [ INTERNET, NODE, NODEIFACE, TUNFILTER, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
@@ -1309,7 +1314,7 @@ factories_info = dict({
                                "depends", "build-depends", "build", "install",
                                "sources", "rpm-fusion" ],
             "connector_types": ["node"],
-            "traces": ["stdout", "stderr", "buildlog"],
+            "traces": ["stdout", "stderr", "buildlog", "output"],
             "tags": [tags.APPLICATION],
         }),
     DEPENDENCY: dict({