c.connect("tcp://127.0.0.1:4242")
# do some API tests
- print c.compute_action_start("dc2", "my_new_container1")
+ print c.compute_action_start("dc2", "d1")
time.sleep(10)
- print c.compute_action_stop("dc2", "my_new_container1")
+ print c.compute_action_stop("dc2", "d1")
if __name__ == '__main__':
import logging
from mininet.net import Mininet
-from mininet.node import Controller, OVSKernelSwitch, Switch
+from mininet.node import Controller, OVSKernelSwitch, Switch, Docker, Host
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Link
logging.info("added switch: %s" % name)
return s
- def addLink(self, node1, node2):
+ def addLink(self, node1, node2, **params):
"""
Able to handle Datacenter objects as link
end points.
"""
assert node1 is not None
assert node2 is not None
+ logging.debug("addLink: n1=%s n2=%s" % (str(node1), str(node2)))
# ensure type of node1
if isinstance( node1, basestring ):
if node1 in self.dcs:
node2 = self.switches[node2]
if isinstance( node2, Datacenter ):
node2 = node2.switch
- # create link if everything is correct
- if (node1 is not None and isinstance(node1, OVSKernelSwitch)
- and node2 is not None and isinstance(node2, OVSKernelSwitch)):
- self.mnet.addLink(node1, node2) # TODO we need TCLinks with user defined performance here
- else:
- raise Exception(
- "one of the given nodes is not a Mininet switch or None")
+ self.mnet.addLink(node1, node2, **params) # TODO we need TCLinks with user defined performance here
def addDocker( self, name, **params ):
"""
data center.
"""
#TODO connect container to DC's swtich
- self.net.addDocker("%s.%s" % (self.name, name), dimage="ubuntu")
+ d1 = self.net.addDocker("%s.%s" % (self.name, name), dimage="ubuntu")
+ l1 = self.net.addLink(d1, self.switch)
def removeCompute(self, name):
#TODO disconnect container to DC's swtich