Example #1
0
 def start( self, *args, **kwargs ):
     OVSSwitch.start( self, *args, **kwargs )
     OVSBridgeSTP.prio += 1
     self.cmd( 'ovs-vsctl set-fail-mode', self, 'standalone' )
     self.cmd( 'ovs-vsctl set Bridge', self,
               'stp_enable=true',
               'other_config:stp-priority=%d' % OVSBridgeSTP.prio )
Example #2
0
def emptyNet():

    net = Mininet(topo=None, build=False)
    c0 = Controller('c0', inNamespace=False)

    h1 = Host('h1')
    h2 = Host('h2')
    #intf1 = Intf("h1-eth1")
    #intf2 = Intf("h2-eth1")
    s1 = OVSSwitch('br0', inNamespace=False)    

    Link(h1, s1)
    Link(h2, s1)


    c0.start()
    s1.start([c0])

    net.start()    
    #s1.cmd('ovs-vsctl set bridge br0 protocols=OpenFlow13')
    CLI(net)

    net.stop()
    h1.stop()
    h2.stop()
    s1.stop()
    c0.stop()
 def start(self, *args, **kwargs):
     OVSSwitch.start(self, *args, **kwargs)
     OVSSwitchSTP.prio += 1
     self.cmd('ovs-vsctl set-fail-mode', self, 'standalone')
     self.cmd('ovs-vsctl set-controller', self)
     self.cmd('ovs-vsctl set Bridge', self, 'stp_enable=true',
              'other_config:stp-priority=%d' % OVSSwitchSTP.prio)
    def start(self, controllers):
        "Start up a new P4 switch"
        OVSSwitch.start(self, controllers)
        info("Starting P4 switch {}.\n".format(self.name))
        args = [self.sw_path]
        for port, intf in self.intfs.items():
            if not intf.IP():
                args.extend(['-i', str(port) + "@" + intf.name])
        if self.pcap_dump:
            args.append("--pcap")
            # args.append("--useFiles")
        if self.thrift_port:
            args.extend(['--thrift-port', str(self.thrift_port)])
        if self.nanomsg:
            args.extend(['--nanolog', self.nanomsg])
        args.extend(['--device-id', str(self.device_id)])
        P4Switch.device_id += 1
        args.append(self.json_path)
        if self.enable_debugger:
            args.append("--debugger")
        if self.log_console:
            args.append("--log-console")
        logfile = "/tmp/p4s.{}.log".format(self.name)
        info(' '.join(args) + "\n")

        pid = None
        with tempfile.NamedTemporaryFile() as f:
            # self.cmd(' '.join(args) + ' > /dev/null 2>&1 &')
            self.cmd(' '.join(args) + ' >' + logfile + ' 2>&1 & echo $! >> ' + f.name)
            pid = int(f.read())
        debug("P4 switch {} PID is {}.\n".format(self.name, pid))
        if not self.check_switch_started(pid):
            error("P4 switch {} did not start correctly.\n".format(self.name))
            exit(1)
        info("P4 switch {} has been started.\n".format(self.name))
Example #5
0
def emptyNet():

    net = Mininet(topo=None, build=False)
    c0 = Controller('c0', inNamespace=False)

    h1 = Host('h1')
    h2 = Host('h2')
    #intf1 = Intf("h1-eth1")
    #intf2 = Intf("h2-eth1")
    s1 = OVSSwitch('br0', inNamespace=False)

    Link(h1, s1)
    Link(h2, s1)

    c0.start()
    s1.start([c0])

    net.start()
    #s1.cmd('ovs-vsctl set bridge br0 protocols=OpenFlow13')
    CLI(net)

    net.stop()
    h1.stop()
    h2.stop()
    s1.stop()
    c0.stop()
 def start(self, controllers):
     # Call superclass constructor
     OVSSwitch.start(self, controllers)
     # Set OpenFlow VersionsHost
     self.configureOpenFlowVersion()
     # Set Switch IP address
     if self.switchIP is not None:
         self.cmd('ifconfig', self, self.switchIP)
