# do some API tests
print c.compute_action_start("dc2", "d1")
+ print c.compute_action_start("dc2", "d2")
- time.sleep(10)
+ time.sleep(20)
print c.compute_action_stop("dc2", "d1")
+ print c.compute_action_stop("dc2", "d2")
if __name__ == '__main__':
node2 = self.switches[node2]
if isinstance( node2, Datacenter ):
node2 = node2.switch
+ # try to give containers a default IP
+ if isinstance( node1, Docker ):
+ if not "params1" in params:
+ params["params1"] = {}
+ if not "ip" in params["params1"]:
+ params["params1"]["ip"] = self.getNextIp()
+ if isinstance( node2, Docker ):
+ if not "params2" in params:
+ params["params2"] = {}
+ if not "ip" in params["params2"]:
+ params["params2"]["ip"] = self.getNextIp()
+
return self.mnet.addLink(node1, node2, **params) # TODO we need TCLinks with user defined performance here
def removeLink(self, link=None, node1=None, node2=None):
"""
return self.mnet.removeDocker(name, **params)
+ def getNextIp(self):
+ return self.mnet.getNextIp()
+
def start(self):
# start
for dc in self.dcs.itervalues():
data center.
"""
# TODO ip management
- d = self.net.addDocker("%s.%s" % (self.name, name), dimage="ubuntu")
- self.net.addLink(d, self.switch, params1={"ip": "10.0.0.254/8"})
+ d = self.net.addDocker("%s" % (name), dimage="ubuntu")
+ self.net.addLink(d, self.switch) #params1={"ip": "10.0.0.254/8"}
self.containers[name] = d
def removeCompute(self, name):
assert name in self.containers
self.net.removeLink(
link=None, node1=self.containers[name], node2=self.switch)
- self.net.removeDocker("%s.%s" % (self.name, name))
+ self.net.removeDocker("%s" % (name))
del self.containers[name]