From 056fd459f46bb9fd2d5a83e6326823e86373ff7d Mon Sep 17 00:00:00 2001 From: peusterm Date: Tue, 12 Jan 2016 15:32:25 +0100 Subject: [PATCH] added getStatus functionality for compute nodes --- emuvim/cli/__main__.py | 6 ++++-- emuvim/dcemulator/node.py | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/emuvim/cli/__main__.py b/emuvim/cli/__main__.py index 82930dc..756ff89 100644 --- a/emuvim/cli/__main__.py +++ b/emuvim/cli/__main__.py @@ -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) diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index aeac665..87a5a6e 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -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): -- 2.25.1