Example #1
0
    def build( self ):
        print "Build network based on our topology."

        net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase )
 
        net.controllers = self.addControllers()
        
        # Make nodes
        print "Getting Hosts and Switches."
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                net.addSwitch( name )
            elif 'Host' in tags:
                ipBaseNum, prefixLen = netParse( self.minieditIpBase )
                ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
                net.addHost( name, ip=ip )
            else:
                raise Exception( "Cannot create mystery node: " + name )

        # Make links
        print "Getting Links."
        for link in self.links.values():
            ( src, dst, linkopts ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            net.addLink(src, dst, **linkopts)

        self.printInfo()
        # Build network (we have to do this separately at the moment )
        net.build()

        return net
Example #2
0
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    domains.append(d0)
    ctls = ctlsets[0].split(',')
    for i in range(len(ctls)):
        d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])

    # the fabric domains - position 1 for domain 1, 2 for 2 ...
    for i in range(1, len(ctlsets)):
        f = FabricDomain(i)
        domains.append(f)
        ctls = ctlsets[i].split(',')
        for j in range(len(ctls)):
            f.addController('c%s%s' % (i, j),
                            controller=RemoteController,
                            ip=ctls[j])

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    for i in range(1, len(domains)):
        an = {
            "bandwidth": 100000,
            "optical.type": "cross-connect",
            "durable": "true"
        }
        net.addLink(domains[i].getTether(),
                    d0.getSwitches('OE%s' % i),
                    port1=OVS_AP,
                    port2=OE_AP,
                    speed=10000,
                    annotations=an,
                    cls=LINCLink)

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
Example #3
0
def simpleTest():
    topo = Node45Topo()
    net = Mininet(topo, link=TCLink)  #主要类来创建和管理网络
    mycontroller = RemoteController("c0", ip="127.0.0.1", port=6633)  #创建远程控制器
    net.controllers = [mycontroller]
    net.start()  #启动您的拓扑网络
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)  #转存文件连接
    print "Testing network connectivity"
    # net.pingAll()    #所有节点彼此测试互连
    CLI(net)  #进入mininet>提示符
    net.stop()  #停止您的网络
def sdnnet(opt):
    topo = SDNTopo()
    info('*** Creating network\n')
    #net = Mininet( topo=topo, controller=MyController, link=TCLink)
    net = Mininet(topo=topo, link=TCLink, build=False)
    controllers = []
    for c in Controllers:
        rc = RemoteController('c%d' % Controllers.index(c),
                              ip=c['ip'],
                              port=c['port'])
        print "controller ip %s port %s" % (c['ip'], c['port'])
        controllers.append(rc)

    net.controllers = controllers
    net.build()

    host = []
    for i in range(NR_NODES):
        host.append(net.get('host%d' % i))

    net.start()

    sw = net.get('sw03.00')
    print "center sw", sw
    sw.attach('tapc0')

    for i in range(NR_NODES):
        host[i].defaultIntf().setIP('192.168.%d.%d/16' % (NWID, i))
        host[i].defaultIntf().setMAC('00:00:00:00:%02x:%02x' % (NWID, i))

    for i in range(NR_NODES):
        for n in range(3):
            for h in range(10):
                host[i].setARP('192.168.%d.%d' % (n, h),
                               '00:00:00:00:%02x:%02x' % (n, h))

    root = []
    for i in range(NR_NODES):
        root.append(net.get('root%d' % i))

    for i in range(NR_NODES):
        host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
        root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)

    stopsshd()
    startsshds(host)

    if opt == "cli":
        CLI(net)
        stopsshd()
        net.stop()
def sdnnet(opt):
    topo = SDNTopo()
    info( '*** Creating network\n' )
    #net = Mininet( topo=topo, controller=MyController, link=TCLink)
    net = Mininet( topo=topo, link=TCLink, build=False)
    controllers=[]
    for c in Controllers:
      rc = RemoteController('c%d' % Controllers.index(c), ip=c['ip'],port=c['port'])
      print "controller ip %s port %s" % (c['ip'], c['port'])
      controllers.append(rc)
  
    net.controllers=controllers
    net.build()

    host = []
    for i in range (NR_NODES):
      host.append(net.get( 'host%d' % i ))

    net.start()

    sw=net.get('sw03.00')
    print "center sw", sw
    sw.attach('tapc0')

    for i in range (NR_NODES):
        host[i].defaultIntf().setIP('192.168.%d.%d/16' % (NWID,i)) 
        host[i].defaultIntf().setMAC('00:00:00:00:%02x:%02x' % (NWID,i)) 

    for i in range (NR_NODES):
       for n in range (3):
         for h in range (10):
           host[i].setARP('192.168.%d.%d' % (n, h), '00:00:00:00:%02x:%02x' % (n,h)) 


    root = []
    for i in range (NR_NODES):
        root.append(net.get( 'root%d' % i ))

    for i in range (NR_NODES):
        host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
        root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)

    stopsshd ()
    startsshds ( host )

    if opt=="cli":
        CLI(net)
        stopsshd()
        net.stop()
