Python - AttributeError: "Controller" object has no attribute "insertRule"

 
Vista:

AttributeError: "Controller" object has no attribute "insertRule"

Publicado por nemento (1 intervención) el 29/11/2020 17:45:49
I was trying to add some rules to the controller using python code, but appear an error, I dont know what need or if the funtionality of insert rule is correct, what is the roo case and how can I can fix it?

Error is :
mininet@mininet-vm:~/mininet/custom$ sudo mn --custom topo10.py --topo mytopo
*** Adding controller
Caught exception. Cleaning up...

AttributeError: 'Controller' object has no attribute 'insertRule'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

My code is :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
 
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call
 
class MyTopo( Topo ):
"Simple topology example."
 
def myNetwork():
 
net = Mininet( topo=None,
               build=False,
               ipBase='10.0.0.0/8')
 
info( '*** Adding controller\n' )
c0=net.addController(name='c0',
                  controller=Controller,
                  protocol='tcp',
                  port=6633)
 
c0.insertRule(src_address="10.0.0.0/8", dst_address = "10.0.0.5", nw_proto=6, tp_dst=80, action='drop')
c0.insertRule(src_address="10.0.0.3", dst_address = "10.0.0.5", nw_proto=6, tp_dst=80, action='allow')
 
info( '*** Add switches\n')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
s5 = net.addSwitch('s5', cls=OVSKernelSwitch)
s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
 
info( '*** Add hosts\n')
h2 = net.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute=None)
h3 = net.addHost('h3', cls=Host, ip='10.0.0.4', defaultRoute=None)
h1 = net.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute=None)
h0 = net.addHost('h0', cls=Host, ip='10.0.0.1', defaultRoute=None)
h4 = net.addHost('h4', cls=Host, ip='10.0.0.5', defaultRoute=None)
 
info( '*** Add links\n')
net.addLink(h0, s1)
net.addLink(h1, s2)
net.addLink(h2, s3)
net.addLink(h3, s4)
net.addLink(h4, s5)
net.addLink(s1, s2)
net.addLink(s2, s3)
net.addLink(s3, s4)
net.addLink(s4, s5)
 
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
    controller.start()
 
info( '*** Starting switches\n')
net.get('s2').start([c0])
net.get('s3').start([c0])
net.get('s1').start([c0])
net.get('s5').start([c0])
net.get('s4').start([c0])
 
info( '*** Post configure switches and hosts\n')
 
CLI(net)
if name == 'main':
setLogLevel( 'info' )
myNetwork()
 
topos = { 'mytopo': ( lambda: myNetwork() ) }
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder