applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / resources / ns3 / ns3node.py
index a85ba0d..ca63c3c 100644 (file)
@@ -3,9 +3,8 @@
 #    Copyright (C) 2014 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,6 +27,7 @@ class NS3BaseNode(NS3Base):
     def __init__(self, ec, guid):
         super(NS3BaseNode, self).__init__(ec, guid)
         self._simulation = None
+        self._node_id = None
         self._ipv4 = None
         self._arp = None
         self._mobility = None
@@ -57,7 +57,7 @@ class NS3BaseNode(NS3Base):
             if not self._simulation:
                 msg = "Node not connected to simulation"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return self._simulation
          
@@ -100,12 +100,16 @@ class NS3BaseNode(NS3Base):
             if not devices: 
                 msg = "Node not connected to devices"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._devices = devices
 
         return self._devices
 
+    @property
+    def node_id(self):
+        return self._node_id
+
     @property
     def dceapplications(self):
         if not self._dceapplications:
@@ -116,20 +120,16 @@ class NS3BaseNode(NS3Base):
 
     @property
     def _rms_to_wait(self):
-        rms = set()
-        rms.add(self.simulation)
+        rms = set([self.simulation])
 
-        ipv4 = self.ipv4
-        if ipv4:
-            rms.add(ipv4)
+        if self.ipv4:
+            rms.add(self.ipv4)
 
-        arp = self.arp
-        if arp:
-            rms.add(arp)
+        if self.arp:
+            rms.add(self.arp)
 
-        mobility = self.mobility
-        if mobility:
-            rms.add(mobility)
+        if self.mobility:
+            rms.add(self.mobility)
 
         return rms
 
@@ -153,6 +153,8 @@ class NS3BaseNode(NS3Base):
             uuid_packet_socket_factory = self.simulation.create("PacketSocketFactory")
             self.simulation.invoke(self.uuid, "AggregateObject", uuid_packet_socket_factory)
 
+        self._node_id = self.simulation.invoke(self.uuid, "GetId")
+        
         dceapplications = self.dceapplications
         if dceapplications:
             self._add_dce(dceapplications)
@@ -182,7 +184,11 @@ class NS3BaseNode(NS3Base):
 
         container_uuid = self.simulation.create("NodeContainer")
         self.simulation.invoke(container_uuid, "Add", self.uuid)
-        with dceapp.dce_manager_lock:
-            self.simulation.invoke(dceapp.dce_manager_helper_uuid, 
-                    "Install", container_uuid)
+        
+        dce_helper = self.simulation.dce_helper
+
+        with dce_helper.dce_manager_lock:
+            dce_manager_uuid = dce_helper.dce_manager_uuid
+
+            self.simulation.invoke(dce_manager_uuid, "Install", container_uuid)