def sdnnet(opt):
    topo = SDNTopo()
    info('*** Creating network\n')
    #net = Mininet( topo=topo, controller=MyController, link=TCLink)
    net = Mininet(topo=topo, link=TCLink, build=False)
    controllers = []
    for c in Controllers:
        rc = RemoteController('c%d' % Controllers.index(c),
                              ip=c['ip'],
                              port=c['port'])
        print "controller ip %s port %s" % (c['ip'], c['port'])
        controllers.append(rc)

    net.controllers = controllers
    net.build()

    host = []
    for i in range(8):
        host.append(net.get('host%d' % i))

    net.start()

    core_sw = []
    for i in range(1):
        name_suffix = '%s' % NWID + '0c' + '%02d' % i
        net.get('sw' + name_suffix).attach('tap%s0' % NWID)

    for i in range(8):
        host[i].defaultIntf().setIP('192.168.10.10%d/24' % i)

    root = []
    for i in range(8):
        root.append(net.get('root%d' % i))

    for i in range(8):
        host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
        root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)

    stopsshd()
    startsshds(host)

    if opt == "cli":
        CLI(net)
        stopsshd()
        net.stop()
Example #7
0
File: metro.py Project: Mohdrz/Onos
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    domains.append(d0)
    ctls = ctlsets[0].split(',')
    for i in range (len(ctls)):
        d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])

    # the fabric domains - position 1 for domain 1, 2 for 2 ...
    for i in range (1,len(ctlsets)):
        f = FabricDomain(i)
        domains.append(f)
        ctls = ctlsets[i].split(',')
        for j in range (len(ctls)):
            f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    for i in range(1,len(domains)):
        an = { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }
        net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
                    port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink)

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
Example #8
0
def simpleTest():
        topo = Node45Topo()
        net = Mininet(topo, link=TCLink, autoStaticArp=True)    #主要类来创建和管理网络
        mycontroller = RemoteController("c0", ip="127.0.0.1", port=6633)    #创建远程控制器
        net.controllers = [mycontroller]
        net.start()    #启动您的拓扑网络
        net_start_time = time.time()
        print "***Dumping host connections"
        # dumpNodeConnections(net.hosts)       #转存文件连接
        # print "Testing network connectivity"     
        # net.pingAll()    #所有节点彼此测试互连

        try:
            for i in range(1, gl.switchNum + 1):
                thread.start_new_thread( lru.remo, ('s%d' % i, ) )
        except:
            print "Error: unable to start thread"

        path = "/home/ubuntu/cppalg/output/demandAndPath.txt"
        if os.path.exists(path) == True:
            try_time = 100
            print(os.path.getmtime(path))
            print(net_start_time)
            while os.path.getmtime(path) < net_start_time:
                try_time = try_time - 1
                if try_time < 0:
                    break
            if os.path.getmtime(path) > net_start_time:
                with open(path, "r") as f:
                    lines = f.read().split('\n')
                    for perline in lines:
                        # 读取第二个和最后一个数,如果不相等,iperfudp
                        if perline != "":
                            line = perline.split()
                            print(line)
                            if len(line) > 1 and line[1] != line[-1]:
                                print("Log iperf UDP for: ", line[1], line[-1])
                                hs, hd = net.get('h%s'%line[1], 'h%s'%line[-1])
                                net.iperf( (hs, hd), 'UDP', '%sM'%line[0], None, 3, 5566 )
        CLI(net)		#进入mininet>提示符 
        net.stop()       #停止网络
Example #9
0
from mininet.net import Mininet
from mininet.node import RemoteController, OVSSwitch
from mininet.link import TCLink
from time import sleep

