Exemplo n.º 1
0
 def setup():
     "Ensure any dependencies are loaded; if not, try to load them."
     moduleName = (
         'the OpenFlow reference kernel switch'
         ' (openflow.org) (NOTE: not available in OpenFlow 1.0+!)')
     pathCheck('ofprotocol', moduleName=moduleName)
     moduleDeps(subtract=OVS_KMOD, add=OF_KMOD, moduleName=moduleName)
Exemplo n.º 2
0
 def setup():
     "Ensure any dependencies are loaded; if not, try to load them."
     pathCheck('ovs-dpctl',
               'ovs-openflowd',
               moduleName='Open vSwitch (openvswitch.org)')
     if not os.path.exists('/dev/net/tun'):
         moduleDeps(add=TUN)
Exemplo n.º 3
0
    def build_topo_ee(self, network_topo, name, opts):
        """
        Build VNF Container object with given name and "opts" params
        network_topo - Topology object need to update
        name - Container name
        opts - Container instance params
        
        No return
        """
        settings = {}
        ip = opts.get('ip', None)
        if ip: settings['ip'] = ip

        defaultRoute = opts.get('defaultRoute', None)
        if defaultRoute: settings['defaultRoute'] = 'via ' + defaultRoute

        # Create the correct host class
        hostCls = EE
        params = {
            'name': name,
            'cls': hostCls,
            'cpu': opts['res']['cpu'],
            'mem': opts['res']['mem'],
            'ee_type': opts.get('ee_type', 'static'),
        }
        for o in [
                'remote_dpid', 'remote_port', 'remote_conf_ip',
                'remote_netconf_port', 'netconf_username', 'netconf_passwd',
                'local_intf_name'
        ]:
            params[o] = opts.get(o)

        params.update(settings)
        network_topo['ee'][opts['_id']] = {'params': params}

        if False:
            # Set the CPULimitedHost specific options
            if 'cores' in opts:
                network_topo['ee'][opts['_id']]['cores'] = opts['cores']
            if 'cpu' in opts:
                network_topo['ee'][opts['_id']]['frac'] = {
                    'f': opts['res']['cpu'],
                    'sched': opts['sched']
                }

        # Attach external interfaces
        if 'externalInterfaces' in opts:
            network_topo['ee'][
                opts['_id']]['extintf'] = opts['externalInterfaces']

        vlanif = opts.get('vlanInterfaces', None)
        if vlanif:
            self._debug('Checking that OS is VLAN prepared')
            self.pathCheck('vconfig', moduleName='vlan package')
            moduleDeps(add='8021q')
            network_topo['ee'][opts['_id']]['vlanif'] = vlanif

        self._debug("Add %s EE to mininet topo with parameters %s" %
                    (name, network_topo['ee'][opts['_id']]))
Exemplo n.º 4
0
    def setup():
        "Ensure any dependencies are loaded; if not, try to load them."
        moduleName = 'Open vSwitch (openvswitch.org)'
        pathCheck('ovs-vsctl',
                  'ovsdb-server',
                  'ovs-vswitchd',
                  moduleName=moduleName)
        moduleDeps(subtract=OF_KMOD, add=OVS_KMOD, moduleName=moduleName)

        if not checkRunning('ovsdb-server', 'ovs-vswitchd'):
            ovsdb_server_cmd = [
                'ovsdb-server', '--remote=punix:/tmp/mn-openvswitch-db.sock',
                '--remote=db:Open_vSwitch,manager_options'
            ]

            # We need to specify the DB path for OVS before 1.2.0
            ovs_ver = quietRun('ovsdb-server -V').split('\n')[0]
            # Note the space in front of the version strings.
            # TODO: Maybe we should extract the version instead of
            #       substr matching
            if ' 1.1.' in ovs_ver or ' 1.0.' in ovs_ver:
                ovsdb_server_cmd.insert(1,
                                        '/usr/local/etc/openvswitch/conf.db')

            # Every OVS command *except* ovsdb-server has a default path
            # to the database socket hardcoded. Problem is: if we need
            # to run ovsdb-server ourselves we cannot figure out what
            # this path is. Grr.
            ovsdb_instance = Popen(ovsdb_server_cmd,
                                   stderr=STDOUT,
                                   stdout=open('/tmp/mn-ovsdb-server.log',
                                               "w"))
            sleep(0.1)
            if ovsdb_instance.poll() is not None:
                error(
                    "ovsdb-server was not running and we could not start it - exiting\n"
                )
                sys.exit(1)
            vswitchd_instance = Popen(
                ['ovs-vswitchd', 'unix:/tmp/mn-openvswitch-db.sock'],
                stderr=STDOUT,
                stdout=open('/tmp/mn-vswitchd.log', "w"))
            if vswitchd_instance.poll() is not None:
                error(
                    "ovs-vswitchd was not running and we could not start it - exiting\n"
                )
                sys.exit(1)
            sleep(0.1)
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 --db=unix:/tmp/mn-openvswitch-db.sock '
        else:
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 '

        # Remove old mininet datapaths to make sure they don't interfere
        brlist = quietRun(OVSKernelSwitchNew.vsctl_cmd + ' list-br')
        for line in brlist.split("\n"):
            line = line.rstrip()
            if re.match('^mn-dp[0-9]+$', line):
                quietRun(OVSKernelSwitchNew.vsctl_cmd + ' del-br ' + line)
