Adding linux ns3 server unit test
[nepi.git] / src / nepi / resources / ns3 / ns3application.py
index f53d505..6f8ad6b 100644 (file)
@@ -30,3 +30,24 @@ class NS3BaseApplication(NS3Base):
             self.simulator.invoke(node.uuid, "AddApplication", self.uuid)
             self._connected.add(node.uuid)
 
+    def do_start(self):
+        if self.state == ResourceState.READY:
+            self.info("Starting")
+
+            # BUG: without doing this explicit call it doesn't start!!!
+            # Shouldn't be enough to set the StartTime?
+            self.simulator.invoke(self.uuid, "Start")
+            
+            self.set_started()
+        else:
+            msg = " Failed "
+            self.error(msg, out, err)
+            raise RuntimeError, msg
+
+    def do_stop(self):
+        if self.state == ResourceState.STARTED:
+            # No need to do anything, simulator.Destroy() will stop every object
+            self.info("Stopping command '%s'" % command)
+            self.simulator.invoke(self.uuid, "Stop")
+            self.set_stopped()
+