added CLI interface to retrive datacenter information
authorpeusterm <manuel.peuster@uni-paderborn.de>
Thu, 4 Feb 2016 14:36:02 +0000 (15:36 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Thu, 4 Feb 2016 14:36:02 +0000 (15:36 +0100)
emuvim/api/zerorpcapi.py
emuvim/cli/compute.py
emuvim/cli/son-emu-cli
emuvim/dcemulator/node.py

index bbb95ca..1d5a6b1 100644 (file)
@@ -102,3 +102,11 @@ class MultiDatacenterApi(object):
         except Exception as ex:
             logging.exception("RPC error.")
             return ex.message
+
+    def datacenter_list(self):
+        logging.debug("RPC CALL: datacenter list")
+        try:
+            return [d.getStatus() for d in self.dcs.itervalues()]
+        except Exception as ex:
+            logging.exception("RPC error.")
+            return ex.message
index df40814..87247cb 100644 (file)
@@ -80,7 +80,8 @@ class ZeroRpcClient(object):
 parser = argparse.ArgumentParser(description='son-emu compute')
 parser.add_argument(
     "command",
-    help="Action to be executed: start|stop|list")
+    choices=['start', 'stop', 'list', 'status'],
+    help="Action to be executed.")
 parser.add_argument(
     "--datacenter", "-d", dest="datacenter",
     help="Data center to in which the compute instance should be executed")
index 56fe58b..ba7a292 100755 (executable)
@@ -15,6 +15,7 @@
 import sys
 import compute
 import network
+import datacenter
 
 
 def main():
@@ -25,6 +26,8 @@ def main():
         compute.main(sys.argv[2:])
     elif sys.argv[1] == "network":
         network.main(sys.argv[2:])
+    elif sys.argv[1] == "datacenter":
+        datacenter.main(sys.argv[2:])
 
 if __name__ == '__main__':
     main()
index 6d615b5..0a14f20 100644 (file)
@@ -140,3 +140,9 @@ class Datacenter(object):
         data center.
         """
         return list(self.containers.itervalues())
+
+    def getStatus(self):
+        """
+        Return a dict with status information about this DC.
+        """
+        return {"label": self.label}