Exemplo n.º 5
0
    def build_topo_ee(self, network_topo, name, opts):
        """
        Build VNF Container object with given name and "opts" params
        network_topo - Topology object need to update
        name - Container name
        opts - Container instance params
        
        No return
        """
        settings = {}
        ip = opts.get('ip', None)
        if ip: settings['ip'] = ip

        defaultRoute = opts.get('defaultRoute', None)
        if defaultRoute: settings['defaultRoute'] = 'via ' + defaultRoute

        # Create the correct host class
        hostCls = EE
        params = {'name': name,
                  'cls': hostCls,
                  'cpu': opts['res']['cpu'],
                  'mem': opts['res']['mem'],
                  'ee_type': opts.get('ee_type', 'static'),
                  }
        for o in ['remote_dpid', 'remote_port', 'remote_conf_ip',
                  'remote_netconf_port', 'netconf_username',
                  'netconf_passwd', 'local_intf_name']:
            params[o] = opts.get(o)

        params.update(settings)
        network_topo['ee'][opts['_id']]={'params': params}

        if False:
            # Set the CPULimitedHost specific options
            if 'cores' in opts:
                network_topo['ee'][opts['_id']]['cores'] = opts['cores']
            if 'cpu' in opts:
                network_topo['ee'][opts['_id']]['frac']={'f':opts['res']['cpu'],
                                                         'sched':opts['sched']
                                                         }

        # Attach external interfaces
        if 'externalInterfaces' in opts:
            network_topo['ee'][opts['_id']]['extintf'] = opts['externalInterfaces']

        vlanif = opts.get('vlanInterfaces', None)
        if vlanif:
            self._debug('Checking that OS is VLAN prepared')
            self.pathCheck('vconfig', moduleName='vlan package')
            moduleDeps( add='8021q' )
            network_topo['ee'][opts['_id']]['vlanif'] = vlanif
            
        self._debug("Add %s EE to mininet topo with parameters %s" % (name, network_topo['ee'][opts['_id']]))
Exemplo n.º 6
0
    def setup():
        "Ensure any dependencies are loaded; if not, try to load them."
        moduleName='Open vSwitch (openvswitch.org)'
        pathCheck( 'ovs-vsctl', 'ovsdb-server', 'ovs-vswitchd', moduleName=moduleName )
        moduleDeps( subtract=OF_KMOD, add=OVS_KMOD, moduleName=moduleName )

        if not checkRunning('ovsdb-server', 'ovs-vswitchd'):
            ovsdb_server_cmd = ['ovsdb-server', 
                            '--remote=punix:/tmp/mn-openvswitch-db.sock', 
                            '--remote=db:Open_vSwitch,manager_options']

            # We need to specify the DB path for OVS before 1.2.0
            ovs_ver = quietRun('ovsdb-server -V').split('\n')[0]
            # Note the space in front of the version strings.
            # TODO: Maybe we should extract the version instead of 
            #       substr matching
            if ' 1.1.' in ovs_ver or ' 1.0.' in ovs_ver:
                ovsdb_server_cmd.insert(1, '/usr/local/etc/openvswitch/conf.db')
                
            # Every OVS command *except* ovsdb-server has a default path
            # to the database socket hardcoded. Problem is: if we need
            # to run ovsdb-server ourselves we cannot figure out what
            # this path is. Grr.
            ovsdb_instance = Popen(ovsdb_server_cmd, 
                         stderr = STDOUT, stdout = open('/tmp/mn-ovsdb-server.log', "w") )
            sleep(0.1)
            if ovsdb_instance.poll() is not None:
                error("ovsdb-server was not running and we could not start it - exiting\n")
                sys.exit(1)
            vswitchd_instance = Popen(['ovs-vswitchd', 'unix:/tmp/mn-openvswitch-db.sock'],
                          stderr = STDOUT, stdout = open('/tmp/mn-vswitchd.log', "w") )
            if vswitchd_instance.poll() is not None:
                error("ovs-vswitchd was not running and we could not start it - exiting\n")
                sys.exit(1)
            sleep(0.1)
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 --db=unix:/tmp/mn-openvswitch-db.sock '
        else:
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 '

        # Remove old mininet datapaths to make sure they don't interfere
        brlist = quietRun ( OVSKernelSwitchNew.vsctl_cmd + ' list-br' )
        for line in brlist.split("\n"):
            line = line.rstrip()
            if re.match('^mn-dp[0-9]+$', line):
                quietRun ( OVSKernelSwitchNew.vsctl_cmd + ' del-br ' + line )
