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()
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)
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):