Bottle and Mininet

49 views
Skip to first unread message

Edison Albuquerque

unread,
May 26, 2019, 4:18:26 PM5/26/19
to bottlepy
I use REST in Mininet.
But since I found about Bottle I'm trying to use it instead.
The first code works all right as shown below.

from mininet.net import Mininet
from mininet.node import OVSController
from mininet.topo import SingleSwitchTopo
from mininet.link import Link, TCLink

from bottle import route, run, template
from bottle import get, post, request # or route

net = Mininet(topo=SingleSwitchTopo(2), link=TCLink,controller = OVSController)

@get('/cmd/<node>/<cmd>')
def cmd( node='h1', cmd='ifconfig%20h1-eth0' ):
    out, err, code = net.get( node ).pexec( cmd )
    return out + err

@route('/stop')
def stop():
        net.stop()

run(host='localhost', port=8080 )

But when I try to access a switch I receive 200 (OK) but nothing returns.

Somebody hep me, please.

Edison Albuquerque

unread,
May 27, 2019, 4:32:29 PM5/27/19
to bottlepy
I solved the problem. I didn't start the net so no switch was active.

Edison Albuquerque

unread,
May 27, 2019, 4:32:29 PM5/27/19
to bottlepy


Em domingo, 26 de maio de 2019 17:18:26 UTC-3, Edison Albuquerque escreveu:
Complementing my own post,  I realized that I CAN run linux commands from switch (s1). What I cannot do is run switch's OS commands as  I do without using Bottle.
Reply all
Reply to author
Forward
0 new messages