1

Im new to python and trying to have this python script to create a very simple custom topology in mininet in an Ubuntu live server However, when I enter "sudo Python SDN.py" it gives no result whatsoever

from mininet.topo import Topo  
class MyTopo( Topo ):  
    "Simple topology example."
    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        hostx = self.addHost( 'h1' )
        Sw1 = self.addSwitch('s1')

        # Add links
        self.addLink( Hostx, Sw1 )
        topos = { 'mytopo': ( lambda: MyTopo() ) }

any help is welcome, please note i'm only day 2 into python

1 Answer 1

2

You're never actually running anything! Take this for example:

def func(a):
    print(a)

This snippet won't do anything unless you actually make a call to the function, like this:

func("test")
Sign up to request clarification or add additional context in comments.

1 Comment

To add to this - In most programming languages, when writing functions, there's normally a difference between saying what you want to do and actually doing it. So here you've told Python what you want to do when you run the function. If you don't actually tell Python to run the function, nothing happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.