Exemplo n.º 7
0
 def setup( cls ):
     "Ensure any dependencies are loaded; if not, try to load them."
     if not os.path.exists( '/dev/net/tun' ):
         moduleDeps( add=TUN )
Exemplo n.º 8
0
 def setup( cls ):
     "Ensure any dependencies are loaded; if not, try to load them."
     pathCheck( 'ovs-dpctl', 'ovs-openflowd',
                moduleName='Open vSwitch (openvswitch.org)')
     moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
Exemplo n.º 9
0
 def setup():
     "Ensure any dependencies are loaded; if not, try to load them."
     pathCheck( 'ofprotocol',
         moduleName='the OpenFlow reference kernel switch'
         ' (openflow.org) (NOTE: not available in OpenFlow 1.0!)' )
     moduleDeps( subtract=OVS_KMOD, add=OF_KMOD )
Exemplo n.º 10
0
 def setup():
     "Ensure any dependencies are loaded; if not, try to load them."
     pathCheck( 'ovs-dpctl', 'ovs-openflowd',
         moduleName='Open vSwitch (openvswitch.org)')
     if not os.path.exists( '/dev/net/tun' ):
         moduleDeps( add=TUN )
Exemplo n.º 11
0
    def setup():
        "Ensure any dependencies are loaded; if not, try to load them."
        moduleName='Open vSwitch (openvswitch.org)'
        pathCheck( 'ovs-vsctl', 'ovsdb-server', 'ovs-vswitchd', moduleName=moduleName )

        output = quietRun('ovs-vsctl --version')
        if "1.7" in output:
            # The kernel module name is changed some time in 2012
            # http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;
            # a=commitdiff;h=9b80f761bed9a32c1b0eb22ee3361966057ea973
            moduleDeps( subtract=OF_KMOD, add="openvswitch", moduleName=moduleName )
        else:
            moduleDeps( subtract=OF_KMOD, add=OVS_KMOD, moduleName=moduleName )

        if not checkRunning('ovsdb-server', 'ovs-vswitchd'):
            # db, socket, pid, log file paths
            ovsInstanceDir = "/var/run/openvswitch"
            quietRun('mkdir -p %s' % ovsInstanceDir)
            confDbPath = "%s/conf.db" % ovsInstanceDir
            dbSockPath = "%s/db.sock" % ovsInstanceDir
            ovsdbServerPidPath = "%s/ovsdb-server.pid" % ovsInstanceDir
            ovsdbServerLogPath = "%s/ovsdb-server.log" % ovsInstanceDir
            ovsVswitchdPidPath = "%s/ovs-vswitchd.pid" % ovsInstanceDir
            ovsVswitchdLogPath = "%s/ovs-vswitchd.log" % ovsInstanceDir

            # Create ovs database
            quietRun("ovsdb-tool create %s" % confDbPath)

            # Start ovsdb-server
            ovsdb_instance = Popen(['ovsdb-server',
                                    confDbPath,
                                    '--remote=punix:%s' % dbSockPath,
                                    '--remote=db:Open_vSwitch,manager_options',
                                    '--detach',
                                    '--pidfile=%s' % ovsdbServerPidPath,
                                    '--log-file=%s' % ovsdbServerLogPath],
                                   stderr = sys.stderr,
                                   stdout = sys.stdout)
            assert ovsdb_instance.wait() == 0

            # Start ovs-vswitchd
            vswitchd_instance = Popen(['ovs-vswitchd',
                                       'unix:%s' % dbSockPath,
                                       '--detach',
                                       '--pidfile=%s' % ovsVswitchdPidPath,
                                       '--log-file=%s' % ovsVswitchdLogPath],
                                      stderr = sys.stderr,
                                      stdout = sys.stdout)
            assert vswitchd_instance.wait() == 0

            # Append ovs-vsctl with database information
            OVSKernelSwitchNew.vsctl_cmd = \
                'ovs-vsctl -t 2 --db=unix:%s ' % dbSockPath

            # Save the pids of ovsdb-server and ovs-vswitchd
            OVSKernelSwitchNew.ovsdbServerPid = \
                int(file(ovsdbServerPidPath).read().strip())
            OVSKernelSwitchNew.ovsVswitchdPid = \
                int(file(ovsVswitchdPidPath).read().strip())
        else:
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 '

        # Remove old mininet datapaths to make sure they don't interfere
        brlist = quietRun ( OVSKernelSwitchNew.vsctl_cmd + ' list-br' )
        for line in brlist.split("\n"):
            line = line.rstrip()
            if re.match('^mn-dp[0-9]+$', line):
                quietRun ( OVSKernelSwitchNew.vsctl_cmd + ' del-br ' + line )
