title: trouble in connecting to opendaylight using python API
body: <p>I tried this code in python to connect to controller:</p>
  <pre><code>from mininet.net import Mininet
  
  from mininet.node import Controller, RemoteController, OVSKernelSwitch, UserSwitch
  
  from mininet.cli import CLI
  
  from mininet.log import setLogLevel
  
  from mininet.link import Link, TCLink
  
   
  
  def topology():
  
          net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
  
   
  
          # Add hosts and switches
  
          h1 = net.addHost( 'h1', ip=&quot;10.0.1.10/24&quot;, mac=&quot;00:00:00:00:00:01&quot; )
  
          h2 = net.addHost( 'h2', ip=&quot;10.0.2.10/24&quot;, mac=&quot;00:00:00:00:00:02&quot; )
  
          r1 = net.addHost( 'r1')
  
          s1 = net.addSwitch( 's1')
  
          s2 = net.addSwitch( 's2')
  
          c0 = net.addController( 'c0', controller=RemoteController, ip='192.168.19.132', port=6633 )
  
   
  
          net.addLink( r1, s1 )
  
          net.addLink( r1, s2 )
  
          net.addLink( h1, s1 )
  
          net.addLink( h2, s2 )
  
          net.build()
  
          c0.start()
  
          s1.start( [c0] )
  
          s2.start( [c0] )
  
          r1.cmd(&quot;ifconfig r1-eth0 0&quot;)
  
          r1.cmd(&quot;ifconfig r1-eth1 0&quot;)
  
          r1.cmd(&quot;ifconfig r1-eth0 hw ether 00:00:00:00:01:01&quot;)
  
          r1.cmd(&quot;ifconfig r1-eth1 hw ether 00:00:00:00:01:02&quot;)
  
          r1.cmd(&quot;ip addr add 10.0.1.1/24 brd + dev r1-eth0&quot;)
  
          r1.cmd(&quot;ip addr add 10.0.2.1/24 brd + dev r1-eth1&quot;)
  
          r1.cmd(&quot;echo 1 &gt; /proc/sys/net/ipv4/ip_forward&quot;)
  
          h1.cmd(&quot;ip route add default via 10.0.1.1&quot;)
  
          h2.cmd(&quot;ip route add default via 10.0.2.1&quot;)
  
          s1.cmd(&quot;ovs-ofctl add-flow s1 priority=1,arp,actions=flood&quot;)
  
          s1.cmd(&quot;ovs-ofctl add-flow s1 priority=65535,ip,dl_dst=00:00:00:00:01:01,actions=output:1&quot;)
  
          s1.cmd(&quot;ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:2&quot;)
  
          s2.cmd(&quot;ovs-ofctl add-flow s2 priority=1,arp,actions=flood&quot;)
  
          s2.cmd(&quot;ovs-ofctl add-flow s2 priority=65535,ip,dl_dst=00:00:00:00:01:02,actions=output:1&quot;)
  
          s2.cmd(&quot;ovs-ofctl add-flow s2 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:2&quot;)
  
   
  
          print (&quot;*** Running CLI&quot;)
  
          CLI( net )
  
   
  
          print (&quot;*** Stopping network&quot;)
  
          net.stop()
  
        
  
  if __name__ == '__main__':
  
      setLogLevel( 'info' )
  
      topology()  
  </code></pre>
  <p>but when I check dlux in browser it doesn't show any nodes.
  if I use CLI and set the topology using sudo mn  and give it the ip of my controller then it works.
  why doesn't it work with python?
  I used ubuntu 20.04 and my opendaylight version is nitrogen.</p>
  <p>thanks in advance</p>