From: peusterm Date: Thu, 4 Feb 2016 14:36:02 +0000 (+0100) Subject: added CLI interface to retrive datacenter information X-Git-Tag: v3.1~181^2~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=d313dc1ebe04c14d3e1cc915b9778474c7236409;p=osm%2Fvim-emu.git added CLI interface to retrive datacenter information --- diff --git a/emuvim/api/zerorpcapi.py b/emuvim/api/zerorpcapi.py index bbb95ca..1d5a6b1 100644 --- a/emuvim/api/zerorpcapi.py +++ b/emuvim/api/zerorpcapi.py @@ -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 diff --git a/emuvim/cli/compute.py b/emuvim/cli/compute.py index df40814..87247cb 100644 --- a/emuvim/cli/compute.py +++ b/emuvim/cli/compute.py @@ -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") diff --git a/emuvim/cli/son-emu-cli b/emuvim/cli/son-emu-cli index 56fe58b..ba7a292 100755 --- a/emuvim/cli/son-emu-cli +++ b/emuvim/cli/son-emu-cli @@ -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() diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index 6d615b5..0a14f20 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -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}