if __name__ == "__main__":
    default_hs_bw = 10
    default_ss_bw = 10
    default_gs_bw = 10
    default_ng_bw = 10

    setLogLevel("info")
    net = Mininet(switch=OVSSwitch, listenPort = 6633, ipBase='191.0.0.1/4')

    mycontroller = RemoteController("RemoteController")
    net.controllers = [mycontroller]
    net.nameToNode["RemoteController"] = mycontroller

    # host
    # tenant 1
    host1 = net.addHost('h1', ip="191.168.1.1", mac='00:00:00:00:00:01')
    host2 = net.addHost('h2', ip="191.168.1.2", mac='00:00:00:00:00:02')
    host3 = net.addHost('h3', ip="191.168.1.3", mac='00:00:00:00:00:03')
    host4 = net.addHost('h4', ip="191.168.1.4", mac='00:00:00:00:00:04')
    host5 = net.addHost('h5', ip="191.168.1.4", mac='00:00:00:00:00:05')
    host6 = net.addHost('h6', ip="191.168.1.6", mac='00:00:00:00:00:09')

    # tenant 2
    host7 = net.addHost('h7', ip="191.168.1.1", mac='00:00:00:00:00:0A')
    host8 = net.addHost('h8', ip="191.168.1.2", mac='00:00:00:00:00:0B')
    host9 = net.addHost('h9', ip="191.168.1.3", mac='00:00:00:00:00:0C')
Example #10
0
from mininet.node import OVSSwitch, Controller, RemoteController
from mininet.topolib import TreeTopo
from mininet.log import setLogLevel
from mininet.cli import CLI

setLogLevel('info')

# Two local and one "external" controller (which is actually c0)
# Ignore the warning message that the remote isn't (yet) running
c0 = Controller('c0')
c1 = Controller('c1')
c2 = RemoteController('c2', ip='127.0.0.1')

cmap = {'s1': c0, 's2': c1, 's3': c2}


class MultiSwitch(OVSSwitch):
    "Custom Switch() subclass that connects to different controllers"

    def start(self, controllers):
        return OVSSwitch.start(self, [cmap[self.name]])


topo = TreeTopo(depth=2, fanout=2)
net = Mininet(topo=topo, switch=MultiSwitch, build=False)
net.controllers = [c0, c1]
net.build()
net.start()
CLI(net)
net.stop()
Example #11
0
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    domains.append(d0)
    ctls = ctlsets[0].split(',')
    for i in range (len(ctls)):
        d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])

    # the fabric domains - position 1 for domain 1, 2 for 2 ...
    for i in range (1,len(ctlsets)):
        f = FabricDomain(i)
        domains.append(f)
        ctls = ctlsets[i].split(',')
        for j in range (len(ctls)):
            f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])

    # netcfg for each domains
    # Note: Separate netcfg for domain0 is created in opticalUtils
    domainCfgs = []
    for i in range (0,len(ctlsets)):
        cfg = {}
        cfg['devices'] = {}
        cfg['ports'] = {}
        cfg['links'] = {}
        domainCfgs.append(cfg)

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    # adding cross-connect links
    for i in range(1,len(domains)):
        # add 10 cross-connect links between domains
        xcPortNo=2
        ochPortNo=10
        for j in range(0, 10):
            an = { "bandwidth": 10, "durable": "true" }
            net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
                        port1=xcPortNo+j, port2=ochPortNo+j, speed=10000, annotations=an, cls=LINCLink)

            xcId = 'of:' + domains[i].getSwitches(name=domains[i].getTether()).dpid + '/' + str(xcPortNo+j)
            ochId = 'of:' + d0.getSwitches('OE%s' % i).dpid + '/' + str(ochPortNo+j)
            domainCfgs[i]['ports'][xcId] = {'cross-connect': {'remote': ochId}}

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    # send netcfg json to each CO-ONOS
    for i in range(1,len(domains)):
        info('*** Pushing Topology.json to CO-ONOS %d\n' % i)
        filename = 'Topology%d.json' % i
        with open(filename, 'w') as outfile:
            json.dump(domainCfgs[i], outfile, indent=4, separators=(',', ': '))

        output = quietRun('%s/tools/test/bin/onos-netcfg %s %s &'\
                           % (LINCSwitch.onosDir,
                              domains[i].getControllers()[0].ip,
                              filename), shell=True)
        # successful output contains the two characters '{}'
        # if there is more output than this, there is an issue
        if output.strip('{}'):
            warn('***WARNING: Could not push topology file to ONOS: %s\n' % output)

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
Example #12
0
info( '* Creating Control Network\n' )
ctopo = ControlNetwork( n=4, dataController=DataController )
cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', build=False )
info( '* Adding Control Network Controller\n')
cnet.addController( 'cc0' )
info( '* Starting Control Network\n')
cnet.build()
cnet.start()
dataControllers = cnet.hosts[ : -1 ]  # ignore 'root' node

