Revision 8d493b68 examples/miniedit.py

View differences:

examples/miniedit.py
13 13
OpenFlow icon from https://www.opennetworking.org/
14 14
"""
15 15

  
16
MINIEDIT_VERSION = '2.2.0.0'
16
MINIEDIT_VERSION = '2.2.0.1'
17 17

  
18 18
from optparse import OptionParser
19 19
from Tkinter import *
......
161 161
    def setSwitchIP(self, ip):
162 162
        self.switchIP = ip
163 163

  
164
    def getOpenFlowVersion(self):
165
        return self.openFlowVersions
166

  
167
    def setOpenFlowVersion(self, versions):
168
        self.openFlowVersions = []
169
        if versions['ovsOf10'] == '1':
170
            self.openFlowVersions.append('OpenFlow10')
171
        if versions['ovsOf11'] == '1':
172
            self.openFlowVersions.append('OpenFlow11')
173
        if versions['ovsOf12'] == '1':
174
            self.openFlowVersions.append('OpenFlow12')
175
        if versions['ovsOf13'] == '1':
176
            self.openFlowVersions.append('OpenFlow13')
177

  
178
    def configureOpenFlowVersion(self):
179
        if not ( 'OpenFlow11' in self.openFlowVersions or
180
                 'OpenFlow12' in self.openFlowVersions or
181
                 'OpenFlow13' in self.openFlowVersions ):
182
            return
183

  
184
        protoList = ",".join(self.openFlowVersions)
185
        print 'Configuring OpenFlow to '+protoList
186
        self.cmd( 'ovs-vsctl -- set bridge', self, 'protocols='+protoList)
187

  
188 164
    def start( self, controllers ):
189 165
        # Call superclass constructor
190 166
        OVSSwitch.start( self, controllers )
191
        # Set OpenFlow Versions
192
        self.configureOpenFlowVersion()
193 167
        # Set Switch IP address
194 168
        if (self.switchIP is not None):
195 169
            self.cmd( 'ifconfig', self, self.switchIP )
......
2757 2731
                    switchClass = IVSSwitch
2758 2732
                else:
2759 2733
                    switchClass = customOvs
2734

  
2735
                if switchClass == customOvs:
2736
                    # Set OpenFlow versions
2737
                    self.openFlowVersions = []
2738
                    if self.appPrefs['openFlowVersions']['ovsOf10'] == '1':
2739
                        self.openFlowVersions.append('OpenFlow10')
2740
                    if self.appPrefs['openFlowVersions']['ovsOf11'] == '1':
2741
                        self.openFlowVersions.append('OpenFlow11')
2742
                    if self.appPrefs['openFlowVersions']['ovsOf12'] == '1':
2743
                        self.openFlowVersions.append('OpenFlow12')
2744
                    if self.appPrefs['openFlowVersions']['ovsOf13'] == '1':
2745
                        self.openFlowVersions.append('OpenFlow13')
2746
                    protoList = ",".join(self.openFlowVersions)
2747
                    switchParms['protocols'] = protoList
2760 2748
                newSwitch = net.addSwitch( name , cls=switchClass, **switchParms)
2749

  
2750
                # Some post startup config
2761 2751
                if switchClass == CustomUserSwitch:
2762 2752
                    if ('switchIP' in opts):
2763 2753
                        if (len(opts['switchIP']) > 0):
2764 2754
                            newSwitch.setSwitchIP(opts['switchIP'])
2765 2755
                if switchClass == customOvs:
2766
                    newSwitch.setOpenFlowVersion(self.appPrefs['openFlowVersions'])
2767 2756
                    if ('switchIP' in opts):
2768 2757
                        if (len(opts['switchIP']) > 0):
2769 2758
                            newSwitch.setSwitchIP(opts['switchIP'])

Also available in: Unified diff