added status and list commands to cli
diff --git a/emuvim/cli/compute.py b/emuvim/cli/compute.py
index b75b043..c5f2231 100644
--- a/emuvim/cli/compute.py
+++ b/emuvim/cli/compute.py
@@ -1,9 +1,11 @@
"""
son-emu compute CLI
+(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
"""
import argparse
import pprint
+from tabulate import tabulate
import zerorpc
@@ -14,7 +16,7 @@
def __init__(self):
self.c = zerorpc.Client()
- self.c.connect("tcp://127.0.0.1:4242") # yes, hard coded for now. we'll change this later
+ self.c.connect("tcp://127.0.0.1:4242") # TODO hard coded for now. we'll change this later
self.cmds = {}
def execute_command(self, args):
@@ -35,10 +37,38 @@
pp.pprint(r)
def list(self, args):
- print "TODO: Not implemented"
+ r = self.c.compute_list(
+ args.get("datacenter"))
+ table = []
+ for c in r:
+ # for each container add a line to the output table
+ if len(c) > 1:
+ name = c[0]
+ status = c[1]
+ eth0ip = None
+ eth0status = "down"
+ if len(status.get("network")) > 0:
+ eth0ip = status.get("network")[0][1]
+ eth0status = "up" if status.get(
+ "network")[0][3] else "down"
+ table.append([status.get("datacenter"),
+ name,
+ status.get("image"),
+ eth0ip,
+ eth0status,
+ status.get("state").get("Status")])
+ headers = ["Datacenter",
+ "Container",
+ "Image",
+ "eth0 IP",
+ "eth0 status",
+ "Status"]
+ print tabulate(table, headers=headers, tablefmt="grid")
def status(self, args):
- print "TODO: Not implemented"
+ r = self.c.compute_status(
+ args.get("datacenter"), args.get("name"))
+ pp.pprint(r)
parser = argparse.ArgumentParser(description='son-emu compute')
diff --git a/emuvim/cli/network.py b/emuvim/cli/network.py
index 0c50dda..080b0ac 100644
--- a/emuvim/cli/network.py
+++ b/emuvim/cli/network.py
@@ -1,5 +1,6 @@
"""
son-emu network CLI
+(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
"""
diff --git a/emuvim/cli/son-emu-cli b/emuvim/cli/son-emu-cli
index 57ae053..56fe58b 100755
--- a/emuvim/cli/son-emu-cli
+++ b/emuvim/cli/son-emu-cli
@@ -2,6 +2,8 @@
"""
Simple CLI client to interact with a running emulator.
+ (c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
+
The CLI offers different tools, e.g., compute, network, ...
Each of these tools is implemented as an independent Python
module.