added getStatus functionality for compute nodes
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 12 Jan 2016 14:32:25 +0000 (15:32 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 12 Jan 2016 14:32:25 +0000 (15:32 +0100)
emuvim/cli/__main__.py
emuvim/dcemulator/node.py

index 82930dc..756ff89 100644 (file)
@@ -8,10 +8,12 @@
  cli network create dc1 11.0.0.0/24
 """
 import time
+import pprint
 import zerorpc
 
 
 def main():
+    pp = pprint.PrettyPrinter(indent=4)
     print "Example CLI client"
     # create connection to remote Mininet instance
     c = zerorpc.Client()
@@ -25,8 +27,8 @@ def main():
     print c.compute_list("dc2")
 
     time.sleep(1)
-    print c.compute_status("dc2", "d1")
-    print c.compute_status("dc2", "d2")
+    pp.pprint(c.compute_status("dc2", "d1"))
+    pp.pprint(c.compute_status("dc2", "d2"))
 
     time.sleep(5)
 
index aeac665..87a5a6e 100644 (file)
@@ -30,13 +30,27 @@ class EmulatorCompute(Docker):
         Helper method to receive information about the virtual networks
         this compute instance is connected to.
         """
-        return None
+        # format list of tuples (name, Ip, MAC, isUp, status)
+        return [(str(i), i.IP(), i.MAC(), i.isUp(), i.status())
+                for i in self.intfList()]
 
     def getStatus(self):
         """
         Helper method to receive information about this compute instance.
         """
-        return None
+        status = {}
+        status["name"] = self.name
+        status["network"] = self.getNetworkStatus()
+        status["image"] = self.dimage
+        status["cpu_quota"] = self.cpu_quota
+        status["cpu_period"] = self.cpu_period
+        status["cpu_shares"] = self.cpu_shares
+        status["cpuset"] = self.cpuset
+        status["mem_limit"] = self.mem_limit
+        status["memswap_limit"] = self.memswap_limit
+        status["state"] = self.dcli.inspect_container(self.dc)["State"]
+        status["id"] = self.dcli.inspect_container(self.dc)["Id"]
+        return status
 
 
 class Datacenter(object):