Пример #1
0
 def start( self, controllers ):
     """Start OpenFlow reference user datapath.
        Log to /tmp/sN-{ofd,ofp}.log.
        controllers: list of controller objects"""
     controller = controllers[ 0 ]
     ofdlog = '/tmp/' + self.name + '-ofd.log'
     ofplog = '/tmp/' + self.name + '-ofp.log'
     self.cmd( 'ifconfig lo up' )
     mac_str = ''
     if self.defaultMAC:
         # ofdatapath expects a string of hex digits with no colons.
         mac_str = ' -d ' + ''.join( self.defaultMAC.split( ':' ) )
     intfs = sorted( self.intfs.values() )
     if self.inNamespace:
         intfs = intfs[ :-1 ]
     if Compat.get_version() == '1.1.0':
         arg_fail = ''
     else:
         arg_fail = ' --fail=closed '
     self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
         ' punix:/tmp/' + self.name + mac_str + ' --no-slicing ' +
         ' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
     self.cmd( 'ofprotocol unix:/tmp/' + self.name +
         ' tcp:%s:%d' % ( controller.IP(), controller.port ) +
         arg_fail + self.opts +
         ' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
Пример #2
0
 def do_dpctl( self, line ):
     "Run dpctl command on all switches."
     args = line.split()
     if len(args) == 0:
         error( 'usage: dpctl command [arg1] [arg2] ...\n' )
         return
     if not self.mn.listenPort:
         error( "can't run dpctl w/no passive listening port\n")
         return
     for sw in self.mn.switches:
         output( '*** ' + sw.name + ' ' + ('-' * 72) + '\n' )
         addr = 'tcp:127.0.0.1:%i' % sw.listenPort
         if Compat.get_version() == '1.1.0':
             output( sw.cmd( 'dpctl ' + addr + ' ' + ' '.join(args) ) )
         else:
             output( sw.cmd( 'dpctl ' + ' '.join(args) + ' ' + addr ) )