Netrefs now work on interfaces :)
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 21 Apr 2011 12:31:32 +0000 (14:31 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 21 Apr 2011 12:31:32 +0000 (14:31 +0200)
src/nepi/testbeds/planetlab/application.py
src/nepi/testbeds/planetlab/execute.py
test/testbeds/planetlab/execute.py

index 46550c3..471fd44 100644 (file)
@@ -21,6 +21,13 @@ class Application(object):
         # Those are filled when an actual node is connected
         self.node = None
     
+    def __str__(self):
+        return "%s<command:%s%s>" % (
+            self.__class__.__name__,
+            "sudo " if self.sudo else "",
+            self.command,
+        )
+    
     def validate(self):
         pass
 
index 8611834..a86785b 100644 (file)
@@ -111,7 +111,17 @@ class TestbedController(testbed_impl.TestbedController):
             return None
 
     def get_address(self, guid, index, attribute='Address'):
-        # TODO: fetch real data from planetlab
+        # try the real stuff
+        iface = self._elements.get(guid)
+        if iface and index == 0:
+            if attribute == 'Address':
+                return iface.address
+            elif attribute == 'NetPrefix':
+                return iface.netprefix
+            elif attribute == 'Broadcast':
+                return iface.broadcast
+        
+        # if all else fails, query box
         try:
             return self.box_get_address(guid, int(index), attribute)
         except KeyError, AttributeError:
index 6c042d8..0e98122 100755 (executable)
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import getpass
-from nepi.util.constants import STATUS_FINISHED
+from nepi.util.constants import STATUS_FINISHED, TIME_NOW
 from nepi.testbeds import planetlab
 import os
 import shutil
@@ -39,7 +39,7 @@ class NetnsExecuteTestCase(unittest.TestCase):
         instance.defer_connect(4, "inet", 6, "devs")
         instance.defer_connect(5, "inet", 6, "devs")
         instance.defer_create(7, "Application")
-        instance.defer_create_set(7, "command", "ping -qc1 {#GUID-3.addr[0].[ip]#}")
+        instance.defer_create_set(7, "command", "ping -qc1 {#GUID-5.addr[0].[Address]#}")
         instance.defer_add_trace(7, "stdout")
         instance.defer_connect(7, "node", 2, "apps")
 
@@ -48,8 +48,12 @@ class NetnsExecuteTestCase(unittest.TestCase):
         instance.do_connect()
         instance.do_configure()
         
-        print instance.elements[4]
-        print instance.elements[5]
+        # Manually replace netref
+        instance.set(TIME_NOW, 7, "command",
+            instance.get(TIME_NOW, 7, "command")
+                .replace("{#GUID-5.addr[0].[Address]#}", 
+                    instance.get_address(5, 0, "Address") )
+        )
         
         instance.start()
         while instance.status(7) != STATUS_FINISHED: