onos.intfsDown() except KeyError: info('No such ONOS instance %s.\n' % instance) def do_onosdown(self, instance=None): """Disconnects an ONOS instance from the network""" self.onosupdown('down', instance) def do_onosup(self, instance=None): """"Connects an ONOS instance to the network""" self.onosupdown('up', instance) # For interactive use, exit on error exitOnError = dict(nodeOpts={'alertAction': 'exit'}) ONOSClusterInteractive = specialClass(ONOSCluster, defaults=exitOnError) ### Exports for bin/mn CLI = ONOSCLI controllers = { 'onos': ONOSClusterInteractive, 'default': ONOSClusterInteractive } # XXX Hack to change default controller as above doesn't work findController = lambda: controllers['default'] switches = { 'onos': ONOSOVSSwitch, 'onosovs': ONOSOVSSwitch,
### Test code def test(serverCount): "Test this setup" setLogLevel('info') net = Mininet(topo=SingleSwitchTopo(3), controller=[ONOSCluster('c0', serverCount)], switch=ONOSOVSSwitch) net.start() net.waitConnected() CLI(net) net.stop() # For interactive use, exit on error exitOnError = dict(nodeOpts={'alertAction': 'exit'}) ONOS = specialClass(ONOSCluster, defaults=exitOnError) ### Exports for bin/mn controllers = {'onos': ONOS, 'default': ONOS} # XXX Hack to change default controller as above doesn't work findController = lambda: controllers['default'] switches = { 'onos': ONOSOVSSwitch, 'onosovs': ONOSOVSSwitch, 'onosuser': ONOSUserSwitch, 'default': ONOSOVSSwitch } # Null topology so we can control an external/hardware network
from mininet.node import (Host, CPULimitedHost) from mininet.util import specialClass from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo from mininet.topolib import TreeTopo from bal.bcnode import (POWNode, POSNode) HOSTDEF = 'proc' HOSTS = { 'proc': Host, 'rt': specialClass(CPULimitedHost, defaults=dict(sched='rt')), 'cfs': specialClass(CPULimitedHost, defaults=dict(sched='cfs')), 'pow': POWNode, 'pos': POSNode } TOPODEF = 'none' TOPOS = { 'minimal': lambda: SingleSwitchTopo(k=2), 'linear': LinearTopo, 'reversed': SingleSwitchReversedTopo, 'single': SingleSwitchTopo, 'none': None, 'tree': TreeTopo }
# -b: keep using broadcasts; -f: quit after 1 reply # -U: gratuitous ARP update host.sendCmd( 'arping -bf -c', count, '-U -I', intf.name, intf.IP() ) for host in self.mn.net.hosts: # We could check the output here if desired host.waitOutput() info( '.' ) info( '\n' ) elapsed = time.time() - startTime debug( 'Completed in %.2f seconds\n' % elapsed ) # For interactive use, exit on error exitOnError = dict( nodeOpts={ 'alertAction': 'exit' } ) ONOSClusterInteractive = specialClass( ONOSCluster, defaults=exitOnError ) ### Exports for bin/mn CLI = ONOSCLI controllers = { 'onos': ONOSClusterInteractive, 'default': ONOSClusterInteractive } # XXX Hack to change default controller as above doesn't work findController = lambda: controllers[ 'default' ] switches = { 'onos': ONOSOVSSwitch, 'onosovs': ONOSOVSSwitch, 'onosuser': ONOSUserSwitch, 'default': ONOSOVSSwitch }