info( '* Creating Data Network\n' )
topo = TreeTopo( depth=2, fanout=2 )
# UserSwitch so we can easily test failover
net = Mininet( topo=topo, switch=UserSwitch, build=False )
info( '* Adding Controllers to Data Network\n' )
net.controllers = dataControllers
net.build()
info( '* Starting Data Network\n')
net.start()

CLI2( net, cnet=cnet )

info( '* Stopping Data Network\n' )
net.stop()

info( '* Stopping Control Network\n' )
cnet.stop()



Example #13
0
	"""
	info("****creating network****\n")
	net = Mininet(listenPort = 6633)

	mycontroller = RemoteController("muziController", ip = "127.0.0.1")

	switch_1 = net.addSwitch('s1')
	switch_2 = net.addSwitch('s2')
	switch_3 = net.addSwitch('s3')
	#switch_4 = net.addSwitch('s4')
	h1 = net.addHost('h1')
	h2 = net.addHost('h2')



	net.controllers = [mycontroller]

	#_intf_1 = Intf(intfName_1, node = switch_1, port = 1)

	net.addLink(switch_1, switch_2, 2, 1)# node1, node2, port1, port2
	net.addLink(switch_2, switch_3, 2, 1)
	#net.addLink(switch_1, switch_4, 3, 1)

	net.addLink(switch_1, h1, 1)
	net.addLink(switch_2, h2, 2)

	#_intf_3 = Intf(intfName_3, node = switch_3, port = 2)

	#net.addLink(switch_4, switch_3, 2, 3)

	#info("*****Adding hardware interface ", intfName_1, "to switch:" ,switch_1.name, '\n')
Example #14
0
#!/usr/bin/python

"""
Create a network where different switches are connected to
different controllers, by creating a custom Switch() subclass.
"""

from mininet.net import Mininet
from mininet.node import OVSSwitch, Controller
from mininet.topolib import TreeTopo
from mininet.cli import CLI

c0 = Controller( 'c0' )
c1 = Controller( 'c1', ip='127.0.0.2' )
cmap = { 's1': c0, 's2': c1, 's3': c1 }

class MultiSwitch( OVSSwitch ):
    "Custom Switch() subclass that connects to different controllers"
    def start( self, controllers ):
        return OVSSwitch.start( self, [ cmap[ self.name ] ] )

topo = TreeTopo( depth=2, fanout=2 )
net = Mininet( topo=topo, switch=MultiSwitch, build=False )
net.controllers = [ c0, c1 ]
net.build()
net.start()
CLI( net )
net.stop()
Example #15
0
leftTopSwitch  = net.addSwitch('s3')
rightTopSwitch = net.addSwitch('s4')

# Add links
# set link speeds to 10Mbit/s
linkopts = dict(bw=10)
net.addLink(leftHost1,  leftSwitch,    **linkopts )
net.addLink(leftHost2,  leftSwitch,    **linkopts )
net.addLink(rightHost1, rightSwitch,   **linkopts )
net.addLink(rightHost2, rightSwitch,   **linkopts )
net.addLink(leftSwitch, leftTopSwitch, **linkopts )
net.addLink(leftSwitch, rightTopSwitch,**linkopts )
net.addLink(rightSwitch,leftTopSwitch, **linkopts )
net.addLink(rightSwitch,rightTopSwitch,**linkopts )

# Start
net.controllers = [ c ]
net.build()
net.start()

# Enable sFlow
# 1-in-10 sampling rate for 10Mbit/s links is proportional to 1-in-1000 for 1G
# see http://blog.sflow.com/2013/02/sdn-and-large-flows.html
quietRun('ovs-vsctl -- --id=@sflow create sflow agent=eth0 target=127.0.0.1 sampling=10 polling=20 -- -- set bridge s1 sflow=@sflow -- set bridge s2 sflow=@sflow -- set bridge s3 sflow=@sflow -- set bridge s4 sflow=@sflow')

# CLI
CLI( net )

# Clean up
net.stop()
Example #16
0
rightTopSwitch = net.addSwitch('s4')

# Add links
# set link speeds to 10Mbit/s
linkopts = dict(bw=10)
net.addLink(leftHost1, leftSwitch, **linkopts)
net.addLink(leftHost2, leftSwitch, **linkopts)
net.addLink(rightHost1, rightSwitch, **linkopts)
net.addLink(rightHost2, rightSwitch, **linkopts)
net.addLink(leftSwitch, leftTopSwitch, **linkopts)
net.addLink(leftSwitch, rightTopSwitch, **linkopts)
net.addLink(rightSwitch, leftTopSwitch, **linkopts)
net.addLink(rightSwitch, rightTopSwitch, **linkopts)

# Start
net.controllers = [c]
net.build()
net.start()

# Enable sFlow
# 1-in-10 sampling rate for 10Mbit/s links is proportional to 1-in-1000 for 1G
# see http://blog.sflow.com/2013/02/sdn-and-large-flows.html
quietRun(
    'ovs-vsctl -- --id=@sflow create sflow agent=eth0 target=127.0.0.1 sampling=10 polling=20 -- -- set bridge s1 sflow=@sflow -- set bridge s2 sflow=@sflow -- set bridge s3 sflow=@sflow -- set bridge s4 sflow=@sflow'
)

# CLI
CLI(net)

# Clean up
net.stop()
Example #17
0
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    f0 = FabricDomain(1)
    f1 = FabricDomain(2)
    domains.extend([d0, f0, f1])

    for i in range(len(domains)):
        ctls = ctlsets[i].split(',')
        for c in range(len(ctls)):
            domains[i].addController('c%s%s' % (i, c),
                                     controller=RemoteController,
                                     ip=ctls[c])

    # netcfg for each domains
    # Note: Separate netcfg for domain0 is created in opticalUtils
    domainCfgs = []
    for i in range(0, len(ctlsets)):
        cfg = {}
        cfg['devices'] = {}
        cfg['ports'] = {}
        cfg['links'] = {}
        domainCfgs.append(cfg)

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    # adding cross-connect links
    for i in range(1, len(domains)):
        # add 10 cross-connect links between domains
        xcPortNo = 2
        ochPortNo = 10

        an = {"bandwidth": 10, "durable": "true"}
        net.addLink(domains[i].getTether(),
                    d0.getSwitches('OE%s' % i),
                    port1=xcPortNo,
                    port2=ochPortNo,
                    speed=10000,
                    annotations=an,
                    cls=LINCLink)

        xcId = 'of:' + domains[i].getSwitches(
            name=domains[i].getTether()).dpid + '/' + str(xcPortNo)
        ochId = 'of:' + d0.getSwitches('OE%s' % i).dpid + '/' + str(ochPortNo)
        domainCfgs[i]['ports'][xcId] = {'cross-connect': {'remote': ochId}}

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    # send netcfg json to each CO-ONOS
    for i in range(1, len(domains)):
        info('*** Pushing Topology.json to CO-ONOS %d\n' % i)
        filename = 'Topology%d.json' % i
        with open(filename, 'w') as outfile:
            json.dump(domainCfgs[i], outfile, indent=4, separators=(',', ': '))

        output = quietRun('%s/tools/test/bin/onos-netcfg %s %s &'\
                           % (LINCSwitch.onosDir,
                              domains[i].getControllers()[0].ip,
                              filename), shell=True)
        # successful output contains the two characters '{}'
        # if there is more output than this, there is an issue
        if output.strip('{}'):
            warn('***WARNING: Could not push topology file to ONOS: %s\n' %
                 output)

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
Example #18
0
info('* Creating Control Network\n')
ctopo = ControlNetwork(n=4, dataController=DataController)
cnet = Mininet(topo=ctopo, ipBase='192.168.123.0/24', build=False)
info('* Adding Control Network Controller\n')
cnet.addController('cc0')
info('* Starting Control Network\n')
cnet.build()
cnet.start()
dataControllers = cnet.hosts[:-1]  # ignore 'root' node

info('* Creating Data Network\n')
topo = TreeTopo(depth=2, fanout=2)
# UserSwitch so we can easily test failover
net = Mininet(topo=topo, switch=UserSwitch, build=False)
info('* Adding Controllers to Data Network\n')
net.controllers = dataControllers
net.build()
info('* Starting Data Network\n')
net.start()

CLI2(net, cnet=cnet)

info('* Stopping Data Network\n')
net.stop()

info('* Stopping Control Network\n')
# dataControllers have already been stopped
cnet.hosts = list(set(cnet.hosts) - set(dataControllers))
cnet.stop()