Ticket #45: spanning tree deployment
[nepi.git] / src / nepi / testbeds / planetlab / metadata_v01.py
index c2f7e41..85ae099 100644 (file)
@@ -43,13 +43,13 @@ def is_addrlist(attribute, value):
         if '/' in component:
             addr, mask = component.split('/',1)
         else:
-            addr, mask = component, 32
+            addr, mask = component, '32'
         
         if mask is not None and not (mask and mask.isdigit()):
             # No empty or nonnumeric masks
             return False
         
-        if not validation.is_ip4_address(attribute, value):
+        if not validation.is_ip4_address(attribute, addr):
             # Address part must be ipv4
             return False
         
@@ -166,12 +166,17 @@ def create_node(testbed_instance, guid):
     
     # add constraint on number of (real) interfaces
     # by counting connected devices
-    dev_guids = testbed_instance.get_connected(guid, "node", "devs")
+    dev_guids = testbed_instance.get_connected(guid, "devs", "node")
     num_open_ifaces = sum( # count True values
         NODEIFACE == testbed_instance._get_factory_id(guid)
         for guid in dev_guids )
     element.min_num_external_ifaces = num_open_ifaces
     
+    # require vroute vsys if we have routes to set up
+    routes = testbed_instance._add_route.get(guid)
+    if routes:
+        element.required_vsys.add("vroute")
+    
     testbed_instance.elements[guid] = element
 
 def create_nodeiface(testbed_instance, guid):
@@ -404,7 +409,7 @@ def configure_application(testbed_instance, guid):
     app.node.wait_dependencies()
     
     # Install stuff
-    app.setup()
+    app.async_setup()
 
 def configure_dependency(testbed_instance, guid):
     dep = testbed_instance._elements[guid]
@@ -416,7 +421,7 @@ def configure_dependency(testbed_instance, guid):
     dep.node.wait_dependencies()
     
     # Install stuff
-    dep.setup()
+    dep.async_setup()
 
 def configure_netpipe(testbed_instance, guid):
     netpipe = testbed_instance._elements[guid]
@@ -929,7 +934,7 @@ create_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEP
 
 configure_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
 
-# Start node after ifaces, because the node needs the ifaces in order to set up routes
+# Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
 start_order = [ INTERNET, NODEIFACE, TAPIFACE, TUNIFACE, NODE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
 
 factories_info = dict({
@@ -939,7 +944,7 @@ factories_info = dict({
             "category": "topology",
             "create_function": create_node,
             "preconfigure_function": configure_node,
-            "start_function": configure_node_routes,
+            "prestart_function": configure_node_routes,
             "box_attributes": [
                 "forward_X11",
                 "hostname",
@@ -973,7 +978,7 @@ factories_info = dict({
             "create_function": create_tuniface,
             "preconfigure_function": preconfigure_tuniface,
             "configure_function": postconfigure_tuniface,
-            "start_function": wait_tuniface,
+            "prestart_function": wait_tuniface,
             "box_attributes": [
                 "up", "device_name", "mtu", "snat", "pointopoint",
                 "txqueuelen",
@@ -989,7 +994,7 @@ factories_info = dict({
             "create_function": create_tapiface,
             "preconfigure_function": preconfigure_tuniface,
             "configure_function": postconfigure_tuniface,
-            "start_function": wait_tuniface,
+            "prestart_function": wait_tuniface,
             "box_attributes": [
                 "up", "device_name", "mtu", "snat", "pointopoint",
                 "txqueuelen",
@@ -1136,6 +1141,10 @@ class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
     def configure_order(self):
         return configure_order
 
+    @property
+    def prestart_order(self):
+        return start_order
+
     @property
     def start_order(self):
         return start_order