Exemplo n.º 12
0
    def setup():
        "Ensure any dependencies are loaded; if not, try to load them."
        moduleName = 'Open vSwitch (openvswitch.org)'
        pathCheck('ovs-vsctl',
                  'ovsdb-server',
                  'ovs-vswitchd',
                  moduleName=moduleName)

        output = quietRun('ovs-vsctl --version')
        if "1.7" in output:
            # The kernel module name is changed some time in 2012
            # http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;
            # a=commitdiff;h=9b80f761bed9a32c1b0eb22ee3361966057ea973
            moduleDeps(subtract=OF_KMOD,
                       add="openvswitch",
                       moduleName=moduleName)
        else:
            moduleDeps(subtract=OF_KMOD, add=OVS_KMOD, moduleName=moduleName)

        if not checkRunning('ovsdb-server', 'ovs-vswitchd'):
            # db, socket, pid, log file paths
            ovsInstanceDir = "/var/run/openvswitch"
            quietRun('mkdir -p %s' % ovsInstanceDir)
            confDbPath = "%s/conf.db" % ovsInstanceDir
            dbSockPath = "%s/db.sock" % ovsInstanceDir
            ovsdbServerPidPath = "%s/ovsdb-server.pid" % ovsInstanceDir
            ovsdbServerLogPath = "%s/ovsdb-server.log" % ovsInstanceDir
            ovsVswitchdPidPath = "%s/ovs-vswitchd.pid" % ovsInstanceDir
            ovsVswitchdLogPath = "%s/ovs-vswitchd.log" % ovsInstanceDir

            # Create ovs database
            quietRun("ovsdb-tool create %s" % confDbPath)

            # Start ovsdb-server
            ovsdb_instance = Popen([
                'ovsdb-server', confDbPath,
                '--remote=punix:%s' % dbSockPath,
                '--remote=db:Open_vSwitch,manager_options', '--detach',
                '--pidfile=%s' % ovsdbServerPidPath,
                '--log-file=%s' % ovsdbServerLogPath
            ],
                                   stderr=sys.stderr,
                                   stdout=sys.stdout)
            assert ovsdb_instance.wait() == 0

            # Start ovs-vswitchd
            vswitchd_instance = Popen([
                'ovs-vswitchd',
                'unix:%s' % dbSockPath, '--detach',
                '--pidfile=%s' % ovsVswitchdPidPath,
                '--log-file=%s' % ovsVswitchdLogPath
            ],
                                      stderr=sys.stderr,
                                      stdout=sys.stdout)
            assert vswitchd_instance.wait() == 0

            # Append ovs-vsctl with database information
            OVSKernelSwitchNew.vsctl_cmd = \
                'ovs-vsctl -t 2 --db=unix:%s ' % dbSockPath

            # Save the pids of ovsdb-server and ovs-vswitchd
            OVSKernelSwitchNew.ovsdbServerPid = \
                int(file(ovsdbServerPidPath).read().strip())
            OVSKernelSwitchNew.ovsVswitchdPid = \
                int(file(ovsVswitchdPidPath).read().strip())
        else:
            OVSKernelSwitchNew.vsctl_cmd = 'ovs-vsctl -t 2 '

        # Remove old mininet datapaths to make sure they don't interfere
        brlist = quietRun(OVSKernelSwitchNew.vsctl_cmd + ' list-br')
        for line in brlist.split("\n"):
            line = line.rstrip()
            if re.match('^mn-dp[0-9]+$', line):
                quietRun(OVSKernelSwitchNew.vsctl_cmd + ' del-br ' + line)