title: How to run a Mininet CLI command from inside python module
body: <p>I wrote a python module to generate a random topology using Mininet and connected OpenDayLight as the remote controller.</p>
  
  <p>I would like to pass a command to the mininet CLI, but from inside the python module. After generating the hosts and switches as well as connecting them to the remote controller, the module randomly chooses 2 hosts to act as Server and Client. 
  I am having trouble doing something similar to this, but from in-line inside the python module:</p>
  
  <pre><code>mininet&gt; h&lt;random_number&gt; sudo python HTTPTraffic.py &lt;SrcIP&gt; &lt;DstIP&gt;
  </code></pre>
  
  <p><code>HTTPTraffic.py</code> is another module that takes arguments <code>SrcIP</code> and <code>DstIP</code></p>
  
  <p>This is the part of the main module that elects 2 random hosts and gets their IPs. I would like the <code>HTTPTraffic.py</code> to run in the host corresponding to <code>SrcIP</code></p>
  
  <pre><code>Nodes = list(range(1,h))
  Src = random.choice(Nodes)         # randomly chooses 1 host
  Nodes.remove(Src)
  Dst = random.choice(Nodes)         # randomly chooses another host
  
  SrcName = 'h%s' %(Src)
  DstName = 'h%s' %(Dst)
  SrcNode=net.get(SrcName)
  DstNode=net.get(DstName)
  
  SrcIP = SrcNode.IP()               # IP retrieval of chosen hosts
  DstIP = DstNode.IP()
  print ('The Souce/Client is: '+ SrcName)
  print (SrcIP)
  print ('The Destination/Server is: '+ DstName)
  print (DstIP) 
  
  SrcName +".cmd('sudo python HTTPTraffic.py "+SrcIP+" " +DstIP+"')"    # this is where I am having trouble
  </code></pre>
  
  <p>From the <a href="http://mininet.org/sample-workflow/" rel="nofollow noreferrer">mininet API documentation</a> (See section 'Customizing a Network'), something like that is possible but I am having so much trouble doing it. Also, I would like for this command to run in the background while the main program runs. Any feedback is appreciated.</p>