Example #7
0
 def start( self, controllers ):
     # make sure controllers contains only a ControllerCluster
     assert len( controllers ) == 1
     ccluster = controllers[ 0 ]
     assert type( ccluster ) == ControllerCluster
     
     controller_list = ccluster.clist( self.name )
     # TODO: manage order of controllers to control mastership
     OVSSwitch.start( self, controllers=controller_list )
    def start(self, controllers):
        """
        Starts the switch, then notifies ONOS about the new device via Netcfg.
        """
        OVSSwitch.start(self, controllers)

        if not self.netcfg:
            # Do not push config to ONOS.
            return

        controllerIP = self.controllerIp(controllers)

        basicCfg = {"name": self.name, "driver": "ofdpa-ovs"}

        if self.longitude and self.latitude:
            basicCfg["longitude"] = self.longitude
            basicCfg["latitude"] = self.latitude

        cfgData = {"devices": {self.onosDeviceId: {"basic": basicCfg}}}
        with open(self.netcfgfile, 'w') as fp:
            json.dump(cfgData, fp, indent=4)

        # Build netcfg URL
        url = 'http://%s:8181/onos/v1/network/configuration/' % controllerIP
        # Instantiate password manager for HTTP auth
        pm = urllib2.HTTPPasswordMgrWithDefaultRealm()
        user = os.environ[
            'ONOS_WEB_USER'] if 'ONOS_WEB_USER' in os.environ else 'onos'
        password = os.environ[
            'ONOS_WEB_PASS'] if 'ONOS_WEB_PASS' in os.environ else 'rocks'
        pm.add_password(None, url, user, password)
        urllib2.install_opener(
            urllib2.build_opener(urllib2.HTTPBasicAuthHandler(pm)))
        try:
            # Push config data to controller
            req = urllib2.Request(url, json.dumps(cfgData),
                                  {'Content-Type': 'application/json'})
            f = urllib2.urlopen(req)
            print f.read()
            f.close()
        except urllib2.URLError as e:
            warn("*** WARN: unable to push config to ONOS (%s)\n" % e.reason)
Example #9
0
# Two local and one "external" controller (which is actually c0)

# Ignore the warning message that the remote isn't (yet) running

c0 = RemoteController( 'c0', ip='127.0.0.1')



cmap = { 's1': c0 }

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.build()

net.start()

CLI( net )

net.stop()

 def start( self, controllers ):
     return OVSSwitch.start( self, [ cmap[ self.name ] ] )
Example #11
0
 def start(self, controllers):
     return OVSSwitch.start(self, [])
Example #12
0
Link(h3, e2)
Link(h4, e2)
Link(h5, e3)
Link(h6, e3)
Link(h7, e4)
Link(h8, e4)
h1.setIP('10.0.0.1/24')
h2.setIP('10.0.0.2/24')
h3.setIP('10.0.0.3/24')
h4.setIP('10.0.0.4/24')
h5.setIP('10.0.0.5/24')
h6.setIP('10.0.0.6/24')
h7.setIP('10.0.0.7/24')
h8.setIP('10.0.0.8/24')
c1.start()
a1.start([c1])
a2.start([c1])
print h1.IP
print h2.IP
print h3.IP
print h4.IP
print h5.IP
print h6.IP
print h7.IP
print h8.IP
print 'Pinging ...'
print h1.cmd('ping -c3 ', h2.IP())
print h1.cmd('ping -c3 ', h3.IP())
a1.stop()
a2.stop()
c1.stop()
Example #13
0
 def start(self, controllers):
     OVSSwitch.start(self, controllers)
     self.cmd("ovs-vsctl set Bridge %s protocols=OpenFlow13" % self.name)
Example #14
0
 def start( self ):
     self.failMode=""
     return OVSSwitch.start( self, [  ] )
Example #15
0
 def start(self, controllers):
     if self.name[0:1] == "gw":
         return OVSSwitch.start(self, [controllers[1]])
     else:
         return OVSSwitch.start(self, [controllers[0]])
Example #16
0
#!/usr/bin/python

from mininet.topo import Topo
from mininet.node import Host, OVSSwitch, Controller
from mininet.link import Link

h1 = Host('h1')
h2 = Host('h2')
s1 = OVSSwitch('s1', inNamespace=False)
c0 = Controller('c0', inNamespace=False)
Link(h1,s1)
Link(h2,s1)
h1.setIP('10.1/8')
h2.setIP('10.2/8')
c0.start()
s1.start([c0])
print h1.cmd('ping -c1', h2.IP())
s1.stop()
c0.stop()
while( i <= n ** 2):                                                                                                         
    e1 = OVSSwitch( 'e%d', inNamespace=False ) % (i)
    Link( acount, ei ) 
    if i == n:
        count = count + 1    
    i = i + 1

i = 1
count = 1
while( i <= n ** 3) :    
    h1 = Host( 'h%d' ) % (i)
    Link( ecount, hi ) 
    hi.setIP( '10.0.0.1/24' )
    if i == n:
        count = count + 1    
    i = i + 1
                                                                                                                                                                                                                                                                        
