Added routes to OMF nodes
[nepi.git] / src / nepi / core / testbed_impl.py
index fd947c0..d27588d 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 from nepi.core import execute
@@ -151,12 +150,14 @@ class TestbedController(execute.TestbedController):
             self._add_address[guid] = list()
         self._add_address[guid].append((address, netprefix, broadcast))
 
-    def defer_add_route(self, guid, destination, netprefix, nexthop, metric = 0):
+    def defer_add_route(self, guid, destination, netprefix, nexthop, 
+            metric = 0, device = None):
         self._validate_guid(guid)
         self._validate_allow_routes(guid)
         if not guid in self._add_route:
             self._add_route[guid] = list()
-        self._add_route[guid].append((destination, netprefix, nexthop, metric)) 
+        self._add_route[guid].append((destination, netprefix, nexthop, 
+            metric, device)) 
 
     def do_setup(self):
         self._root_directory = self._attributes.\
@@ -250,15 +251,15 @@ class TestbedController(execute.TestbedController):
 
             # perform the action on all elements, in parallel if so requested
             if runner:
-                logger.debug("Starting parallel %s", action)
+                logger.debug("TestbedController: Starting parallel %s", action)
                 runner.start()
 
             for guid in guids[factory_id]:
                 if runner:
-                    logger.debug("Scheduling %s on %s", action, guid)
+                    logger.debug("TestbedController: Scheduling %s on %s", action, guid)
                     runner.put(perform_action, guid)
                 else:
-                    logger.debug("Performing %s on %s", action, guid)
+                    logger.debug("TestbedController: Performing %s on %s", action, guid)
                     perform_action(guid)
 
             # sync
@@ -269,16 +270,16 @@ class TestbedController(execute.TestbedController):
             if poststep:
                 for guid in guids[factory_id]:
                     if runner:
-                        logger.debug("Scheduling post-%s on %s", action, guid)
+                        logger.debug("TestbedController: Scheduling post-%s on %s", action, guid)
                         runner.put(poststep, self, guid)
                     else:
-                        logger.debug("Performing post-%s on %s", action, guid)
+                        logger.debug("TestbedController: Performing post-%s on %s", action, guid)
                         poststep(self, guid)
 
             # sync
             if runner:
                 runner.join()
-                logger.debug("Finished parallel %s", action)
+                logger.debug("TestbedController: Finished parallel %s", action)
 
     @staticmethod
     def do_poststep_preconfigure(self, guid):
@@ -329,6 +330,14 @@ class TestbedController(execute.TestbedController):
                         cross_connector_type_name,
                         True)
                 if connect_code:
+                    if hasattr(connect_code, "func"):
+                        func_name = connect_code.func.__name__
+                    elif hasattr(connect_code, "__name__"):
+                        func_name = connect_code.__name__
+                    else:
+                        func_name = repr(connect_code)
+                    self._logger.debug("Cross-connect - guid: %d, connect_code: %s " % (
+                        guid, func_name))
                     elem_cross_data = cross_data[cross_testbed_guid][cross_guid]
                     connect_code(self, guid, elem_cross_data)       
 
@@ -457,6 +466,9 @@ class TestbedController(execute.TestbedController):
         if status_function:
             return status_function(self, guid)
         return AS.STATUS_UNDETERMINED
+    
+    def testbed_status(self):
+        return self._status
 
     def trace(self, guid, trace_id, attribute='value'):
         if attribute == 'value':
@@ -465,6 +477,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
@@ -490,6 +504,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,