Added routes to OMF nodes
[nepi.git] / src / nepi / core / design.py
index f40b54b..7ad5509 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
@@ -56,6 +55,11 @@ class Connector(object):
         self._connections.append(connector)
         connector._connections.append(self)
 
+    def get_connected_box(self, idx = 0):
+        if len(self._connections) == 0:
+            return None
+        return self._connections[idx].box
+
     def disconnect(self, connector):
         if connector not in self._connections or\
                 self not in connector._connections:
@@ -153,6 +157,12 @@ class Route(AttributesMap):
                 value = 0,
                 flags = Attribute.NoDefaultValue,
                 validation_function = validation.is_integer)
+        self.add_attribute(name = "Device",
+                help = "Device name", 
+                type = Attribute.STRING,
+                value = None,
+                flags = Attribute.NoDefaultValue,
+                validation_function = validation.is_string)
 
 class Box(AttributesMap, Taggable):
     def __init__(self, guid, factory, testbed_guid, container = None):
@@ -371,7 +381,7 @@ class ExperimentDescription(object):
             for box in tbd_desc.boxes:
                 l = box.get_attribute_value("label")
                 if label == l:
-                    return tbd_desc
+                    return box
         return None
     
     def add_testbed_description(self, provider, guid = None):