c0.start()                                                                                                            
a1.start( [ c0 ] )
a2.start( [ c0 ] )                                                                                                    
print h1.IP
print h2.IP
print h3.IP
print h4.IP
print 'Pinging ...'
print h1.cmd( 'ping -c3 ', h2.IP() )     
print h1.cmd( 'ping -c3 ', h3.IP() )     
a1.stop()                               
a2.stop()                                                                              
c0.stop() 
Example #18
0
 def start(self, controllers):
     self.init_map(controllers[1:])
     return OVSSwitch.start(self, [self.map[self.name]])
Example #19
0
 def start( self, controllers ):
     print "starting ", self.name
     return OVSSwitch.start( self, [ cmap[ self.name ] ] )
Example #20
0
 def start(self, controllers):
     print "starting ", self.name
     return OVSSwitch.start(self, [cmap[self.name]])
 def start(self, controllers):
     my_num = int(self.name[1:]) - 1
     return OVSSwitch.start(self, [controllers[my_num % len(controllers)]])
Example #22
0
	def start(self, controllers):
		cmds = self.commands
		self.commands = []
		OVSSwitch.start(self, controllers)
		self.commands = self.commands + cmds
Example #23
0
				def start( self, defaultControllersNotUsed ):
					# Assign controllers on the switch start
					return OVSSwitch.start( self, [defaultController] )
Example #24
0
 def start(self, controllers):
     self.init_map(controllers[1:])
     return OVSSwitch.start(self, [self.map[self.name]])
Example #25
0
 def start(self, controllers):
     # This switch should always have no controllers
     OVSSwitch.start(self, [])
 def start(self, controllers):
     print "%s : %s" % (self.name, str(cmap.get(self.name, [])))
     return OVSSwitch.start(self, cmap.get(self.name, []))
Example #27
0
 def start(self, controllers):
     return OVSSwitch.start(self, [RemoteController('Controller', ip='127.0.0.1', port=6653)])
Example #28
0
 def start(self, controllers):
     return OVSSwitch.start(self,[{'c0': c0}])
Example #29
0
 def start( self, controllers ):
     assert len( controllers ) == 1
     c0 = controllers[ 0 ]
     assert type( c0 ) == ONOSCluster
     controllers = c0.clist()
     OVSSwitch.start( self, controllers )
Example #30
0
 def start(self, controllers):
     OVSSwitch.start(self, controllers)
     self.cmd("ovs-vsctl set Bridge %s protocols=OpenFlow13" % self.name)
Example #31
0
 def start(self, controllers):
     if self.custom_ctrl is not None:
         return OVSSwitch.start(self, [self.custom_ctrl])
     else:
         return OVSSwitch.start(self, controllers)
Example #32
0
 def start(self, controllers):
     print(self.name)
     return OVSSwitch.start(self, [_controllers[_translation[self.name]]])
Example #33
0
from mininet.link import Link

h1 = Host('h1')
h2 = Host('h2')
h3 = Host('h3')
h4 = Host('h4')
s1 = OVSSwitch('s1', inNamespace=False)
s2 = OVSSwitch('s2', inNamespace=False)
c0 = Controller('c0', inNamespace=False)
Link(h1, s1)
Link(h2, s1)
Link(h3, s2)
Link(h4, s2)
Link(s1, s2)
h1.setIP('10.0.0.1/24')
h2.setIP('10.0.0.2/24')
h3.setIP('10.0.0.3/24')
h4.setIP('10.0.0.4/24')
c0.start()
s1.start([c0])
s2.start([c0])
print h1.IP
print h2.IP
print h3.IP
print h4.IP
print 'Pinging ...'
print h1.cmd('ping -c3 ', h2.IP())
print h1.cmd('ping -c3 ', h3.IP())
s1.stop()
s2.stop()
c0.stop()
Example #34
0
 def start(self, controllers):
     assert len(controllers) == 1
     c0 = controllers[0]
     assert type(c0) == ONOSCluster
     controllers = c0.clist()
     OVSSwitch.start(self, controllers)
Example #35
0
 def start(self, controllers):
     return OVSSwitch.start(self, controllers)
 def start(self, controllers):
     return OVSSwitch.start(self, customcontroller)
Example #37
0
 def start(self, controllers):
     return OVSSwitch.start(self, [cmap[self.name]])
Example #38
0
 def start( self, *args, **kwargs ):
     OVSSwitch.start( self, *args, **kwargs )
     OVSBridgeSTP.prio += 1
     self.cmd( 'ovs-vsctl set Bridge', self,
               'stp_enable=true',
               'other_config:stp-priority=%d' % OVSBridgeSTP.prio )