#!/usr/bin/python

"""
This example shows how to add an interface (for example a real
hardware interface) to a network after the network is created.
"""

import re

from mininet.cli import CLI
from mininet.log import setLogLevel, info, error
from mininet.net import Mininet
from mininet.topolib import TreeTopo
from mininet.util import quietRun

def checkIntf( intf ):
    "Make sure intf exists and is not configured."
    if ( ' %s:' % intf ) not in quietRun( 'ip link show' ):
        error( 'Error:', intf, 'does not exist!\n' )
        exit( 1 )
    ips = re.findall( r'\d+\.\d+\.\d+\.\d+', quietRun( 'ifconfig ' + intf ) )
    if ips:
        error( 'Error:', intf, 'has an IP address,'
               'and is probably in use!\n' )
        exit( 1 )

if __name__ == '__main__':
    setLogLevel( 'info' )

    newIntf = 'eth1'
    info( '*** Checking', newIntf, '\n' )
    checkIntf( newIntf )

    info( '*** Creating network\n' )
    net = Mininet( topo=TreeTopo( depth=1, fanout=2 ) )

    switch = net.switches[ 0 ]
    info( '*** Adding', newIntf, 'to switch', switch.name, '\n' )
    switch.addIntf( newIntf )

    net.start()
    CLI( net )
    net.stop()

@@ -267,16 +267,46 @@
 Mininet%0A
+from mininet.link import Intf%0A
 from min
@@ -838,23 +838,24 @@
  )%0A%0A    
-newIntf
+intfName
  = 'eth1
@@ -882,23 +882,24 @@
 cking', 
-newIntf
+intfName
 , '%5Cn' )
@@ -910,31 +910,32 @@
  checkIntf( 
-newIntf
+intfName
  )%0A%0A    info
@@ -1076,18 +1076,38 @@
 ding
-', newIntf
+ hardware interface', intfName
 , 't
@@ -1116,16 +1116,26 @@
 switch',
+%0A         
  switch.
@@ -1155,31 +1155,165 @@
     
-switch.addIntf( newIntf
+intf = Intf( intfName, node=switch )%0A%0A    info( '*** Note: you may need to reconfigure the interfaces for '%0A          'the Mininet hosts:%5Cn', net.hosts, '%5Cn'
  )%0A%0A

Change to use Intf() class rather than string for interface.