# Create a new ovsdb namespace self.switches = [] name = 'ovsdb%d' % cls.ovsdbCount kwargs.update( inNamespace=True ) kwargs.setdefault( 'privateDirs', self.privateDirs ) super( OVSDB, self ).__init__( name, **kwargs ) ovsdb = cnet.addHost( name, cls=self.self, **kwargs ) link = cnet.addLink( ovsdb, cnet.switches[ 0 ] ) cnet.switches[ 0 ].attach( link.intf2 ) ovsdb.configDefault() ovsdb.setDefaultRoute( 'via %s' % self.nat.intfs[ 0 ].IP() ) ovsdb.startOVS() # Install cleanup callback Cleanup.addCleanupCallback( OVSDB.cleanUpOVS ) class OVSSwitchNS( OVSSwitch ): "OVS Switch in shared OVSNS namespace" isSetup = False @classmethod def batchStartup( cls, switches ): result = [] for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb') ): switchGroup = list( switchGroup ) info( '(%s)' % ovsdb ) result += OVSSwitch.batchStartup( switchGroup, run=ovsdb.cmd ) return result
from mininet.clean import cleanup, killprocs, Cleanup from mininet.cli import CLI from mininet.log import info, setLogLevel from mininet.net import Containernet from mininet.node import Controller from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from pyftpdlib.servers import MultiprocessFTPServer from container.kali import Kali from controller import PoxController from typing import List, Tuple # Add a cleanup command to mininet.clean to clean pox controller Cleanup.addCleanupCallback(lambda: killprocs(PoxController.pox_comand)) class Scenario(object): """ Base scenario class. Performs the functions to run and document a scenario. Should be extended by any other implemented scenarios, all public methods are extensible. Extension classes should have the class name `Import` as per the `start` file. """ # These attributes allow for the filtering/ordering of scenarios when presenting them to students name = "Base Scenario" """Scenario name. Used in the produced documentation""" enabled = False """If the scenario should be shown to users.""" weight = -1