Initially working version of PlanetLab testbed implementation.
[nepi.git] / src / nepi / core / execute.py
index 60c26cc..add0909 100644 (file)
@@ -97,7 +97,8 @@ class ConnectorType(object):
 # need a definition!
 class Factory(AttributesMap):
     def __init__(self, factory_id, create_function, start_function, 
-            stop_function, status_function, configure_function,
+            stop_function, status_function, 
+            configure_function, preconfigure_function,
             allow_addresses = False, allow_routes = False):
         super(Factory, self).__init__()
         self._factory_id = factory_id
@@ -108,6 +109,7 @@ class Factory(AttributesMap):
         self._stop_function = stop_function
         self._status_function = status_function
         self._configure_function = configure_function
+        self._preconfigure_function = preconfigure_function
         self._connector_types = dict()
         self._traces = list()
         self._box_attributes = AttributesMap()
@@ -148,6 +150,10 @@ class Factory(AttributesMap):
     def configure_function(self):
         return self._configure_function
 
+    @property
+    def preconfigure_function(self):
+        return self._preconfigure_function
+
     @property
     def traces(self):
         return self._traces
@@ -166,7 +172,7 @@ class Factory(AttributesMap):
         self._box_attributes.add_attribute(name, help, type, value, range, 
                 allowed, flags, validation_function)
 
-class TestbedInstance(object):
+class TestbedController(object):
     def __init__(self, testbed_id, testbed_version):
         self._testbed_id = testbed_id
         self._testbed_version = testbed_version
@@ -297,10 +303,18 @@ class ExperimentController(object):
         self._netrefs = dict()
         self._root_dir = root_dir
 
+        self.persist_experiment_xml()
+
     @property
     def experiment_xml(self):
         return self._experiment_xml
 
+    def persist_experiment_xml(self):
+        xml_path = os.path.join(self._root_dir, "experiment.xml")
+        f = open(xml_path, "w")
+        f.write(self._experiment_xml)
+        f.close()
+
     def set_access_configuration(self, testbed_guid, access_config):
         self._access_config[testbed_guid] = access_config
 
@@ -329,7 +343,8 @@ class ExperimentController(object):
         # perform create-connect in parallel, wait
         # (internal connections only)
         self._parallel([lambda : (testbed.do_create(), 
-                                  testbed.do_connect())
+                                  testbed.do_connect(),
+                                  testbed.do_preconfigure())
                         for testbed in self._testbeds.itervalues()])
         
         # resolve netrefs