diff --git a/bin/miniccnx b/bin/miniccnx
old mode 100644
new mode 100755
diff --git a/bin/miniccnxedit b/bin/miniccnxedit
old mode 100644
new mode 100755
index ec14483..5ca6191
--- a/bin/miniccnxedit
+++ b/bin/miniccnxedit
@@ -1,57 +1,620 @@
 #!/usr/bin/python
 
 """
-MiniCCNxEdit: a simple network editor for MiniCCNx
+MiniEdit: a simple network editor for Mininet
 
-Based on miniedit by Bob Lantz, April 2010
+This is a simple demonstration of how one might build a
+GUI application using Mininet as the network model.
 
-Carlos Cabral Jan, 2013
+Bob Lantz, April 2010
+Gregory Gee, July 2013
 
-
+Controller icon from http://semlabs.co.uk/
+OpenFlow icon from https://www.opennetworking.org/
 """
-import optparse
 
-from Tkinter import Frame, Button, Label, Scrollbar, Canvas
-from Tkinter import Menu, BitmapImage, PhotoImage, Wm, Toplevel
+MINIEDIT_VERSION = '2.2.0.1'
+
+from optparse import OptionParser
+from Tkinter import *
+from ttk import Notebook
+from tkMessageBox import showinfo, showerror, showwarning
+from subprocess import call
+import tkFont
+import csv
+import tkFileDialog
+import tkSimpleDialog
+import re
+import json
+from distutils.version import StrictVersion
+import os
+import sys
+from functools import partial
+
+if 'PYTHONPATH' in os.environ:
+    sys.path = os.environ[ 'PYTHONPATH' ].split( ':' ) + sys.path
 
 # someday: from ttk import *
 
-from mininet.log import setLogLevel
-from mininet.net import Mininet
-from mininet.util import ipStr
+from mininet.log import info, error, debug, output, setLogLevel
+from mininet.net import Mininet, VERSION
+from mininet.util import ipStr, netParse, ipAdd, quietRun
+from mininet.util import buildTopo
+from mininet.util import custom, customConstructor
 from mininet.term import makeTerm, cleanUpScreens
+from mininet.node import Controller, RemoteController, NOX, OVSController
+from mininet.node import CPULimitedHost, Host, Node
+from mininet.node import OVSKernelSwitch, OVSSwitch, UserSwitch
+from mininet.link import TCLink, Intf, Link
+from mininet.cli import CLI
+from mininet.moduledeps import moduleDeps, pathCheck
+from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
+from mininet.topolib import TreeTopo
+
+print 'MiniEdit running against MiniNet '+VERSION
+MININET_VERSION = re.sub(r'[^\d\.]', '', VERSION)
+if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
+    from mininet.node import IVSSwitch
+
+TOPODEF = 'none'
+TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
+          'linear': LinearTopo,
+          'reversed': SingleSwitchReversedTopo,
+          'single': SingleSwitchTopo,
+          'none': None,
+          'tree': TreeTopo }
+LINKDEF = 'default'
+LINKS = { 'default': Link,
+          'tc': TCLink }
+HOSTDEF = 'proc'
+HOSTS = { 'proc': Host,
+          'rt': custom( CPULimitedHost, sched='rt' ),
+          'cfs': custom( CPULimitedHost, sched='cfs' ) }
+
+class LegacyRouter( Node ):
+
+    def __init__( self, name, inNamespace=True, **params ):
+        Node.__init__( self, name, inNamespace, **params )
+
+    def config( self, **_params ):
+        if self.intfs:
+            self.setParam( _params, 'setIP', ip='0.0.0.0' )
+        r = Node.config( self, **_params )
+        self.cmd('sysctl -w net.ipv4.ip_forward=1')
+        return r
+
+class CustomDialog(object):
+
+        # TODO: Fix button placement and Title and window focus lock
+        def __init__(self, master, title):
+            self.top=Toplevel(master)
+
+            self.bodyFrame = Frame(self.top)
+            self.bodyFrame.grid(row=0, column=0, sticky='nswe')
+            self.body(self.bodyFrame)
+
+            #return self.b # initial focus
+            buttonFrame = Frame(self.top, relief='ridge', bd=3, bg='lightgrey')
+            buttonFrame.grid(row=1 , column=0, sticky='nswe')
+
+            okButton = Button(buttonFrame, width=8, text='OK', relief='groove',
+                       bd=4, command=self.okAction)
+            okButton.grid(row=0, column=0, sticky=E)
+
+            canlceButton = Button(buttonFrame, width=8, text='Cancel', relief='groove',
+                        bd=4, command=self.cancelAction)
+            canlceButton.grid(row=0, column=1, sticky=W)
+
+        def body(self, master):
+            self.rootFrame = master
+
+        def apply(self):
+            self.top.destroy()
+
+        def cancelAction(self):
+            self.top.destroy()
+
+        def okAction(self):
+            self.apply()
+            self.top.destroy()
+
+class HostDialog(CustomDialog):
+
+        def __init__(self, master, title, prefDefaults):
+
+            self.prefValues = prefDefaults
+            self.result = None
+
+            CustomDialog.__init__(self, master, title)
+
+        def body(self, master):
+            self.rootFrame = master
+            n = Notebook(self.rootFrame)
+            self.propFrame = Frame(n)
+            self.vlanFrame = Frame(n)
+            self.interfaceFrame = Frame(n)
+            self.mountFrame = Frame(n)
+            n.add(self.propFrame, text='Properties')
+            n.add(self.vlanFrame, text='VLAN Interfaces')
+            n.add(self.interfaceFrame, text='External Interfaces')
+            n.add(self.mountFrame, text='Private Directories')
+            n.pack()
+
+            ### TAB 1
+            # Field for Hostname
+            Label(self.propFrame, text="Hostname:").grid(row=0, sticky=E)
+            self.hostnameEntry = Entry(self.propFrame)
+            self.hostnameEntry.grid(row=0, column=1)
+            if 'hostname' in self.prefValues:
+                self.hostnameEntry.insert(0, self.prefValues['hostname'])
+
+            # Field for Switch IP
+            Label(self.propFrame, text="IP Address:").grid(row=1, sticky=E)
+            self.ipEntry = Entry(self.propFrame)
+            self.ipEntry.grid(row=1, column=1)
+            if 'ip' in self.prefValues:
+                self.ipEntry.insert(0, self.prefValues['ip'])
+
+            # Field for default route
+            Label(self.propFrame, text="Default Route:").grid(row=2, sticky=E)
+            self.routeEntry = Entry(self.propFrame)
+            self.routeEntry.grid(row=2, column=1)
+            if 'defaultRoute' in self.prefValues:
+                self.routeEntry.insert(0, self.prefValues['defaultRoute'])
+
+            # Field for CPU
+            Label(self.propFrame, text="Amount CPU:").grid(row=3, sticky=E)
+            self.cpuEntry = Entry(self.propFrame)
+            self.cpuEntry.grid(row=3, column=1)
+            if 'cpu' in self.prefValues:
+                self.cpuEntry.insert(0, str(self.prefValues['cpu']))
+            # Selection of Scheduler
+            if 'sched' in self.prefValues:
+                sched =  self.prefValues['sched']
+            else:
+                sched = 'host'
+            self.schedVar = StringVar(self.propFrame)
+            self.schedOption = OptionMenu(self.propFrame, self.schedVar, "host", "cfs", "rt")
+            self.schedOption.grid(row=3, column=2, sticky=W)
+            self.schedVar.set(sched)
+
+            # Selection of Cores
+            Label(self.propFrame, text="Cores:").grid(row=4, sticky=E)
+            self.coreEntry = Entry(self.propFrame)
+            self.coreEntry.grid(row=4, column=1)
+            if 'cores' in self.prefValues:
+                self.coreEntry.insert(1, self.prefValues['cores'])
+
+            # Start command
+            Label(self.propFrame, text="Start Command:").grid(row=5, sticky=E)
+            self.startEntry = Entry(self.propFrame)
+            self.startEntry.grid(row=5, column=1, sticky='nswe', columnspan=3)
+            if 'startCommand' in self.prefValues:
+                self.startEntry.insert(0, str(self.prefValues['startCommand']))
+            # Stop command
+            Label(self.propFrame, text="Stop Command:").grid(row=6, sticky=E)
+            self.stopEntry = Entry(self.propFrame)
+            self.stopEntry.grid(row=6, column=1, sticky='nswe', columnspan=3)
+            if 'stopCommand' in self.prefValues:
+                self.stopEntry.insert(0, str(self.prefValues['stopCommand']))
+
+            ### TAB 2
+            # External Interfaces
+            self.externalInterfaces = 0
+            Label(self.interfaceFrame, text="External Interface:").grid(row=0, column=0, sticky=E)
+            self.b = Button( self.interfaceFrame, text='Add', command=self.addInterface)
+            self.b.grid(row=0, column=1)
+
+            self.interfaceFrame = VerticalScrolledTable(self.interfaceFrame, rows=0, columns=1, title='External Interfaces')
+            self.interfaceFrame.grid(row=1, column=0, sticky='nswe', columnspan=2)
+            self.tableFrame = self.interfaceFrame.interior
+            self.tableFrame.addRow(value=['Interface Name'], readonly=True)
+
+            # Add defined interfaces
+            externalInterfaces = []
+            if 'externalInterfaces' in self.prefValues:
+                externalInterfaces = self.prefValues['externalInterfaces']
+
+            for externalInterface in externalInterfaces:
+                self.tableFrame.addRow(value=[externalInterface])
+
+            ### TAB 3
+            # VLAN Interfaces
+            self.vlanInterfaces = 0
+            Label(self.vlanFrame, text="VLAN Interface:").grid(row=0, column=0, sticky=E)
+            self.vlanButton = Button( self.vlanFrame, text='Add', command=self.addVlanInterface)
+            self.vlanButton.grid(row=0, column=1)
+
+            self.vlanFrame = VerticalScrolledTable(self.vlanFrame, rows=0, columns=2, title='VLAN Interfaces')
+            self.vlanFrame.grid(row=1, column=0, sticky='nswe', columnspan=2)
+            self.vlanTableFrame = self.vlanFrame.interior
+            self.vlanTableFrame.addRow(value=['IP Address','VLAN ID'], readonly=True)
+
+            vlanInterfaces = []
+            if 'vlanInterfaces' in self.prefValues:
+                vlanInterfaces = self.prefValues['vlanInterfaces']
+            for vlanInterface in vlanInterfaces:
+                self.vlanTableFrame.addRow(value=vlanInterface)
+
+            ### TAB 4
+            # Private Directories
+            self.privateDirectories = 0
+            Label(self.mountFrame, text="Private Directory:").grid(row=0, column=0, sticky=E)
+            self.mountButton = Button( self.mountFrame, text='Add', command=self.addDirectory)
+            self.mountButton.grid(row=0, column=1)
+
+            self.mountFrame = VerticalScrolledTable(self.mountFrame, rows=0, columns=2, title='Directories')
+            self.mountFrame.grid(row=1, column=0, sticky='nswe', columnspan=2)
+            self.mountTableFrame = self.mountFrame.interior
+            self.mountTableFrame.addRow(value=['Mount','Persistent Directory'], readonly=True)
+
+            directoryList = []
+            if 'privateDirectory' in self.prefValues:
+                directoryList = self.prefValues['privateDirectory']
+            for privateDir in directoryList:
+                if isinstance( privateDir, tuple ):
+                    self.mountTableFrame.addRow(value=privateDir)
+                else:
+                    self.mountTableFrame.addRow(value=[privateDir,''])
 
 
-def parse_args():
-    usage="""Usage: miniccnxedit [template_file]
-	If no template_file is given, generated template will be written
-	to the file miniccnx.conf in the current directory.
-    """
+        def addDirectory( self ):
+            self.mountTableFrame.addRow()
 
-    parser = optparse.OptionParser(usage)
+        def addVlanInterface( self ):
+            self.vlanTableFrame.addRow()
+
+        def addInterface( self ):
+            self.tableFrame.addRow()
+
+        def apply(self):
+            externalInterfaces = []
+            for row in range(self.tableFrame.rows):
+                if (len(self.tableFrame.get(row, 0)) > 0 and
+                    row > 0):
+                    externalInterfaces.append(self.tableFrame.get(row, 0))
+            vlanInterfaces = []
+            for row in range(self.vlanTableFrame.rows):
+                if (len(self.vlanTableFrame.get(row, 0)) > 0 and
+                    len(self.vlanTableFrame.get(row, 1)) > 0 and
+                    row > 0):
+                    vlanInterfaces.append([self.vlanTableFrame.get(row, 0), self.vlanTableFrame.get(row, 1)])
+            privateDirectories = []
+            for row in range(self.mountTableFrame.rows):
+                if (len(self.mountTableFrame.get(row, 0)) > 0 and row > 0):
+                    if(len(self.mountTableFrame.get(row, 1)) > 0):
+                        privateDirectories.append((self.mountTableFrame.get(row, 0), self.mountTableFrame.get(row, 1)))
+                    else:
+                        privateDirectories.append(self.mountTableFrame.get(row, 0))
+
+            results = {'cpu': self.cpuEntry.get(),
+                       'cores':self.coreEntry.get(),
+                       'sched':self.schedVar.get(),
+                       'hostname':self.hostnameEntry.get(),
+                       'ip':self.ipEntry.get(),
+                       'defaultRoute':self.routeEntry.get(),
+                       'startCommand':self.startEntry.get(),
+                       'stopCommand':self.stopEntry.get(),
+                       'privateDirectory':privateDirectories,
+                       'externalInterfaces':externalInterfaces,
+                       'vlanInterfaces':vlanInterfaces}
+            self.result = results
+
+
+class VerticalScrolledTable(LabelFrame):
+    """A pure Tkinter scrollable frame that actually works!
+
+    * Use the 'interior' attribute to place widgets inside the scrollable frame
+    * Construct and pack/place/grid normally
+    * This frame only allows vertical scrolling
     
-    _, arg = parser.parse_args()
+    """
+    def __init__(self, parent, rows=2, columns=2, title=None, *args, **kw):
+        LabelFrame.__init__(self, parent, text=title, padx=5, pady=5, *args, **kw)            
 
-    if len(arg) != 1:
-        arg = None
-    else:
-        arg = arg[0]
-        
-    return arg
+        # create a canvas object and a vertical scrollbar for scrolling it
+        vscrollbar = Scrollbar(self, orient=VERTICAL)
+        vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
+        canvas = Canvas(self, bd=0, highlightthickness=0,
+                        yscrollcommand=vscrollbar.set)
+        canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
+        vscrollbar.config(command=canvas.yview)
+
+        # reset the view
+        canvas.xview_moveto(0)
+        canvas.yview_moveto(0)
+
+        # create a frame inside the canvas which will be scrolled with it
+        self.interior = interior = TableFrame(canvas, rows=rows, columns=columns)
+        interior_id = canvas.create_window(0, 0, window=interior,
+                                           anchor=NW)
+
+        # track changes to the canvas and frame width and sync them,
+        # also updating the scrollbar
+        def _configure_interior(event):
+            # update the scrollbars to match the size of the inner frame
+            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
+            canvas.config(scrollregion="0 0 %s %s" % size)
+            if interior.winfo_reqwidth() != canvas.winfo_width():
+                # update the canvas's width to fit the inner frame
+                canvas.config(width=interior.winfo_reqwidth())
+        interior.bind('<Configure>', _configure_interior)
+
+        def _configure_canvas(event):
+            if interior.winfo_reqwidth() != canvas.winfo_width():
+                # update the inner frame's width to fill the canvas
+                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
+        canvas.bind('<Configure>', _configure_canvas)
+
+        return
+
+class TableFrame(Frame):
+    def __init__(self, parent, rows=2, columns=2):
+
+        Frame.__init__(self, parent, background="black")
+        self._widgets = []
+        self.rows = rows
+        self.columns = columns
+        for row in range(rows):
+            current_row = []
+            for column in range(columns):
+                label = Entry(self, borderwidth=0)
+                label.grid(row=row, column=column, sticky="wens", padx=1, pady=1)
+                current_row.append(label)
+            self._widgets.append(current_row)
+
+    def set(self, row, column, value):
+        widget = self._widgets[row][column]
+        widget.insert(0, value)
+
+    def get(self, row, column):
+        widget = self._widgets[row][column]
+        return widget.get()
+
+    def addRow( self, value=None, readonly=False ):
+        #print "Adding row " + str(self.rows +1)
+        current_row = []
+        for column in range(self.columns):
+            label = Entry(self, borderwidth=0)
+            label.grid(row=self.rows, column=column, sticky="wens", padx=1, pady=1)
+            if value is not None:
+                label.insert(0, value[column])
+            if (readonly == True):
+                label.configure(state='readonly')
+            current_row.append(label)
+        self._widgets.append(current_row)
+        self.update_idletasks()
+        self.rows += 1
+
+class LinkDialog(tkSimpleDialog.Dialog):
+
+        def __init__(self, parent, title, linkDefaults):
+
+            self.linkValues = linkDefaults
+
+            tkSimpleDialog.Dialog.__init__(self, parent, title)
+
+        def body(self, master):
+
+            self.var = StringVar(master)
+            Label(master, text="Bandwidth:").grid(row=0, sticky=E)
+            self.e1 = Entry(master)
+            self.e1.grid(row=0, column=1)
+            Label(master, text="Mbit").grid(row=0, column=2, sticky=W)
+            if 'bw' in self.linkValues:
+                self.e1.insert(0,str(self.linkValues['bw']))
+
+            Label(master, text="Delay:").grid(row=1, sticky=E)
+            self.e2 = Entry(master)
+            self.e2.grid(row=1, column=1)
+            if 'delay' in self.linkValues:
+                self.e2.insert(0, self.linkValues['delay'])
+
+            Label(master, text="Loss:").grid(row=2, sticky=E)
+            self.e3 = Entry(master)
+            self.e3.grid(row=2, column=1)
+            Label(master, text="%").grid(row=2, column=2, sticky=W)
+            if 'loss' in self.linkValues:
+                self.e3.insert(0, str(self.linkValues['loss']))
+
+            Label(master, text="Max Queue size:").grid(row=3, sticky=E)
+            self.e4 = Entry(master)
+            self.e4.grid(row=3, column=1)
+            if 'max_queue_size' in self.linkValues:
+                self.e4.insert(0, str(self.linkValues['max_queue_size']))
+
+            Label(master, text="Jitter:").grid(row=4, sticky=E)
+            self.e5 = Entry(master)
+            self.e5.grid(row=4, column=1)
+            if 'jitter' in self.linkValues:
+                self.e5.insert(0, self.linkValues['jitter'])
+
+            Label(master, text="Speedup:").grid(row=5, sticky=E)
+            self.e6 = Entry(master)
+            self.e6.grid(row=5, column=1)
+            if 'speedup' in self.linkValues:
+                self.e6.insert(0, str(self.linkValues['speedup']))
+
+            return self.e1 # initial focus
+
+        def apply(self):
+            self.result = {}
+            if (len(self.e1.get()) > 0):
+                self.result['bw'] = int(self.e1.get())
+            if (len(self.e2.get()) > 0):
+                self.result['delay'] = self.e2.get()
+            if (len(self.e3.get()) > 0):
+                self.result['loss'] = int(self.e3.get())
+            if (len(self.e4.get()) > 0):
+                self.result['max_queue_size'] = int(self.e4.get())
+            if (len(self.e5.get()) > 0):
+                self.result['jitter'] = self.e5.get()
+            if (len(self.e6.get()) > 0):
+                self.result['speedup'] = int(self.e6.get())
+
+class ControllerDialog(tkSimpleDialog.Dialog):
+
+        def __init__(self, parent, title, ctrlrDefaults=None):
+
+            if ctrlrDefaults:
+                self.ctrlrValues = ctrlrDefaults
+
+            tkSimpleDialog.Dialog.__init__(self, parent, title)
+
+        def body(self, master):
+
+            self.var = StringVar(master)
+            self.protcolvar = StringVar(master)
+
+            rowCount=0
+            # Field for Hostname
+            Label(master, text="Name:").grid(row=rowCount, sticky=E)
+            self.hostnameEntry = Entry(master)
+            self.hostnameEntry.grid(row=rowCount, column=1)
+            self.hostnameEntry.insert(0, self.ctrlrValues['hostname'])
+            rowCount+=1
+
+            # Field for Remove Controller Port
+            Label(master, text="Controller Port:").grid(row=rowCount, sticky=E)
+            self.e2 = Entry(master)
+            self.e2.grid(row=rowCount, column=1)
+            self.e2.insert(0, self.ctrlrValues['remotePort'])
+            rowCount+=1
+
+            # Field for Controller Type
+            Label(master, text="Controller Type:").grid(row=rowCount, sticky=E)
+            controllerType = self.ctrlrValues['controllerType']
+            self.o1 = OptionMenu(master, self.var, "Remote Controller", "In-Band Controller", "OpenFlow Reference", "OVS Controller")
+            self.o1.grid(row=rowCount, column=1, sticky=W)
+            if controllerType == 'ref':
+                self.var.set("OpenFlow Reference")
+            elif controllerType == 'inband':
+                self.var.set("In-Band Controller")
+            elif controllerType == 'remote':
+                self.var.set("Remote Controller")
+            else:
+                self.var.set("OVS Controller")
+            rowCount+=1
+
+            # Field for Controller Protcol
+            Label(master, text="Protocol:").grid(row=rowCount, sticky=E)
+            if 'controllerProtocol' in self.ctrlrValues:
+               controllerProtocol = self.ctrlrValues['controllerProtocol']
+            else:
+               controllerProtocol = 'tcp'
+            self.protcol = OptionMenu(master, self.protcolvar, "TCP", "SSL")
+            self.protcol.grid(row=rowCount, column=1, sticky=W)
+            if controllerProtocol == 'ssl':
+                self.protcolvar.set("SSL")
+            else:
+                self.protcolvar.set("TCP")
+            rowCount+=1
+
+            # Field for Remove Controller IP
+            remoteFrame= LabelFrame(master, text='Remote/In-Band Controller', padx=5, pady=5)
+            remoteFrame.grid(row=rowCount, column=0, columnspan=2, sticky=W)
+
+            Label(remoteFrame, text="IP Address:").grid(row=0, sticky=E)
+            self.e1 = Entry(remoteFrame)
+            self.e1.grid(row=0, column=1)
+            self.e1.insert(0, self.ctrlrValues['remoteIP'])
+            rowCount+=1
+
+            return self.hostnameEntry # initial focus
+
+        def apply(self):
+            self.result = { 'hostname': self.hostnameEntry.get(),
+                            'remoteIP': self.e1.get(),
+                            'remotePort': int(self.e2.get())}
+
+            controllerType = self.var.get()
+            if controllerType == 'Remote Controller':
+                self.result['controllerType'] = 'remote'
+            elif controllerType == 'In-Band Controller':
+                self.result['controllerType'] = 'inband'
+            elif controllerType == 'OpenFlow Reference':
+                self.result['controllerType'] = 'ref'
+            else:
+                self.result['controllerType'] = 'ovsc'
+            controllerProtocol = self.protcolvar.get()
+            if controllerProtocol == 'SSL':
+                self.result['controllerProtocol'] = 'ssl'
+            else:
+                self.result['controllerProtocol'] = 'tcp'
+
+class ToolTip(object):
+
+    def __init__(self, widget):
+        self.widget = widget
+        self.tipwindow = None
+        self.id = None
+        self.x = self.y = 0
+
+    def showtip(self, text):
+        "Display text in tooltip window"
+        self.text = text
+        if self.tipwindow or not self.text:
+            return
+        x, y, cx, cy = self.widget.bbox("insert")
+        x = x + self.widget.winfo_rootx() + 27
+        y = y + cy + self.widget.winfo_rooty() +27
+        self.tipwindow = tw = Toplevel(self.widget)
+        tw.wm_overrideredirect(1)
+        tw.wm_geometry("+%d+%d" % (x, y))
+        try:
+            # For Mac OS
+            tw.tk.call("::tk::unsupported::MacWindowStyle",
+                       "style", tw._w,
+                       "help", "noActivates")
+        except TclError:
+            pass
+        label = Label(tw, text=self.text, justify=LEFT,
+                      background="#ffffe0", relief=SOLID, borderwidth=1,
+                      font=("tahoma", "8", "normal"))
+        label.pack(ipadx=1)
+
+    def hidetip(self):
+        tw = self.tipwindow
+        self.tipwindow = None
+        if tw:
+            tw.destroy()
 
 class MiniEdit( Frame ):
 
     "A simple network editor for Mininet."
 
-    def __init__( self, parent=None, cheight=200, cwidth=500, template_file='miniccnx.conf' ):
+    def __init__( self, parent=None, cheight=600, cwidth=1000 ):
+
+        self.defaultIpBase='10.0.0.0/8'
+
+        self.nflowDefaults = {'nflowTarget':'',
+                              'nflowTimeout':'600',
+                              'nflowAddId':'0'}
+        self.sflowDefaults = {'sflowTarget':'',
+                              'sflowSampling':'400',
+                              'sflowHeader':'128',
+                              'sflowPolling':'30'}
+
+        self.appPrefs={
+            "ipBase": self.defaultIpBase,
+            "startCLI": "0",
+            "terminalType": 'xterm',
+            "switchType": 'ovs',
+            "dpctl": '',
+            'sflow':self.sflowDefaults,
+            'netflow':self.nflowDefaults,
+            'openFlowVersions':{'ovsOf10':'1',
+                                'ovsOf11':'0',
+                                'ovsOf12':'0',
+                                'ovsOf13':'0'}
+
+        }
+
 
         Frame.__init__( self, parent )
         self.action = None
-        self.appName = 'Mini-CCNx'
-        if template_file == None:
-            self.template_file='miniccnx.conf'
-        else:
-	        self.template_file = template_file
+        self.appName = 'MiniEdit'
+        self.fixedFont = tkFont.Font ( family="DejaVu Sans Mono", size="14" )
 
         # Style
         self.font = ( 'Geneva', 9 )
@@ -70,11 +633,14 @@
         self.cframe, self.canvas = self.createCanvas()
 
         # Toolbar
+        self.controllers = {}
+
+        # Toolbar
         self.images = miniEditImages()
         self.buttons = {}
         self.active = None
-        self.tools = ( 'Select', 'Host', 'Switch', 'Link' )
-        self.customColors = { 'Switch': 'darkGreen', 'Host': 'blue' }
+        self.tools = ( 'Select', 'Host', 'LegacyRouter', 'NetLink' )
+        self.customColors = { 'LegacyRouter': 'darkGreen', 'Host': 'blue' }
         self.toolbar = self.createToolbar()
 
         # Layout
@@ -89,7 +655,7 @@
 
         # Initialize node data
         self.nodeBindings = self.createNodeBindings()
-        self.nodePrefixes = { 'Switch': 's', 'Host': 'h' }
+        self.nodePrefixes = { 'LegacyRouter': 'r', 'Host': 'h'}
         self.widgetToItem = {}
         self.itemToWidget = {}
 
@@ -105,13 +671,32 @@
         self.bind( '<KeyPress-BackSpace>', self.deleteSelection )
         self.focus()
 
+	#Mouse bindings
+
+	self.bind( '<Button-1>', lambda event: self.clearPopups )
+
+        self.hostPopup = Menu(self.top, tearoff=0)
+        self.hostPopup.add_command(label='Host Options', font=self.font)
+        self.hostPopup.add_separator()
+        self.hostPopup.add_command(label='Properties', font=self.font, command=self.hostDetails )
+
+        self.legacyRouterPopup = Menu(self.top, tearoff=0)
+        self.legacyRouterPopup.add_command(label='Router Options', font=self.font)
+
+        self.linkPopup = Menu(self.top, tearoff=0)
+        self.linkPopup.add_command(label='Link Options', font=self.font)
+
         # Event handling initalization
         self.linkx = self.linky = self.linkItem = None
         self.lastSelection = None
 
         # Model initialization
         self.links = {}
-        self.nodeCount = 0
+        self.hostOpts = {}
+        self.switchOpts = {}
+        self.hostCount = 0
+        self.switchCount = 0
+        self.controllerCount = 0
         self.net = None
 
         # Close window gracefully
@@ -122,7 +707,7 @@
         self.stop()
         Frame.quit( self )
 
-    def createMenubar( self ):
+    def createMenubar( self ): # MODIFICADO - OK
         "Create our menu bar."
 
         font = self.font
@@ -130,6 +715,26 @@
         mbar = Menu( self.top, font=font )
         self.top.configure( menu=mbar )
 
+
+        #fileMenu = Menu( mbar, tearoff=False )
+        #mbar.add_cascade( label="File", font=font, menu=fileMenu )
+        #fileMenu.add_command( label="New", font=font, command=self.newTopology )
+        #fileMenu.add_command( label="Open", font=font, command=self.loadTopology )
+        #fileMenu.add_command( label="Save", font=font, command=self.saveTopology )
+        #fileMenu.add_command( label="Export Level 2 Script", font=font, command=self.exportScript )
+        #fileMenu.add_separator()
+        #fileMenu.add_command( label='Quit', command=self.quit, font=font )
+
+        #editMenu.add_command( label="Preferences", font=font, command=self.prefDetails)
+
+        #runMenu = Menu( mbar, tearoff=False )
+        #mbar.add_cascade( label="Run", font=font, menu=runMenu )
+        #runMenu.add_command( label="Run", font=font, command=self.doRun )
+        #runMenu.add_command( label="Stop", font=font, command=self.doStop )
+        #fileMenu.add_separator()
+        #runMenu.add_command( label='Show OVS Summary', font=font, command=self.ovsShow )
+        #runMenu.add_command( label='Root Terminal', font=font, command=self.rootTerminal )
+
         # Application menu
         appMenu = Menu( mbar, tearoff=False )
         mbar.add_cascade( label=self.appName, font=font, menu=appMenu )
@@ -137,28 +742,13 @@
                              font=font)
         appMenu.add_separator()
         appMenu.add_command( label='Quit', command=self.quit, font=font )
-
-        #fileMenu = Menu( mbar, tearoff=False )
-        #mbar.add_cascade( label="File", font=font, menu=fileMenu )
-        #fileMenu.add_command( label="Load...", font=font )
-        #fileMenu.add_separator()
-        #fileMenu.add_command( label="Save", font=font )
-        #fileMenu.add_separator()
-        #fileMenu.add_command( label="Print", font=font )
-
+	
         editMenu = Menu( mbar, tearoff=False )
         mbar.add_cascade( label="Edit", font=font, menu=editMenu )
         editMenu.add_command( label="Cut", font=font,
                               command=lambda: self.deleteSelection( None ) )
 
-       # runMenu = Menu( mbar, tearoff=False )
-       # mbar.add_cascade( label="Run", font=font, menu=runMenu )
-       # runMenu.add_command( label="Run", font=font, command=self.doRun )
-       # runMenu.add_command( label="Stop", font=font, command=self.doStop )
-       # runMenu.add_separator()
-       # runMenu.add_command( label='Xterm', font=font, command=self.xterm )
-
-    # Canvas
+    # Canvas - TUDO IGUAL - OK
 
     def createCanvas( self ):
         "Create and return our scrolling canvas frame."
@@ -213,7 +803,7 @@
 
     # Toolbar
 
-    def activate( self, toolName ):
+    def activate( self, toolName ): #IGUAL - OK
         "Activate a tool and press its button."
         # Adjust button appearance
         if self.active:
@@ -222,7 +812,17 @@
         # Activate dynamic bindings
         self.active = toolName
 
-    def createToolbar( self ):
+
+    def createToolTip(self, widget, text): #NOVA - CRIA HINTS E TIPS
+        toolTip = ToolTip(widget)
+        def enter(event):
+            toolTip.showtip(text)
+        def leave(event):
+            toolTip.hidetip()
+        widget.bind('<Enter>', enter)
+        widget.bind('<Leave>', leave)
+
+    def createToolbar( self ): #MODIFICADO - OK
         "Create and return our toolbar frame."
 
         toolbar = Frame( self )
@@ -232,7 +832,8 @@
             cmd = ( lambda t=tool: self.activate( t ) )
             b = Button( toolbar, text=tool, font=self.smallFont, command=cmd)
             if tool in self.images:
-                b.config( height=50, image=self.images[ tool ] )
+                b.config( height=35, image=self.images[ tool ] )
+                self.createToolTip(b, str(tool))
                 # b.config( compound='top' )
             b.pack( fill='x' )
             self.buttons[ tool ] = b
@@ -248,16 +849,17 @@
         #                fg=color, command=doCmd )
         #    b.pack( fill='x', side='bottom' )
 
-	for cmd, color in [ ( 'Generate', 'darkGreen' ) ]:
+	# abaixo copiado Mini-CCNx para criar botao Generate
+
+        for cmd, color in [ ( 'Generate', 'darkGreen' ) ]:
             doCmd = getattr( self, 'do' + cmd )
             b = Button( toolbar, text=cmd, font=self.smallFont,
                         fg=color, command=doCmd )
             b.pack( fill='x', side='bottom' )
 
-
         return toolbar
 
-    def doGenerate( self ):
+    def doGenerate( self ): #COPIA Mini-CCNx - GERA TEMPLATE
         "Generate template."
         self.activate( 'Select' )
         for tool in self.tools:
@@ -265,44 +867,644 @@
 
         self.buildTemplate()
 
-	for tool in self.tools:
+        for tool in self.tools:
             self.buttons[ tool ].config( state='normal' )
 
+    #def doRun( self ):
+    #    "Run command."
+    #    self.activate( 'Select' )
+    #    for tool in self.tools:
+    #        self.buttons[ tool ].config( state='disabled' )
+    #    self.start()
+
     def doStop( self ):
         "Stop command."
         self.stop()
         for tool in self.tools:
             self.buttons[ tool ].config( state='normal' )
 
-    def buildTemplate( self ):
-	"Generate template"
-	
-	template = open(self.template_file, 'w')
+    def buildTemplate( self ): #COPIA Mini-CCNx para criar Template
+        "Generate template"
 
-	# hosts
-	template.write('[nodes]\n')
-	for widget in self.widgetToItem:
+        template = open(self.template_file, 'w')
+
+        # hosts
+        template.write('[hosts]\n')
+        for widget in self.widgetToItem:
             name = widget[ 'text' ]
             tags = self.canvas.gettags( self.widgetToItem[ widget ] )
-	    if 'Host' in tags:
-		template.write(name + ':\n')	
+            if 'Host' in tags:
+                template.write(name + ':\n')
 
-	# switches/routers
-	# template.write('[routers]\n')
-	for widget in self.widgetToItem:
+        # switches/routers
+        template.write('[routers]\n')
+        for widget in self.widgetToItem:
             name = widget[ 'text' ]
             tags = self.canvas.gettags( self.widgetToItem[ widget ] )
-	    if 'Switch' in tags:
-		template.write(name + ':\n')	
+            if 'Switch' in tags:
+                template.write(name + ':\n')
 
         # Make links
-	template.write('[links]\n')
+        template.write('[links]\n')
         for link in self.links.values():
              ( src, dst ) = link
              srcName, dstName = src[ 'text' ], dst[ 'text' ]
              template.write(srcName + ':' + dstName + '\n')
 
-	template.close()   
+        template.close()
+
+    def addNode( self, node, nodeNum, x, y, name=None):
+        "Add a new node to our canvas."
+        if 'Switch' == node:
+            self.switchCount += 1
+        if 'Host' == node:
+            self.hostCount += 1
+        if 'Controller' == node:
+            self.controllerCount += 1
+        if name is None:
+            name = self.nodePrefixes[ node ] + nodeNum
+        self.addNamedNode(node, name, x, y)
+
+    def addNamedNode( self, node, name, x, y):
+        "Add a new node to our canvas."
+        c = self.canvas
+        icon = self.nodeIcon( node, name )
+        item = self.canvas.create_window( x, y, anchor='c', window=icon,
+                                          tags=node )
+        self.widgetToItem[ icon ] = item
+        self.itemToWidget[ item ] = icon
+        icon.links = {}
+
+    def convertJsonUnicode(self, input):
+        "Some part of Mininet don't like Unicode"
+        if isinstance(input, dict):
+            return {self.convertJsonUnicode(key): self.convertJsonUnicode(value) for key, value in input.iteritems()}
+        elif isinstance(input, list):
+            return [self.convertJsonUnicode(element) for element in input]
+        elif isinstance(input, unicode):
+            return input.encode('utf-8')
+        else:
+            return input
+
+    def loadTopology( self ):
+        "Load command."
+        c = self.canvas
+
+        myFormats = [
+            ('Mininet Topology','*.mn'),
+            ('All Files','*'),
+        ]
+        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
+        if f == None:
+            return
+        self.newTopology()
+        loadedTopology = self.convertJsonUnicode(json.load(f))
+
+        # Load application preferences
+        if 'application' in loadedTopology:
+            self.appPrefs = dict(self.appPrefs.items() + loadedTopology['application'].items())
+            if "ovsOf10" not in self.appPrefs["openFlowVersions"]:
+                self.appPrefs["openFlowVersions"]["ovsOf10"] = '0'
+            if "ovsOf11" not in self.appPrefs["openFlowVersions"]:
+                self.appPrefs["openFlowVersions"]["ovsOf11"] = '0'
+            if "ovsOf12" not in self.appPrefs["openFlowVersions"]:
+                self.appPrefs["openFlowVersions"]["ovsOf12"] = '0'
+            if "ovsOf13" not in self.appPrefs["openFlowVersions"]:
+                self.appPrefs["openFlowVersions"]["ovsOf13"] = '0'
+            if "sflow" not in self.appPrefs:
+                self.appPrefs["sflow"] = self.sflowDefaults
+            if "netflow" not in self.appPrefs:
+                self.appPrefs["netflow"] = self.nflowDefaults
+
+        # Load controllers
+        if ('controllers' in loadedTopology):
+            if (loadedTopology['version'] == '1'):
+                # This is old location of controller info
+                hostname = 'c0'
+                self.controllers = {}
+                self.controllers[hostname] = loadedTopology['controllers']['c0']
+                self.controllers[hostname]['hostname'] = hostname
+                #elf.addNode('Controller', 0, float(30), float(30), name=hostname)
+                icon = self.findWidgetByName(hostname)
+                #con.bind('<Button-3>', self.do_controllerPopup )
+            else:
+                controllers = loadedTopology['controllers']
+                for controller in controllers:
+                    hostname = controller['opts']['hostname']
+                    x = controller['x']
+                    y = controller['y']
+                    self.addNode('Controller', 0, float(x), float(y), name=hostname)
+                    self.controllers[hostname] = controller['opts']
+                    icon = self.findWidgetByName(hostname)
+                    #con.bind('<Button-3>', self.do_controllerPopup )
+
+
+        # Load hosts
+        hosts = loadedTopology['hosts']
+        for host in hosts:
+            nodeNum = host['number']
+            hostname = 'h'+nodeNum
+            if 'hostname' in host['opts']:
+                hostname = host['opts']['hostname']
+            else:
+                host['opts']['hostname'] = hostname
+            if 'nodeNum' not in host['opts']:
+                host['opts']['nodeNum'] = int(nodeNum)
+            x = host['x']
+            y = host['y']
+            self.addNode('Host', nodeNum, float(x), float(y), name=hostname)
+
+            # Fix JSON converting tuple to list when saving
+            if 'privateDirectory' in host['opts']:
+                newDirList = []
+                for privateDir in host['opts']['privateDirectory']:
+                    if isinstance( privateDir, list ):
+                        newDirList.append((privateDir[0],privateDir[1]))
+                    else:
+                        newDirList.append(privateDir)
+                host['opts']['privateDirectory'] = newDirList
+            self.hostOpts[hostname] = host['opts']
+            icon = self.findWidgetByName(hostname)
+            icon.bind('<Button-3>', self.do_hostPopup )
+
+        # Load switches
+        switches = loadedTopology['switches']
+        for switch in switches:
+            nodeNum = switch['number']
+            hostname = 's'+nodeNum
+            if 'controllers' not in switch['opts']:
+                switch['opts']['controllers'] = []
+            if 'switchType' not in switch['opts']:
+                switch['opts']['switchType'] = 'default'
+            if 'hostname' in switch['opts']:
+                hostname = switch['opts']['hostname']
+            else:
+                switch['opts']['hostname'] = hostname
+            if 'nodeNum' not in switch['opts']:
+                switch['opts']['nodeNum'] = int(nodeNum)
+            x = switch['x']
+            y = switch['y']
+            if switch['opts']['switchType'] == "legacyRouter":
+                self.addNode('LegacyRouter', nodeNum, float(x), float(y), name=hostname)
+                icon = self.findWidgetByName(hostname)
+                icon.bind('<Button-3>', self.do_legacyRouterPopup )
+
+        # Load links
+        links = loadedTopology['links']
+        for link in links:
+            srcNode = link['src']
+            src = self.findWidgetByName(srcNode)
+            sx, sy = self.canvas.coords( self.widgetToItem[ src ] )
+
+            destNode = link['dest']
+            dest = self.findWidgetByName(destNode)
+            dx, dy = self.canvas.coords( self.widgetToItem[ dest]  )
+
+            self.link = self.canvas.create_line( sx, sy, dx, dy, width=4,
+                                             fill='blue', tag='link' )
+            c.itemconfig(self.link, tags=c.gettags(self.link)+('data',))
+            self.addLink( src, dest, linkopts=link['opts'] )
+            self.createDataLinkBindings()
+            self.link = self.linkWidget = None
+
+        f.close
+
+    def findWidgetByName( self, name ):
+        for widget in self.widgetToItem:
+            if name ==  widget[ 'text' ]:
+                return widget
+
+    def newTopology( self ):
+        "New command."
+        for widget in self.widgetToItem.keys():
+            self.deleteItem( self.widgetToItem[ widget ] )
+        self.hostCount = 0
+        self.switchCount = 0
+        self.links = {}
+        self.hostOpts = {}
+        self.switchOpts = {}
+        self.appPrefs["ipBase"]= self.defaultIpBase
+
+    def saveTopology( self ):
+        "Save command."
+        myFormats = [
+            ('Mininet Topology','*.mn'),
+            ('All Files','*'),
+        ]
+
+        savingDictionary = {}
+        fileName = tkFileDialog.asksaveasfilename(filetypes=myFormats ,title="Save the topology as...")
+        if len(fileName ) > 0:
+            # Save Application preferences
+            savingDictionary['version'] = '2'
+
+            # Save Switches and Hosts
+            hostsToSave = []
+            switchesToSave = []
+            controllersToSave = []
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                x1, y1 = self.canvas.coords( self.widgetToItem[ widget ] )
+                if 'LegacyRouter' in tags:
+                    nodeNum = self.switchOpts[name]['nodeNum']
+                    nodeToSave = {'number':str(nodeNum),
+                                  'x':str(x1),
+                                  'y':str(y1),
+                                  'opts':self.switchOpts[name] }
+                    switchesToSave.append(nodeToSave)
+                elif 'Host' in tags:
+                    nodeNum = self.hostOpts[name]['nodeNum']
+                    nodeToSave = {'number':str(nodeNum),
+                                  'x':str(x1),
+                                  'y':str(y1),
+                                  'opts':self.hostOpts[name] }
+                    hostsToSave.append(nodeToSave)
+                else:
+                    raise Exception( "Cannot create mystery node: " + name )
+            savingDictionary['hosts'] = hostsToSave
+            savingDictionary['switches'] = switchesToSave
+            savingDictionary['controllers'] = controllersToSave
+
+            # Save Links
+            linksToSave = []
+            for link in self.links.values():
+                src = link['src']
+                dst = link['dest']
+                linkopts = link['linkOpts']
+
+                srcName, dstName = src[ 'text' ], dst[ 'text' ]
+                linkToSave = {'src':srcName,
+                              'dest':dstName,
+                              'opts':linkopts}
+                if link['type'] == 'data':
+                    linksToSave.append(linkToSave)
+            savingDictionary['links'] = linksToSave
+
+            # Save Application preferences
+            savingDictionary['application'] = self.appPrefs
+
+            try:
+                f = open(fileName, 'wb')
+                f.write(json.dumps(savingDictionary, sort_keys=True, indent=4, separators=(',', ': ')))
+            except Exception as er:
+                print er
+            finally:
+                f.close()
+
+    def exportScript( self ):
+        "Export command."
+        myFormats = [
+            ('Mininet Custom Topology','*.py'),
+            ('All Files','*'),
+        ]
+
+        fileName = tkFileDialog.asksaveasfilename(filetypes=myFormats ,title="Export the topology as...")
+        if len(fileName ) > 0:
+            #print "Now saving under %s" % fileName
+            f = open(fileName, 'wb')
+
+            f.write("#!/usr/bin/python\n")
+            f.write("\n")
+            f.write("from mininet.net import Mininet\n")
+            f.write("from mininet.node import Controller, RemoteController, OVSController\n")
+            f.write("from mininet.node import CPULimitedHost, Host, Node\n")
+            f.write("from mininet.node import OVSKernelSwitch, UserSwitch\n")
+            if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
+                f.write("from mininet.node import IVSSwitch\n")
+            f.write("from mininet.cli import CLI\n")
+            f.write("from mininet.log import setLogLevel, info\n")
+            f.write("from mininet.link import TCLink, Intf\n")
+            f.write("from subprocess import call\n")
+
+            inBandCtrl = False
+            hasLegacySwitch = False
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+
+                if 'Controller' in tags:
+                    opts = self.controllers[name]
+                    controllerType = opts['controllerType']
+                    if controllerType == 'inband':
+                        inBandCtrl = True
+
+            if inBandCtrl == True:
+                f.write("\n")
+                f.write("class InbandController( RemoteController ):\n")
+                f.write("\n")
+                f.write("    def checkListening( self ):\n")
+                f.write("        \"Overridden to do nothing.\"\n")
+                f.write("        return\n")
+
+            f.write("\n")
+            f.write("def myNetwork():\n")
+            f.write("\n")
+            f.write("    net = Mininet( topo=None,\n")
+            if len(self.appPrefs['dpctl']) > 0:
+                f.write("                   listenPort="+self.appPrefs['dpctl']+",\n")
+            f.write("                   build=False,\n")
+            f.write("                   ipBase='"+self.appPrefs['ipBase']+"')\n")
+            f.write("\n")
+            f.write("    info( '*** Adding controller\\n' )\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+    
+                if 'Controller' in tags:
+                    opts = self.controllers[name]
+                    controllerType = opts['controllerType']
+                    if 'controllerProtocol' in opts:
+                        controllerProtocol = opts['controllerProtocol']
+                    else:
+                        controllerProtocol = 'tcp'
+                    controllerIP = opts['remoteIP']
+                    controllerPort = opts['remotePort']
+
+    
+                    f.write("    "+name+"=net.addController(name='"+name+"',\n")
+        
+                    if controllerType == 'remote':
+                        f.write("                      controller=RemoteController,\n")
+                        f.write("                      ip='"+controllerIP+"',\n")
+                    elif controllerType == 'inband':
+                        f.write("                      controller=InbandController,\n")
+                        f.write("                      ip='"+controllerIP+"',\n")
+                    elif controllerType == 'ovsc':
+                        f.write("                      controller=OVSController,\n")
+                    else:
+                        f.write("                      controller=Controller,\n")
+        
+                    f.write("                      protocol='"+controllerProtocol+"',\n")
+                    f.write("                      port="+str(controllerPort)+")\n")
+                    f.write("\n")
+
+            # Save Switches and Hosts
+            f.write("    info( '*** Add switches\\n')\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'LegacyRouter' in tags:
+                    f.write("    "+name+" = net.addHost('"+name+"', cls=Node, ip='0.0.0.0')\n")
+                    f.write("    "+name+".cmd('sysctl -w net.ipv4.ip_forward=1')\n")
+                if 'LegacySwitch' in tags:
+                    f.write("    "+name+" = net.addSwitch('"+name+"', cls=OVSKernelSwitch, failMode='standalone')\n")
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    nodeNum = opts['nodeNum']
+                    f.write("    "+name+" = net.addSwitch('"+name+"'")
+                    if opts['switchType'] == 'default':
+                        if self.appPrefs['switchType'] == 'ivs':
+                            f.write(", cls=IVSSwitch")
+                        elif self.appPrefs['switchType'] == 'user':
+                            f.write(", cls=UserSwitch")
+                        elif self.appPrefs['switchType'] == 'userns':
+                            f.write(", cls=UserSwitch, inNamespace=True")
+                        else:
+                            f.write(", cls=OVSKernelSwitch")
+                    elif opts['switchType'] == 'ivs':
+                        f.write(", cls=IVSSwitch")
+                    elif opts['switchType'] == 'user':
+                        f.write(", cls=UserSwitch")
+                    elif opts['switchType'] == 'userns':
+                        f.write(", cls=UserSwitch, inNamespace=True")
+                    else:
+                        f.write(", cls=OVSKernelSwitch")
+                    if 'dpctl' in opts:
+                        f.write(", listenPort="+opts['dpctl'])
+                    if 'dpid' in opts:
+                        f.write(", dpid='"+opts['dpid']+"'")
+                    f.write(")\n")
+                    if ('externalInterfaces' in opts):
+                        for extInterface in opts['externalInterfaces']:
+                            f.write("    Intf( '"+extInterface+"', node="+name+" )\n")
+
+            f.write("\n")
+            f.write("    info( '*** Add hosts\\n')\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Host' in tags:
+                    opts = self.hostOpts[name]
+                    ip = None
+                    defaultRoute = None
+                    if 'defaultRoute' in opts and len(opts['defaultRoute']) > 0:
+                        defaultRoute = "'via "+opts['defaultRoute']+"'"
+                    else:
+                        defaultRoute = 'None'
+                    if 'ip' in opts and len(opts['ip']) > 0:
+                        ip = opts['ip']
+                    else:
+                        nodeNum = self.hostOpts[name]['nodeNum']
+                        ipBaseNum, prefixLen = netParse( self.appPrefs['ipBase'] )
+                        ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
+
+                    if 'cores' in opts or 'cpu' in opts:
+                        f.write("    "+name+" = net.addHost('"+name+"', cls=CPULimitedHost, ip='"+ip+"', defaultRoute="+defaultRoute+")\n")
+                        if 'cores' in opts:
+                            f.write("    "+name+".setCPUs(cores='"+opts['cores']+"')\n")
+                        if 'cpu' in opts:
+                            f.write("    "+name+".setCPUFrac(f="+str(opts['cpu'])+", sched='"+opts['sched']+"')\n")
+                    else:
+                        f.write("    "+name+" = net.addHost('"+name+"', cls=Host, ip='"+ip+"', defaultRoute="+defaultRoute+")\n")
+                    if ('externalInterfaces' in opts):
+                        for extInterface in opts['externalInterfaces']:
+                            f.write("    Intf( '"+extInterface+"', node="+name+" )\n")
+            f.write("\n")
+
+            # Save Links
+            f.write("    info( '*** Add links\\n')\n")
+            for key,linkDetail in self.links.iteritems():
+              tags = self.canvas.gettags(key)
+              if 'data' in tags:
+                optsExist = False
+                src = linkDetail['src']
+                dst = linkDetail['dest']
+                linkopts = linkDetail['linkOpts']
+                srcName, dstName = src[ 'text' ], dst[ 'text' ]
+                bw = ''
+                delay = ''
+                loss = ''
+                max_queue_size = ''
+                linkOpts = "{"
+                if 'bw' in linkopts:
+                    bw =  linkopts['bw']
+                    linkOpts = linkOpts + "'bw':"+str(bw)
+                    optsExist = True
+                if 'delay' in linkopts:
+                    delay =  linkopts['delay']
+                    if optsExist:
+                        linkOpts = linkOpts + ","
+                    linkOpts = linkOpts + "'delay':'"+linkopts['delay']+"'"
+                    optsExist = True
+                if 'loss' in linkopts:
+                    if optsExist:
+                        linkOpts = linkOpts + ","
+                    linkOpts = linkOpts + "'loss':"+str(linkopts['loss'])
+                    optsExist = True
+                if 'max_queue_size' in linkopts:
+                    if optsExist:
+                        linkOpts = linkOpts + ","
+                    linkOpts = linkOpts + "'max_queue_size':"+str(linkopts['max_queue_size'])
+                    optsExist = True
+                if 'jitter' in linkopts:
+                    if optsExist:
+                        linkOpts = linkOpts + ","
+                    linkOpts = linkOpts + "'jitter':'"+linkopts['jitter']+"'"
+                    optsExist = True
+                if 'speedup' in linkopts:
+                    if optsExist:
+                        linkOpts = linkOpts + ","
+                    linkOpts = linkOpts + "'speedup':"+str(linkopts['speedup'])
+                    optsExist = True
+
+                linkOpts = linkOpts + "}"
+                if optsExist:
+                    f.write("    "+srcName+dstName+" = "+linkOpts+"\n")
+                f.write("    net.addLink("+srcName+", "+dstName)
+                if optsExist:
+                    f.write(", cls=TCLink , **"+srcName+dstName)
+                f.write(")\n")
+
+            f.write("\n")
+            f.write("    info( '*** Starting network\\n')\n")
+            f.write("    net.build()\n")
+
+            f.write("    info( '*** Starting controllers\\n')\n")
+            f.write("    for controller in net.controllers:\n")
+            f.write("        controller.start()\n")
+            f.write("\n")
+
+            f.write("    info( '*** Starting switches\\n')\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Switch' in tags or 'LegacySwitch' in tags:
+                    opts = self.switchOpts[name]
+                    ctrlList = ",".join(opts['controllers'])
+                    f.write("    net.get('"+name+"').start(["+ctrlList+"])\n")
+
+            f.write("\n")
+
+            f.write("    info( '*** Post configure switches and hosts\\n')\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    if opts['switchType'] == 'default':
+                        if self.appPrefs['switchType'] == 'user':
+                            if ('switchIP' in opts):
+                                if (len(opts['switchIP'])>0):
+                                    f.write("    "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
+                        elif self.appPrefs['switchType'] == 'userns':
+                            if ('switchIP' in opts):
+                                if (len(opts['switchIP'])>0):
+                                    f.write("    "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
+                        elif self.appPrefs['switchType'] == 'ovs':
+                            if ('switchIP' in opts):
+                                if (len(opts['switchIP'])>0):
+                                    f.write("    "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
+                    elif opts['switchType'] == 'user':
+                        if ('switchIP' in opts):
+                            if (len(opts['switchIP'])>0):
+                                f.write("    "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
+                    elif opts['switchType'] == 'userns':
+                        if ('switchIP' in opts):
+                            if (len(opts['switchIP'])>0):
+                                f.write("    "+name+".cmd('ifconfig lo "+opts['switchIP']+"')\n")
+                    elif opts['switchType'] == 'ovs':
+                        if ('switchIP' in opts):
+                            if (len(opts['switchIP'])>0):
+                                f.write("    "+name+".cmd('ifconfig "+name+" "+opts['switchIP']+"')\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Host' in tags:
+                    opts = self.hostOpts[name]
+                    # Attach vlan interfaces
+                    if ('vlanInterfaces' in opts):
+                        for vlanInterface in opts['vlanInterfaces']:
+                            f.write("    "+name+".cmd('vconfig add "+name+"-eth0 "+vlanInterface[1]+"')\n")
+                            f.write("    "+name+".cmd('ifconfig "+name+"-eth0."+vlanInterface[1]+" "+vlanInterface[0]+"')\n")
+                    # Run User Defined Start Command
+                    if ('startCommand' in opts):
+                        f.write("    "+name+".cmdPrint('"+opts['startCommand']+"')\n")
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    # Run User Defined Start Command
+                    if ('startCommand' in opts):
+                        f.write("    "+name+".cmdPrint('"+opts['startCommand']+"')\n")
+
+            # Configure NetFlow
+            nflowValues = self.appPrefs['netflow']
+            if len(nflowValues['nflowTarget']) > 0:
+                nflowEnabled = False
+                nflowSwitches = ''
+                for widget in self.widgetToItem:
+                    name = widget[ 'text' ]
+                    tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+    
+                    if 'Switch' in tags:
+                        opts = self.switchOpts[name]
+                        if 'netflow' in opts:
+                            if opts['netflow'] == '1':
+                                nflowSwitches = nflowSwitches+' -- set Bridge '+name+' netflow=@MiniEditNF'
+                                nflowEnabled=True
+                if nflowEnabled:
+                    nflowCmd = 'ovs-vsctl -- --id=@MiniEditNF create NetFlow '+ 'target=\\\"'+nflowValues['nflowTarget']+'\\\" '+ 'active-timeout='+nflowValues['nflowTimeout']
+                    if nflowValues['nflowAddId'] == '1':
+                        nflowCmd = nflowCmd + ' add_id_to_interface=true'
+                    else:
+                        nflowCmd = nflowCmd + ' add_id_to_interface=false'
+                    f.write("    \n")
+                    f.write("    call('"+nflowCmd+nflowSwitches+"', shell=True)\n")
+
+            # Configure sFlow
+            sflowValues = self.appPrefs['sflow']
+            if len(sflowValues['sflowTarget']) > 0:
+                sflowEnabled = False
+                sflowSwitches = ''
+                for widget in self.widgetToItem:
+                    name = widget[ 'text' ]
+                    tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+    
+                    if 'Switch' in tags:
+                        opts = self.switchOpts[name]
+                        if 'sflow' in opts:
+                            if opts['sflow'] == '1':
+                                sflowSwitches = sflowSwitches+' -- set Bridge '+name+' sflow=@MiniEditSF'
+                                sflowEnabled=True
+                if sflowEnabled:
+                    sflowCmd = 'ovs-vsctl -- --id=@MiniEditSF create sFlow '+ 'target=\\\"'+sflowValues['sflowTarget']+'\\\" '+ 'header='+sflowValues['sflowHeader']+' '+ 'sampling='+sflowValues['sflowSampling']+' '+ 'polling='+sflowValues['sflowPolling']
+                    f.write("    \n")
+                    f.write("    call('"+sflowCmd+sflowSwitches+"', shell=True)\n")
+
+            f.write("\n")
+            f.write("    CLI(net)\n")
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Host' in tags:
+                    opts = self.hostOpts[name]
+                    # Run User Defined Stop Command
+                    if ('stopCommand' in opts):
+                        f.write("    "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    # Run User Defined Stop Command
+                    if ('stopCommand' in opts):
+                        f.write("    "+name+".cmdPrint('"+opts['stopCommand']+"')\n")
+
+            f.write("    net.stop()\n")
+            f.write("\n")
+            f.write("if __name__ == '__main__':\n")
+            f.write("    setLogLevel( 'info' )\n")
+            f.write("    myNetwork()\n")
+            f.write("\n")
+
+
+            f.close()
 
 
     # Generic canvas handler
@@ -369,6 +1571,16 @@
             self.deleteItem( self.selection )
         self.selectItem( None )
 
+    def clearPopups(self):
+	print 'Entrou funcao clear_popups'
+
+    	if isHostPopup == True:
+		print 'Hostpopup = true'
+    		self.hostPopup.unpost
+		isHostPopup = False
+	#if isRouterPopup == True
+	#if isLinkPopup == True
+
     def nodeIcon( self, node, name ):
         "Create a new node icon."
         icon = Button( self.canvas, image=self.images[ node ],
@@ -383,8 +1595,47 @@
         "Add a new node to our canvas."
         c = self.canvas
         x, y = c.canvasx( event.x ), c.canvasy( event.y )
-        self.nodeCount += 1
-        name = self.nodePrefixes[ node ] + str( self.nodeCount )
+        name = self.nodePrefixes[ node ]
+        if 'Switch' == node:
+            self.switchCount += 1
+            name = self.nodePrefixes[ node ] + str( self.switchCount )
+            self.switchOpts[name] = {}
+            self.switchOpts[name]['nodeNum']=self.switchCount
+            self.switchOpts[name]['hostname']=name
+            self.switchOpts[name]['switchType']='default'
+            self.switchOpts[name]['controllers']=[]
+        if 'LegacyRouter' == node:
+            self.switchCount += 1
+            name = self.nodePrefixes[ node ] + str( self.switchCount )
+            self.switchOpts[name] = {}
+            self.switchOpts[name]['nodeNum']=self.switchCount
+            self.switchOpts[name]['hostname']=name
+            self.switchOpts[name]['switchType']='legacyRouter'
+        if 'LegacySwitch' == node:
+            self.switchCount += 1
+            name = self.nodePrefixes[ node ] + str( self.switchCount )
+            self.switchOpts[name] = {}
+            self.switchOpts[name]['nodeNum']=self.switchCount
+            self.switchOpts[name]['hostname']=name
+            self.switchOpts[name]['switchType']='legacySwitch'
+            self.switchOpts[name]['controllers']=[]
+        if 'Host' == node:
+            self.hostCount += 1
+            name = self.nodePrefixes[ node ] + str( self.hostCount )
+            self.hostOpts[name] = {'sched':'host'}
+            self.hostOpts[name]['nodeNum']=self.hostCount
+            self.hostOpts[name]['hostname']=name
+        if 'Controller' == node:
+            name = self.nodePrefixes[ node ] + str( self.controllerCount )
+            ctrlr = { 'controllerType': 'ref',
+                      'hostname': name,
+                      'controllerProtocol': 'tcp',
+                      'remoteIP': '127.0.0.1',
+                      'remotePort': 6633}
+            self.controllers[name] = ctrlr
+            # We want to start controller count at 0
+            self.controllerCount += 1
+
         icon = self.nodeIcon( node, name )
         item = self.canvas.create_window( x, y, anchor='c', window=icon,
                                           tags=node )
@@ -392,16 +1643,32 @@
         self.itemToWidget[ item ] = icon
         self.selectItem( item )
         icon.links = {}
+        if 'LegacyRouter' == node:
+            icon.bind('<Button-3>', self.do_legacyRouterPopup )
+        if 'Host' == node:
+            icon.bind('<Button-3>', self.do_hostPopup )
+
+    def clickController( self, event ):
+        "Add a new Controller to our canvas."
+        self.newNode( 'Controller', event )
 
     def clickHost( self, event ):
         "Add a new host to our canvas."
         self.newNode( 'Host', event )
 
+    def clickLegacyRouter( self, event ):
+        "Add a new switch to our canvas."
+        self.newNode( 'LegacyRouter', event )
+
+    def clickLegacySwitch( self, event ):
+        "Add a new switch to our canvas."
+        self.newNode( 'LegacySwitch', event )
+
     def clickSwitch( self, event ):
         "Add a new switch to our canvas."
         self.newNode( 'Switch', event )
 
-    def dragLink( self, event ):
+    def dragNetLink( self, event ):
         "Drag a link's endpoint to another node."
         if self.link is None:
             return
@@ -411,7 +1678,7 @@
         c = self.canvas
         c.coords( self.link, self.linkx, self.linky, x, y )
 
-    def releaseLink( self, _event ):
+    def releaseNetLink( self, _event ):
         "Give up on the current link."
         if self.link is not None:
             self.canvas.delete( self.link )
@@ -426,8 +1693,7 @@
             '<B1-Motion>': self.dragNode,
             '<ButtonRelease-1>': self.releaseNode,
             '<Enter>': self.enterNode,
-            '<Leave>': self.leaveNode,
-            '<Double-ButtonPress-1>': self.xterm
+            '<Leave>': self.leaveNode
         }
         l = Label()  # lightweight-ish owner for bindings
         for event, binding in bindings.items():
@@ -449,7 +1715,7 @@
 
     def clickNode( self, event ):
         "Node click handler."
-        if self.active is 'Link':
+        if self.active is 'NetLink':
             self.startLink( event )
         else:
             self.selectNode( event )
@@ -457,14 +1723,14 @@
 
     def dragNode( self, event ):
         "Node drag handler."
-        if self.active is 'Link':
-            self.dragLink( event )
+        if self.active is 'NetLink':
+            self.dragNetLink( event )
         else:
             self.dragNodeAround( event )
 
     def releaseNode( self, event ):
         "Node release handler."
-        if self.active is 'Link':
+        if self.active is 'NetLink':
             self.finishLink( event )
 
     # Specific node handlers
@@ -491,21 +1757,10 @@
             item = self.widgetToItem[ dest ]
             x1, y1 = c.coords( item )
             c.coords( link, x, y, x1, y1 )
+        self.updateScrollRegion()
 
-    def startLink( self, event ):
-        "Start a new link."
-        if event.widget not in self.widgetToItem:
-            # Didn't click on a node
-            return
-        w = event.widget
-        item = self.widgetToItem[ w ]
-        x, y = self.canvas.coords( item )
-        self.link = self.canvas.create_line( x, y, x, y, width=4,
-                                             fill='blue', tag='link' )
-        self.linkx, self.linky = x, y
-        self.linkWidget = w
-        self.linkItem = item
-
+    def createControlLinkBindings( self ):
+        "Create a set of bindings for nodes."
         # Link bindings
         # Selection still needs a bit of work overall
         # Callbacks ignore event
@@ -516,17 +1771,59 @@
 
         def highlight( _event, link=self.link ):
             "Highlight item on mouse entry."
-            # self.selectItem( link )
+            self.selectItem( link )
+            self.canvas.itemconfig( link, fill='green' )
+
+        def unhighlight( _event, link=self.link ):
+            "Unhighlight item on mouse exit."
+            self.canvas.itemconfig( link, fill='red' )
+            #self.selectItem( None )
+
+        self.canvas.tag_bind( self.link, '<Enter>', highlight )
+        self.canvas.tag_bind( self.link, '<Leave>', unhighlight )
+        self.canvas.tag_bind( self.link, '<ButtonPress-1>', select )
+
+    def createDataLinkBindings( self ):
+        "Create a set of bindings for nodes."
+        # Link bindings
+        # Selection still needs a bit of work overall
+        # Callbacks ignore event
+
+        def select( _event, link=self.link ):
+            "Select item on mouse entry."
+            self.selectItem( link )
+
+        def highlight( _event, link=self.link ):
+            "Highlight item on mouse entry."
+            self.selectItem( link )
             self.canvas.itemconfig( link, fill='green' )
 
         def unhighlight( _event, link=self.link ):
             "Unhighlight item on mouse exit."
             self.canvas.itemconfig( link, fill='blue' )
-            # self.selectItem( None )
+            #self.selectItem( None )
 
         self.canvas.tag_bind( self.link, '<Enter>', highlight )
         self.canvas.tag_bind( self.link, '<Leave>', unhighlight )
         self.canvas.tag_bind( self.link, '<ButtonPress-1>', select )
+        self.canvas.tag_bind( self.link, '<Button-3>', self.do_linkPopup )
+
+
+    def startLink( self, event ):
+        "Start a new link."
+        if event.widget not in self.widgetToItem:
+            # Didn't click on a node
+            return
+
+        w = event.widget
+        item = self.widgetToItem[ w ]
+        x, y = self.canvas.coords( item )
+        self.link = self.canvas.create_line( x, y, x, y, width=4,
+                                             fill='blue', tag='link' )
+        self.linkx, self.linky = x, y
+        self.linkWidget = w
+        self.linkItem = item
+
 
     def finishLink( self, event ):
         "Finish creating a link"
@@ -540,17 +1837,48 @@
         dest = self.itemToWidget.get( target, None )
         if ( source is None or dest is None or source == dest
                 or dest in source.links or source in dest.links ):
-            self.releaseLink( event )
+            self.releaseNetLink( event )
             return
         # For now, don't allow hosts to be directly linked
-#        stags = self.canvas.gettags( self.widgetToItem[ source ] )
-#        dtags = self.canvas.gettags( target )
-#        if 'Host' in stags and 'Host' in dtags:
-#            self.releaseLink( event )
-#            return
+        stags = self.canvas.gettags( self.widgetToItem[ source ] )
+        dtags = self.canvas.gettags( target )
+        if (('Host' in stags and 'Host' in dtags) or
+           ('Controller' in dtags and 'LegacyRouter' in stags) or
+           ('Controller' in stags and 'LegacyRouter' in dtags) or
+           ('Controller' in dtags and 'LegacySwitch' in stags) or
+           ('Controller' in stags and 'LegacySwitch' in dtags) or
+           ('Controller' in dtags and 'Host' in stags) or
+           ('Controller' in stags and 'Host' in dtags) or
+           ('Controller' in stags and 'Controller' in dtags)):
+            self.releaseNetLink( event )
+            return
+
+        # Set link type
+        linkType='data'
+        if 'Controller' in stags or 'Controller' in dtags:
+            linkType='control'
+            c.itemconfig(self.link, dash=(6, 4, 2, 4), fill='red')
+            self.createControlLinkBindings()
+        else:
+            linkType='data'
+            self.createDataLinkBindings()
+        c.itemconfig(self.link, tags=c.gettags(self.link)+(linkType,))
+
         x, y = c.coords( target )
         c.coords( self.link, self.linkx, self.linky, x, y )
-        self.addLink( source, dest )
+        self.addLink( source, dest, linktype=linkType )
+        if linkType == 'control':
+            controllerName = ''
+            switchName = ''
+            if 'Controller' in stags:
+                controllerName = source[ 'text' ]
+                switchName = dest[ 'text' ]
+            else:
+                controllerName = dest[ 'text' ]
+                switchName = source[ 'text' ]
+
+            self.switchOpts[switchName]['controllers'].append(controllerName)
+
         # We're done
         self.link = self.linkWidget = None
 
@@ -563,18 +1891,23 @@
             bg = 'white'
             about = Toplevel( bg='white' )
             about.title( 'About' )
-            info = self.appName + ': a simple network editor for Mini-CCNx - based on Miniedit '
-            warning = 'Development version - not entirely functional!'
-	    author = 'Carlos Cabral, Jan 2013'
-            author2 = 'Miniedit by Bob Lantz <rlantz@cs>, April 2010'
+            info = self.appName + ': a simple network editor for MiniNet'
+            version = 'MiniEdit '+MINIEDIT_VERSION
+            author = 'Originally by: Bob Lantz <rlantz@cs>, April 2010'
+            enhancements = 'Enhancements by: Gregory Gee, Since July 2013'
+            www = 'http://gregorygee.wordpress.com/category/miniedit/'
             line1 = Label( about, text=info, font='Helvetica 10 bold', bg=bg )
-            line2 = Label( about, text=warning, font='Helvetica 9', bg=bg )
+            line2 = Label( about, text=version, font='Helvetica 9', bg=bg )
             line3 = Label( about, text=author, font='Helvetica 9', bg=bg )
-	    line4 = Label( about, text=author2, font='Helvetica 9', bg=bg )
+            line4 = Label( about, text=enhancements, font='Helvetica 9', bg=bg )
+            line5 = Entry( about, font='Helvetica 9', bg=bg, width=len(www), justify=CENTER )
+            line5.insert(0, www)
+            line5.configure(state='readonly')
             line1.pack( padx=20, pady=10 )
             line2.pack(pady=10 )
             line3.pack(pady=10 )
-	    line4.pack(pady=10 )
+            line4.pack(pady=10 )
+            line5.pack(pady=10 )
             hide = ( lambda about=about: about.withdraw() )
             self.aboutBox = about
             # Hide on close rather than destroying window
@@ -585,79 +1918,658 @@
     def createToolImages( self ):
         "Create toolbar (and icon) images."
 
+    def checkIntf( self, intf ):
+        "Make sure intf exists and is not configured."
+        if ( ' %s:' % intf ) not in quietRun( 'ip link show' ):
+            showerror(title="Error",
+                      message='External interface ' +intf + ' does not exist! Skipping.')
+            return False
+        ips = re.findall( r'\d+\.\d+\.\d+\.\d+', quietRun( 'ifconfig ' + intf ) )
+        if ips:
+            showerror(title="Error",
+                      message= intf + ' has an IP address and is probably in use! Skipping.' )
+            return False
+        return True
+
+    def hostDetails( self, _ignore=None ):
+        if ( self.selection is None or
+             self.net is not None or
+             self.selection not in self.itemToWidget ):
+            return
+        widget = self.itemToWidget[ self.selection ]
+        name = widget[ 'text' ]
+        tags = self.canvas.gettags( self.selection )
+        if 'Host' not in tags:
+            return
+
+        prefDefaults = self.hostOpts[name]
+        hostBox = HostDialog(self, title='Host Details', prefDefaults=prefDefaults)
+        self.master.wait_window(hostBox.top)
+        if hostBox.result:
+            newHostOpts = {'nodeNum':self.hostOpts[name]['nodeNum']}
+            newHostOpts['sched'] = hostBox.result['sched']
+            if len(hostBox.result['startCommand']) > 0:
+                newHostOpts['startCommand'] = hostBox.result['startCommand']
+            if len(hostBox.result['stopCommand']) > 0:
+                newHostOpts['stopCommand'] = hostBox.result['stopCommand']
+            if len(hostBox.result['cpu']) > 0:
+                newHostOpts['cpu'] = float(hostBox.result['cpu'])
+            if len(hostBox.result['cores']) > 0:
+                newHostOpts['cores'] = hostBox.result['cores']
+            if len(hostBox.result['hostname']) > 0:
+                newHostOpts['hostname'] = hostBox.result['hostname']
+                name = hostBox.result['hostname']
+                widget[ 'text' ] = name
+            if len(hostBox.result['defaultRoute']) > 0:
+                newHostOpts['defaultRoute'] = hostBox.result['defaultRoute']
+            if len(hostBox.result['ip']) > 0:
+                newHostOpts['ip'] = hostBox.result['ip']
+            if len(hostBox.result['externalInterfaces']) > 0:
+                newHostOpts['externalInterfaces'] = hostBox.result['externalInterfaces']
+            if len(hostBox.result['vlanInterfaces']) > 0:
+                newHostOpts['vlanInterfaces'] = hostBox.result['vlanInterfaces']
+            if len(hostBox.result['privateDirectory']) > 0:
+                newHostOpts['privateDirectory'] = hostBox.result['privateDirectory']
+            self.hostOpts[name] = newHostOpts
+            print 'New host details for ' + name + ' = ' + str(newHostOpts)
+
+    def switchDetails( self, _ignore=None ):
+        if ( self.selection is None or
+             self.net is not None or
+             self.selection not in self.itemToWidget ):
+            return
+        widget = self.itemToWidget[ self.selection ]
+        name = widget[ 'text' ]
+        tags = self.canvas.gettags( self.selection )
+        if 'Switch' not in tags:
+            return
+
+        prefDefaults = self.switchOpts[name]
+        switchBox = SwitchDialog(self, title='Switch Details', prefDefaults=prefDefaults)
+        self.master.wait_window(switchBox.top)
+        if switchBox.result:
+            newSwitchOpts = {'nodeNum':self.switchOpts[name]['nodeNum']}
+            newSwitchOpts['switchType'] = switchBox.result['switchType']
+            newSwitchOpts['controllers'] = self.switchOpts[name]['controllers']
+            if len(switchBox.result['startCommand']) > 0:
+                newSwitchOpts['startCommand'] = switchBox.result['startCommand']
+            if len(switchBox.result['stopCommand']) > 0:
+                newSwitchOpts['stopCommand'] = switchBox.result['stopCommand']
+            if len(switchBox.result['dpctl']) > 0:
+                newSwitchOpts['dpctl'] = switchBox.result['dpctl']
+            if len(switchBox.result['dpid']) > 0:
+                newSwitchOpts['dpid'] = switchBox.result['dpid']
+            if len(switchBox.result['hostname']) > 0:
+                newSwitchOpts['hostname'] = switchBox.result['hostname']
+                name = switchBox.result['hostname']
+                widget[ 'text' ] = name
+            if len(switchBox.result['externalInterfaces']) > 0:
+                newSwitchOpts['externalInterfaces'] = switchBox.result['externalInterfaces']
+            newSwitchOpts['switchIP'] = switchBox.result['switchIP']
+            newSwitchOpts['sflow'] = switchBox.result['sflow']
+            newSwitchOpts['netflow'] = switchBox.result['netflow']
+            self.switchOpts[name] = newSwitchOpts
+            print 'New switch details for ' + name + ' = ' + str(newSwitchOpts)
+
+    def linkUp( self ):
+        if ( self.selection is None or
+             self.net is None):
+            return
+        link = self.selection
+        linkDetail =  self.links[link]
+        src = linkDetail['src']
+        dst = linkDetail['dest']
+        srcName, dstName = src[ 'text' ], dst[ 'text' ]
+        self.net.configLinkStatus(srcName, dstName, 'up')
+        self.canvas.itemconfig(link, dash=())
+
+    def linkDown( self ):
+        if ( self.selection is None or
+             self.net is None):
+            return
+        link = self.selection
+        linkDetail =  self.links[link]
+        src = linkDetail['src']
+        dst = linkDetail['dest']
+        srcName, dstName = src[ 'text' ], dst[ 'text' ]
+        self.net.configLinkStatus(srcName, dstName, 'down')
+        self.canvas.itemconfig(link, dash=(4, 4))
+
+    def linkDetails( self, _ignore=None ):
+        if ( self.selection is None or
+             self.net is not None):
+            return
+        link = self.selection
+
+        linkDetail =  self.links[link]
+        src = linkDetail['src']
+        dest = linkDetail['dest']
+        linkopts = linkDetail['linkOpts']
+        linkBox = LinkDialog(self, title='Link Details', linkDefaults=linkopts)
+        if linkBox.result is not None:
+            linkDetail['linkOpts'] = linkBox.result
+            print 'New link details = ' + str(linkBox.result)
+
+    def prefDetails( self ):
+        prefDefaults = self.appPrefs
+        prefBox = PrefsDialog(self, title='Preferences', prefDefaults=prefDefaults)
+        print 'New Prefs = ' + str(prefBox.result)
+        if prefBox.result:
+            self.appPrefs = prefBox.result
+
+
+    def controllerDetails( self ):
+        if ( self.selection is None or
+             self.net is not None or
+             self.selection not in self.itemToWidget ):
+            return
+        widget = self.itemToWidget[ self.selection ]
+        name = widget[ 'text' ]
+        tags = self.canvas.gettags( self.selection )
+        oldName = name
+        if 'Controller' not in tags:
+            return
+
+        ctrlrBox = ControllerDialog(self, title='Controller Details', ctrlrDefaults=self.controllers[name])
+        if ctrlrBox.result:
+            #print 'Controller is ' + ctrlrBox.result[0]
+            if len(ctrlrBox.result['hostname']) > 0:
+                name = ctrlrBox.result['hostname']
+                widget[ 'text' ] = name
+            else:
+                ctrlrBox.result['hostname'] = name
+            self.controllers[name] = ctrlrBox.result
+            print 'New controller details for ' + name + ' = ' + str(self.controllers[name])
+            # Find references to controller and change name
+            if oldName != name:
+                for widget in self.widgetToItem:
+                    switchName = widget[ 'text' ]
+                    tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                    if 'Switch' in tags:
+                        switch = self.switchOpts[switchName]
+                        if oldName in switch['controllers']:
+                            switch['controllers'].remove(oldName)
+                            switch['controllers'].append(name)
+
+
+    def listBridge( self, _ignore=None ):
+        if ( self.selection is None or
+             self.net is None or
+             self.selection not in self.itemToWidget ):
+            return
+        name = self.itemToWidget[ self.selection ][ 'text' ]
+        tags = self.canvas.gettags( self.selection )
+
+        if name not in self.net.nameToNode:
+            return
+        if 'Switch' in tags or 'LegacySwitch' in tags:
+           call(["xterm -T 'Bridge Details' -sb -sl 2000 -e 'ovs-vsctl list bridge " + name + "; read -p \"Press Enter to close\"' &"], shell=True)
+
+    def ovsShow( self, _ignore=None ):
+        call(["xterm -T 'OVS Summary' -sb -sl 2000 -e 'ovs-vsctl show; read -p \"Press Enter to close\"' &"], shell=True)
+
+    def rootTerminal( self, _ignore=None ):
+        call(["xterm -T 'Root Terminal' -sb -sl 2000 &"], shell=True)
+
     # Model interface
     #
     # Ultimately we will either want to use a topo or
     # mininet object here, probably.
 
-    def addLink( self, source, dest ):
+    def addLink( self, source, dest, linktype='data', linkopts={} ):
         "Add link to model."
         source.links[ dest ] = self.link
         dest.links[ source ] = self.link
-        self.links[ self.link ] = ( source, dest )
+        self.links[ self.link ] = {'type' :linktype,
+                                   'src':source,
+                                   'dest':dest,
+                                   'linkOpts':linkopts}
 
     def deleteLink( self, link ):
         "Delete link from model."
         pair = self.links.get( link, None )
         if pair is not None:
-            source, dest = pair
+            source=pair['src']
+            dest=pair['dest']
             del source.links[ dest ]
             del dest.links[ source ]
+            stags = self.canvas.gettags( self.widgetToItem[ source ] )
+            dtags = self.canvas.gettags( self.widgetToItem[ dest ] )
+            ltags = self.canvas.gettags( link )
+
+            if 'control' in ltags:
+                controllerName = ''
+                switchName = ''
+                if 'Controller' in stags:
+                    controllerName = source[ 'text' ]
+                    switchName = dest[ 'text' ]
+                else:
+                    controllerName = dest[ 'text' ]
+                    switchName = source[ 'text' ]
+    
+                if controllerName in self.switchOpts[switchName]['controllers']:
+                    self.switchOpts[switchName]['controllers'].remove(controllerName)
+
+
         if link is not None:
             del self.links[ link ]
 
     def deleteNode( self, item ):
         "Delete node (and its links) from model."
+
         widget = self.itemToWidget[ item ]
+        tags = self.canvas.gettags(item)
+        if 'Controller' in tags:
+            # remove from switch controller lists
+            for serachwidget in self.widgetToItem:
+                name = serachwidget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ serachwidget ] )
+                if 'Switch' in tags:
+                    if widget['text'] in self.switchOpts[name]['controllers']:
+                        self.switchOpts[name]['controllers'].remove(widget['text'])
+            
         for link in widget.links.values():
             # Delete from view and model
             self.deleteItem( link )
         del self.itemToWidget[ item ]
         del self.widgetToItem[ widget ]
 
-    def build( self ):
-        "Build network based on our topology."
-
-        net = Mininet( topo=None )
-
-        # Make controller
-        net.addController( 'c0' )
+    def buildNodes( self, net):
         # Make nodes
+        print "Getting Hosts and Switches."
         for widget in self.widgetToItem:
             name = widget[ 'text' ]
             tags = self.canvas.gettags( self.widgetToItem[ widget ] )
-            nodeNum = int( name[ 1: ] )
+            #print name+' has '+str(tags)
+
             if 'Switch' in tags:
-                net.addSwitch( name )
+                opts = self.switchOpts[name]
+                #print str(opts)
+
+                # Create the correct switch class
+                switchClass = customOvs
+                switchParms={}
+                if 'dpctl' in opts:
+                    switchParms['listenPort']=int(opts['dpctl'])
+                if 'dpid' in opts:
+                    switchParms['dpid']=opts['dpid']
+                if opts['switchType'] == 'default':
+                    if self.appPrefs['switchType'] == 'ivs':
+                        switchClass = IVSSwitch
+                    elif self.appPrefs['switchType'] == 'user':
+                        switchClass = CustomUserSwitch
+                    elif self.appPrefs['switchType'] == 'userns':
+                        switchParms['inNamespace'] = True
+                        switchClass = CustomUserSwitch
+                    else:
+                        switchClass = customOvs
+                elif opts['switchType'] == 'user':
+                    switchClass = CustomUserSwitch
+                elif opts['switchType'] == 'userns':
+                    switchClass = CustomUserSwitch
+                    switchParms['inNamespace'] = True
+                elif opts['switchType'] == 'ivs':
+                    switchClass = IVSSwitch
+                else:
+                    switchClass = customOvs
+
+                if switchClass == customOvs:
+                    # Set OpenFlow versions
+                    self.openFlowVersions = []
+                    if self.appPrefs['openFlowVersions']['ovsOf10'] == '1':
+                        self.openFlowVersions.append('OpenFlow10')
+                    if self.appPrefs['openFlowVersions']['ovsOf11'] == '1':
+                        self.openFlowVersions.append('OpenFlow11')
+                    if self.appPrefs['openFlowVersions']['ovsOf12'] == '1':
+                        self.openFlowVersions.append('OpenFlow12')
+                    if self.appPrefs['openFlowVersions']['ovsOf13'] == '1':
+                        self.openFlowVersions.append('OpenFlow13')
+                    protoList = ",".join(self.openFlowVersions)
+                    switchParms['protocols'] = protoList
+                newSwitch = net.addSwitch( name , cls=switchClass, **switchParms)
+
+                # Some post startup config
+                if switchClass == CustomUserSwitch:
+                    if ('switchIP' in opts):
+                        if (len(opts['switchIP']) > 0):
+                            newSwitch.setSwitchIP(opts['switchIP'])
+                if switchClass == customOvs:
+                    if ('switchIP' in opts):
+                        if (len(opts['switchIP']) > 0):
+                            newSwitch.setSwitchIP(opts['switchIP'])
+
+                # Attach external interfaces
+                if ('externalInterfaces' in opts):
+                    for extInterface in opts['externalInterfaces']:
+                        if self.checkIntf(extInterface):
+                           Intf( extInterface, node=newSwitch )
+
+            elif 'LegacySwitch' in tags:
+                newSwitch = net.addSwitch( name , cls=LegacySwitch)
+            elif 'LegacyRouter' in tags:
+                newSwitch = net.addHost( name , cls=LegacyRouter)
             elif 'Host' in tags:
-                net.addHost( name, ip=ipStr( nodeNum ) )
+                opts = self.hostOpts[name]
+                #print str(opts)
+                ip = None
+                defaultRoute = None
+                if 'defaultRoute' in opts and len(opts['defaultRoute']) > 0:
+                    defaultRoute = 'via '+opts['defaultRoute']
+                if 'ip' in opts and len(opts['ip']) > 0:
+                    ip = opts['ip']
+                else:
+                    nodeNum = self.hostOpts[name]['nodeNum']
+                    ipBaseNum, prefixLen = netParse( self.appPrefs['ipBase'] )
+                    ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
+
+                # Create the correct host class
+                if 'cores' in opts or 'cpu' in opts:
+                    if ('privateDirectory' in opts):
+                        hostCls = partial( CPULimitedHost,
+                                           privateDirs=opts['privateDirectory'] )
+                    else:
+                        hostCls=CPULimitedHost
+                else:
+                    if ('privateDirectory' in opts):
+                        hostCls = partial( Host,
+                                           privateDirs=opts['privateDirectory'] )
+                    else:
+                        hostCls=Host
+                print hostCls
+                newHost = net.addHost( name,
+                                       cls=hostCls,
+                                       ip=ip,
+                                       defaultRoute=defaultRoute
+                                      )
+
+                # Set the CPULimitedHost specific options
+                if 'cores' in opts:
+                    newHost.setCPUs(cores = opts['cores'])
+                if 'cpu' in opts:
+                    newHost.setCPUFrac(f=opts['cpu'], sched=opts['sched'])
+
+                # Attach external interfaces
+                if ('externalInterfaces' in opts):
+                    for extInterface in opts['externalInterfaces']:
+                        if self.checkIntf(extInterface):
+                           Intf( extInterface, node=newHost )
+                if ('vlanInterfaces' in opts):
+                    if len(opts['vlanInterfaces']) > 0:
+                        print 'Checking that OS is VLAN prepared'
+                        self.pathCheck('vconfig', moduleName='vlan package')
+                        moduleDeps( add='8021q' )
+            elif 'Controller' in tags:
+                opts = self.controllers[name]
+
+                # Get controller info from panel
+                controllerType = opts['controllerType']
+                if 'controllerProtocol' in opts:
+                    controllerProtocol = opts['controllerProtocol']
+                else:
+                    controllerProtocol = 'tcp'
+                    opts['controllerProtocol'] = 'tcp'
+                controllerIP = opts['remoteIP']
+                controllerPort = opts['remotePort']
+
+                # Make controller
+                print 'Getting controller selection:'+controllerType
+                if controllerType == 'remote':
+                    net.addController(name=name,
+                                      controller=RemoteController,
+                                      ip=controllerIP,
+                                      protocol=controllerProtocol,
+                                      port=controllerPort)
+                elif controllerType == 'inband':
+                    net.addController(name=name,
+                                      controller=InbandController,
+                                      ip=controllerIP,
+                                      protocol=controllerProtocol,
+                                      port=controllerPort)
+                elif controllerType == 'ovsc':
+                    net.addController(name=name,
+                                      controller=OVSController,
+                                      protocol=controllerProtocol,
+                                      port=controllerPort)
+                else:
+                    net.addController(name=name,
+                                      controller=Controller,
+                                      protocol=controllerProtocol,
+                                      port=controllerPort)
+
             else:
                 raise Exception( "Cannot create mystery node: " + name )
+
+    def pathCheck( self, *args, **kwargs ):
+        "Make sure each program in *args can be found in $PATH."
+        moduleName = kwargs.get( 'moduleName', 'it' )
+        for arg in args:
+            if not quietRun( 'which ' + arg ):
+                showerror(title="Error",
+                      message= 'Cannot find required executable %s.\n' % arg +
+                       'Please make sure that %s is installed ' % moduleName +
+                       'and available in your $PATH.' )
+
+    def buildLinks( self, net):
         # Make links
-        for link in self.links.values():
-            ( src, dst ) = link
-            srcName, dstName = src[ 'text' ], dst[ 'text' ]
-            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
-            src.linkTo( dst )
+        print "Getting Links."
+        for key,link in self.links.iteritems():
+            tags = self.canvas.gettags(key)
+            if 'data' in tags:
+                src=link['src']
+                dst=link['dest']
+                linkopts=link['linkOpts']
+                srcName, dstName = src[ 'text' ], dst[ 'text' ]
+                srcNode, dstNode = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
+                if linkopts:
+                    net.addLink(srcNode, dstNode, cls=TCLink, **linkopts)
+                else:
+                    #print str(srcNode)
+                    #print str(dstNode)
+                    net.addLink(srcNode, dstNode)
+                self.canvas.itemconfig(key, dash=())
+
+
+    def build( self ):
+        print "Build network based on our topology."
+
+        dpctl = None
+        if len(self.appPrefs['dpctl']) > 0:
+            dpctl = int(self.appPrefs['dpctl'])
+        net = Mininet( topo=None,
+                       listenPort=dpctl,
+                       build=False,
+                       ipBase=self.appPrefs['ipBase'] )
+
+        self.buildNodes(net)
+        self.buildLinks(net)
 
         # Build network (we have to do this separately at the moment )
         net.build()
 
         return net
 
+
+    def postStartSetup( self ):
+
+        # Setup host details
+        for widget in self.widgetToItem:
+            name = widget[ 'text' ]
+            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+            if 'Host' in tags:
+                newHost = self.net.get(name)
+                opts = self.hostOpts[name]
+                # Attach vlan interfaces
+                if ('vlanInterfaces' in opts):
+                    for vlanInterface in opts['vlanInterfaces']:
+                        print 'adding vlan interface '+vlanInterface[1]
+                        newHost.cmdPrint('ifconfig '+name+'-eth0.'+vlanInterface[1]+' '+vlanInterface[0])
+                # Run User Defined Start Command
+                if ('startCommand' in opts):
+                    newHost.cmdPrint(opts['startCommand'])
+            if 'Switch' in tags:
+                newNode = self.net.get(name)
+                opts = self.switchOpts[name]
+                # Run User Defined Start Command
+                if ('startCommand' in opts):
+                    newNode.cmdPrint(opts['startCommand'])
+
+
+        # Configure NetFlow
+        nflowValues = self.appPrefs['netflow']
+        if len(nflowValues['nflowTarget']) > 0:
+            nflowEnabled = False
+            nflowSwitches = ''
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+    
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    if 'netflow' in opts:
+                        if opts['netflow'] == '1':
+                            print name+' has Netflow enabled'
+                            nflowSwitches = nflowSwitches+' -- set Bridge '+name+' netflow=@MiniEditNF'
+                            nflowEnabled=True
+            if nflowEnabled:
+                nflowCmd = 'ovs-vsctl -- --id=@MiniEditNF create NetFlow '+ 'target=\\\"'+nflowValues['nflowTarget']+'\\\" '+ 'active-timeout='+nflowValues['nflowTimeout']
+                if nflowValues['nflowAddId'] == '1':
+                    nflowCmd = nflowCmd + ' add_id_to_interface=true'
+                else:
+                    nflowCmd = nflowCmd + ' add_id_to_interface=false'
+                print 'cmd = '+nflowCmd+nflowSwitches
+                call(nflowCmd+nflowSwitches, shell=True)
+
+            else:
+                print 'No switches with Netflow'
+        else:
+            print 'No NetFlow targets specified.'
+
+        # Configure sFlow
+        sflowValues = self.appPrefs['sflow']
+        if len(sflowValues['sflowTarget']) > 0:
+            sflowEnabled = False
+            sflowSwitches = ''
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+    
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    if 'sflow' in opts:
+                        if opts['sflow'] == '1':
+                            print name+' has sflow enabled'
+                            sflowSwitches = sflowSwitches+' -- set Bridge '+name+' sflow=@MiniEditSF'
+                            sflowEnabled=True
+            if sflowEnabled:
+                sflowCmd = 'ovs-vsctl -- --id=@MiniEditSF create sFlow '+ 'target=\\\"'+sflowValues['sflowTarget']+'\\\" '+ 'header='+sflowValues['sflowHeader']+' '+ 'sampling='+sflowValues['sflowSampling']+' '+ 'polling='+sflowValues['sflowPolling']
+                print 'cmd = '+sflowCmd+sflowSwitches
+                call(sflowCmd+sflowSwitches, shell=True)
+
+            else:
+                print 'No switches with sflow'
+        else:
+            print 'No sFlow targets specified.'
+
+        ## NOTE: MAKE SURE THIS IS LAST THING CALLED
+        # Start the CLI if enabled
+        if self.appPrefs['startCLI'] == '1':
+            info( "\n\n NOTE: PLEASE REMEMBER TO EXIT THE CLI BEFORE YOU PRESS THE STOP BUTTON. Not exiting will prevent MiniEdit from quitting and will prevent you from starting the network again during this sessoin.\n\n")
+            CLI(self.net)
+
     def start( self ):
         "Start network."
         if self.net is None:
             self.net = self.build()
-            self.net.start()
+
+            # Since I am going to inject per switch controllers.
+            # I can't call net.start().  I have to replicate what it
+            # does and add the controller options.
+            #self.net.start()
+            info( '**** Starting %s controllers\n' % len( self.net.controllers ) )
+            for controller in self.net.controllers:
+                info( str(controller) + ' ')
+                controller.start()
+            info('\n')
+            info( '**** Starting %s switches\n' % len( self.net.switches ) )
+            #for switch in self.net.switches:
+            #    info( switch.name + ' ')
+            #    switch.start( self.net.controllers )
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Switch' in tags:
+                    opts = self.switchOpts[name]
+                    switchControllers = []
+                    for ctrl in opts['controllers']:
+                        switchControllers.append(self.net.get(ctrl))
+                    info( name + ' ')
+                    # Figure out what controllers will manage this switch
+                    self.net.get(name).start( switchControllers )
+                if 'LegacySwitch' in tags:
+                    self.net.get(name).start( [] )
+                    info( name + ' ')
+            info('\n')
+
+            self.postStartSetup()
 
     def stop( self ):
         "Stop network."
         if self.net is not None:
+            # Stop host details
+            for widget in self.widgetToItem:
+                name = widget[ 'text' ]
+                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
+                if 'Host' in tags:
+                    newHost = self.net.get(name)
+                    opts = self.hostOpts[name]
+                    # Run User Defined Stop Command
+                    if ('stopCommand' in opts):
+                        newHost.cmdPrint(opts['stopCommand'])
+                if 'Switch' in tags:
+                    newNode = self.net.get(name)
+                    opts = self.switchOpts[name]
+                    # Run User Defined Stop Command
+                    if ('stopCommand' in opts):
+                        newNode.cmdPrint(opts['stopCommand'])
+
             self.net.stop()
         cleanUpScreens()
         self.net = None
 
+    def do_linkPopup(self, event):
+        # display the popup menu
+        if ( self.net is None ):
+            try:
+                self.linkPopup.tk_popup(event.x_root, event.y_root)
+            finally:
+                # make sure to release the grab (Tk 8.0a1 only)
+                self.linkPopup.grab_release()
+        else:
+            try:
+                self.linkPopup.tk_popup(event.x_root, event.y_root)
+            finally:
+                # make sure to release the grab (Tk 8.0a1 only)
+                self.linkPopup.grab_release()
+
+    def do_legacyRouterPopup(self, event):
+        # display the popup menu
+        if ( self.net is None ):
+            try:
+                self.legacyRouterPopup.tk_popup(event.x_root, event.y_root)
+            finally:
+                # make sure to release the grab (Tk 8.0a1 only)
+                self.legacyRouterPopup.grab_release()
+
+    def do_hostPopup(self, event):
+        # display the popup menu
+
+        try:
+            self.hostPopup.tk_popup(event.x_root, event.y_root)
+	    isHostPopup = True
+        finally:
+                # make sure to release the grab (Tk 8.0a1 only)
+            self.hostPopup.grab_release()
+
     def xterm( self, _ignore=None ):
         "Make an xterm when a button is pressed."
         if ( self.selection is None or
@@ -667,9 +2579,201 @@
         name = self.itemToWidget[ self.selection ][ 'text' ]
         if name not in self.net.nameToNode:
             return
-        term = makeTerm( self.net.nameToNode[ name ], 'Host' )
-        self.net.terms.append( term )
+        term = makeTerm( self.net.nameToNode[ name ], 'Host', term=self.appPrefs['terminalType'] )
+        if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
+            self.net.terms += term
+        else:
+            self.net.terms.append(term)
 
+    def iperf( self, _ignore=None ):
+        "Make an xterm when a button is pressed."
+        if ( self.selection is None or
+             self.net is None or
+             self.selection not in self.itemToWidget ):
+            return
+        name = self.itemToWidget[ self.selection ][ 'text' ]
+        if name not in self.net.nameToNode:
+            return
+        self.net.nameToNode[ name ].cmd( 'iperf -s -p 5001 &' )
+
+    """ BELOW HERE IS THE TOPOLOGY IMPORT CODE """
+
+    def parseArgs( self ):
+        """Parse command-line args and return options object.
+           returns: opts parse options dict"""
+
+        if '--custom' in sys.argv:
+            index = sys.argv.index( '--custom' )
+            if len( sys.argv ) > index + 1:
+                filename = sys.argv[ index + 1 ]
+                self.parseCustomFile( filename )
+            else:
+                raise Exception( 'Custom file name not found' )
+
+        desc = ( "The %prog utility creates Mininet network from the\n"
+                 "command line. It can create parametrized topologies,\n"
+                 "invoke the Mininet CLI, and run tests." )
+
+        usage = ( '%prog [options]\n'
+                  '(type %prog -h for details)' )
+
+        opts = OptionParser( description=desc, usage=usage )
+
+        addDictOption( opts, TOPOS, TOPODEF, 'topo' )
+        addDictOption( opts, LINKS, LINKDEF, 'link' )
+
+        opts.add_option( '--custom', type='string', default=None,
+                         help='read custom topo and node params from .py' +
+                         'file' )
+
+        self.options, self.args = opts.parse_args()
+        # We don't accept extra arguments after the options
+        if self.args:
+            opts.print_help()
+            exit()
+
+    def setCustom( self, name, value ):
+        "Set custom parameters for MininetRunner."
+        if name in ( 'topos', 'switches', 'hosts', 'controllers' ):
+            # Update dictionaries
+            param = name.upper()
+            globals()[ param ].update( value )
+        elif name == 'validate':
+            # Add custom validate function
+            self.validate = value
+        else:
+            # Add or modify global variable or class
+            globals()[ name ] = value
+
+    def parseCustomFile( self, fileName ):
+        "Parse custom file and add params before parsing cmd-line options."
+        customs = {}
+        if os.path.isfile( fileName ):
+            execfile( fileName, customs, customs )
+            for name, val in customs.iteritems():
+                self.setCustom( name, val )
+        else:
+            raise Exception( 'could not find custom file: %s' % fileName )
+
+    def importTopo( self ):
+        print 'topo='+self.options.topo
+        if self.options.topo == 'none':
+            return
+        self.newTopology()
+        topo = buildTopo( TOPOS, self.options.topo )
+        link = customConstructor( LINKS, self.options.link )
+        importNet = Mininet(topo=topo, build=False, link=link)
+        importNet.build()
+
+        c = self.canvas
+        rowIncrement = 100
+        currentY = 100
+
+        # Add Controllers
+        print 'controllers:'+str(len(importNet.controllers))
+        for controller in importNet.controllers:
+            name = controller.name
+            x = self.controllerCount*100+100
+            self.addNode('Controller', self.controllerCount,
+                 float(x), float(currentY), name=name)
+            icon = self.findWidgetByName(name)
+           #icon.bind('<Button-3>', self.do_controllerPopup )
+            ctrlr = { 'controllerType': 'ref',
+                      'hostname': name,
+                      'controllerProtocol': controller.protocol,
+                      'remoteIP': controller.ip,
+                      'remotePort': controller.port}
+            self.controllers[name] = ctrlr
+
+
+
+        currentY = currentY + rowIncrement
+
+        # Add switches
+        print 'switches:'+str(len(importNet.switches))
+        columnCount = 0
+        for switch in importNet.switches:
+            name = switch.name
+            self.switchOpts[name] = {}
+            self.switchOpts[name]['nodeNum']=self.switchCount
+            self.switchOpts[name]['hostname']=name
+            self.switchOpts[name]['switchType']='default'
+            self.switchOpts[name]['controllers']=[]
+
+            x = columnCount*100+100
+            self.addNode('Switch', self.switchCount,
+                 float(x), float(currentY), name=name)
+            icon = self.findWidgetByName(name)
+            icon.bind('<Button-3>', self.do_switchPopup )
+            # Now link to controllers
+            for controller in importNet.controllers:
+                self.switchOpts[name]['controllers'].append(controller.name)
+                dest = self.findWidgetByName(controller.name)
+                dx, dy = c.coords( self.widgetToItem[ dest ] )
+                self.link = c.create_line(float(x),
+                                          float(currentY),
+                                          dx,
+                                          dy,
+                                          width=4,
+                                          fill='red',
+                                          dash=(6, 4, 2, 4),
+                                          tag='link' )
+                c.itemconfig(self.link, tags=c.gettags(self.link)+('control',))
+                self.addLink( icon, dest, linktype='control' )
+                self.createControlLinkBindings()
+                self.link = self.linkWidget = None
+            if columnCount == 9:
+                columnCount = 0
+                currentY = currentY + rowIncrement
+            else:
+                columnCount =columnCount+1
+
+
+        currentY = currentY + rowIncrement
+        # Add hosts
+        print 'hosts:'+str(len(importNet.hosts))
+        columnCount = 0
+        for host in importNet.hosts:
+            name = host.name
+            self.hostOpts[name] = {'sched':'host'}
+            self.hostOpts[name]['nodeNum']=self.hostCount
+            self.hostOpts[name]['hostname']=name
+            self.hostOpts[name]['ip']=host.IP()
+
+            x = columnCount*100+100
+            self.addNode('Host', self.hostCount,
+                 float(x), float(currentY), name=name)
+            icon = self.findWidgetByName(name)
+            icon.bind('<Button-3>', self.do_hostPopup )
+            if columnCount == 9:
+                columnCount = 0
+                currentY = currentY + rowIncrement
+            else:
+                columnCount =columnCount+1
+
+        print 'links:'+str(len(topo.links()))
+        #[('h1', 's3'), ('h2', 's4'), ('s3', 's4')]
+        for link in topo.links():
+            print str(link)
+            srcNode = link[0]
+            src = self.findWidgetByName(srcNode)
+            sx, sy = self.canvas.coords( self.widgetToItem[ src ] )
+
+            destNode = link[1]
+            dest = self.findWidgetByName(destNode)
+            dx, dy = self.canvas.coords( self.widgetToItem[ dest]  )
+
+            params = topo.linkInfo( srcNode, destNode )
+            print 'Link Parameters='+str(params)
+
+            self.link = self.canvas.create_line( sx, sy, dx, dy, width=4,
+                                             fill='blue', tag='link' )
+            c.itemconfig(self.link, tags=c.gettags(self.link)+('data',))
+            self.addLink( src, dest, linkopts=params )
+            self.createDataLinkBindings()
+            self.link = self.linkWidget = None
+
+        importNet.stop()
 
 def miniEditImages():
     "Create and return images for MiniEdit."
@@ -682,13 +2786,68 @@
         'Select': BitmapImage(
             file='/usr/include/X11/bitmaps/left_ptr' ),
 
-	'Switch' : PhotoImage( data=r"""
-	   R0lGODlhOgArAMIEAB8aFwB7tQCb343L8P///////////////yH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACwAAAAAOgArAAAD/ki63P4wykmrvTjr3YYfQigKH7d5Y6qmnjmBayyHg8vAAqDPaUTbowaA13OIahqcyEgEQEbIi7LIGA1FzsaSQK0QfbnH10sMa83VsqX53HLL7sgUTudR5s367F7PEq4CYDJRcngqfgshiAqAMwF3AYdWTCERjSoBjy+ZVItvMg6XIZmaEgOkSmJwlKOkkKSRlaqraaewr7ABhnqBNLmZuL+6vCzCrpvGsB9EH8m5wc7R0sbQ09bT1dOEBLbXwMjeEN7HpuO6Dt3hFObi7Ovj7d7bEOnYD+4V8PfqF/wN/lKsxZPmop6wBwaFzTsRbVvCWzYQmlMW0UKzZCUqatzICLGjx48gKyYAADs=
-"""),
-	'Host' : PhotoImage( data=r"""
-	    R0lGODlhKQAyAMIHAJyeoK+wsrW2uMHCxM7P0Ozt7fn5+f///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAKQAyAAAD63i63P4wykmrvS4cwLv/IEhxRxGeKGBM3pa+X9QeBmxrT3gMNpyLrt6rgcJgisKXgIFMopaLpjMEVUinn2pQ1ImSrN8uGKCVegHn8bl8CqbV7jFbJ47H650592sX4zl6MX9ocIOBLYNvhkxtiYV8eYx0kJSEi2d7WFmSmZqRmIKeHoddoqOcoaZkqIiqq6CtqqQkrq9jnaKzaLW6Wy8DBMHCp7ClPT+ArMY2t1u9Qs3Et6k+W87KtMfW0r6x1d7P2uDYu+LLtt3nQ9ufxeXM7MkOuCnR7UTe6/jyEOqeWj/SYQEowxXBfgYPJAAAOw==
-"""),
-        'Link': PhotoImage( data=r"""
+        'LegacyRouter': PhotoImage( data=r"""
+	    R0lGODlhMgAYAPcAAAEBAXZ8gQNAgL29vQNctjl/xVSa4j1dfCF+3QFq1DmL3wJMmAMzZZW11dnZ
+	    2SFrtyNdmTSO6gIZMUKa8gJVqEOHzR9Pf5W74wFjxgFx4jltn+np6Eyi+DuT6qKiohdtwwUPGWiq
+	    6ymF4LHH3Rh11CV81kKT5AMoUA9dq1ap/mV0gxdXlytRdR1ptRNPjTt9vwNgvwJZsX+69gsXJQFH
+	    jTtjizF0tvHx8VOm9z2V736Dhz2N3QM2acPZ70qe8gFo0HS19wVRnTiR6hMpP0eP1i6J5iNlqAtg
+	    tktjfQFu3TNxryx4xAMTIzOE1XqAh1uf5SWC4AcfNy1XgQJny93n8a2trRh312Gt+VGm/AQIDTmB
+	    yAF37QJasydzvxM/ayF3zhdLf8zLywFdu4i56gFlyi2J4yV/1w8wUo2/8j+X8D2Q5Eee9jeR7Uia
+	    7DpeggFt2QNPm97e3jRong9bpziH2DuT7aipqQoVICmG45vI9R5720eT4Q1hs1er/yVVhwJJktPh
+	    70tfdbHP7Xev5xs5V7W1sz9jhz11rUVZcQ9WoCVVhQk7cRdtwWuw9QYOFyFHbSBnr0dznxtWkS18
+	    zKfP9wwcLAMHCwFFiS5UeqGtuRNNiwMfPS1hlQMtWRE5XzGM5yhxusLCwCljnwMdOFWh7cve8pG/
+	    7Tlxp+Tr8g9bpXF3f0lheStrrYu13QEXLS1ppTV3uUuR1RMjNTF3vU2X4TZupwRSolNne4nB+T+L
+	    2YGz4zJ/zYe99YGHjRdDcT95sx09XQldsgMLEwMrVc/X3yN3yQ1JhTRbggsdMQNfu9HPz6WlpW2t
+	    7RctQ0GFyeHh4dvl8SBZklCb5kOO2kWR3Vmt/zdjkQIQHi90uvPz8wIVKBp42SV5zbfT7wtXpStV
+	    fwFWrBVvyTt3swFz5kGBv2+1/QlbrVFjdQM7d1+j54i67UmX51qn9i1vsy+D2TuR5zddhQsjOR1t
+	    u0GV6ghbsDVZf4+76RRisent8Xd9hQFBgwFNmwJLlcPDwwFr1z2T5yH5BAEAAAAALAAAAAAyABgA
+	    Bwj/AAEIHEiQYJY7Qwg9UsTplRIbENuxEiXJgpcz8e5YKsixY8Essh7JcbbOBwcOa1JOmJAmTY4c
+	    HeoIabJrCShI0XyB8YRso0eOjoAdWpciBZajJ1GuWcnSZY46Ed5N8hPATqEBoRB9gVJsxRlhPwHI
+	    0kDkVywcRpGe9LF0adOnMpt8CxDnxg1o9lphKoEACoIvmlxxvHOKVg0n/Tzku2WoVoU2J1P6WNkS
+	    rtwADuxCG/MOjwgRUEIjGG3FhaOBzaThiDSCil27G8Isc3LLjZwXsA6YYJmDjhTMmseoKQIFDx7R
+	    oxHo2abnwygAlUj1mV6tWjlelEpRwfd6gzI7VeJQ/2vZoVaDUqigqftXpH0R46H9Kl++zUo4JnKq
+	    9dGvv09RHFhcIUMe0NiFDyql0OJUHWywMc87TXRhhCRGiHAccvNZUR8JxpDTH38p9HEUFhxgMSAv
+	    jbBjQge8PSXEC6uo0IsHA6gAAShmgCbffNtsQwIJifhRHX/TpUUiSijlUk8AqgQixSwdNBjCa7CF
+	    oVggmEgCyRf01WcFCYvYUgB104k4YlK5HONEXXfpokYdMrXRAzMhmNINNNzB9p0T57AgyZckpKKP
+	    GFNgw06ZWKR10jTw6MAmFWj4AJcQQkQQwSefvFeGCemMIQggeaJywSQ/wgHOAmJskQEfWqBlFBEH
+	    1P/QaGY3QOpDZXA2+A6m7hl3IRQKGDCIAj6iwE8yGKC6xbJv8IHNHgACQQybN2QiTi5NwdlBpZdi
+	    isd7vyanByOJ7CMGGRhgwE+qyy47DhnBPLDLEzLIAEQjBtChRmVPNWgpr+Be+Nc9icARww9TkIEu
+	    DAsQ0O7DzGIQzD2QdDEJHTsIAROc3F7qWQncyHPPHN5QQAAG/vjzw8oKp8sPPxDH3O44/kwBQzLB
+	    xBCMOTzzHEMMBMBARgJvZJBBEm/4k0ACKydMBgwYoKNNEjJXbTXE42Q9jtFIp8z0Dy1jQMA1AGzi
+	    z9VoW7310V0znYDTGMQgwUDXLDBO2nhvoTXbbyRk/XXL+pxWkAT8UJ331WsbnbTSK8MggDZhCTOM
+	    LQkcjvXeSPedAAw0nABWWARZIgEDfyTzxt15Z53BG1PEcEknrvgEelhZMDHKCTwI8EcQFHBBAAFc
+	    gGPLHwLwcMIo12Qxu0ABAQA7
+            """),
+
+        'Host': PhotoImage( data=r"""
+            R0lGODlhIAAYAPcAMf//////zP//mf//Zv//M///AP/M///MzP/M
+            mf/MZv/MM//MAP+Z//+ZzP+Zmf+ZZv+ZM/+ZAP9m//9mzP9mmf9m
+            Zv9mM/9mAP8z//8zzP8zmf8zZv8zM/8zAP8A//8AzP8Amf8AZv8A
+            M/8AAMz//8z/zMz/mcz/Zsz/M8z/AMzM/8zMzMzMmczMZszMM8zM
+            AMyZ/8yZzMyZmcyZZsyZM8yZAMxm/8xmzMxmmcxmZsxmM8xmAMwz
+            /8wzzMwzmcwzZswzM8wzAMwA/8wAzMwAmcwAZswAM8wAAJn//5n/
+            zJn/mZn/Zpn/M5n/AJnM/5nMzJnMmZnMZpnMM5nMAJmZ/5mZzJmZ
+            mZmZZpmZM5mZAJlm/5lmzJlmmZlmZplmM5lmAJkz/5kzzJkzmZkz
+            ZpkzM5kzAJkA/5kAzJkAmZkAZpkAM5kAAGb//2b/zGb/mWb/Zmb/
+            M2b/AGbM/2bMzGbMmWbMZmbMM2bMAGaZ/2aZzGaZmWaZZmaZM2aZ
+            AGZm/2ZmzGZmmWZmZmZmM2ZmAGYz/2YzzGYzmWYzZmYzM2YzAGYA
+            /2YAzGYAmWYAZmYAM2YAADP//zP/zDP/mTP/ZjP/MzP/ADPM/zPM
+            zDPMmTPMZjPMMzPMADOZ/zOZzDOZmTOZZjOZMzOZADNm/zNmzDNm
+            mTNmZjNmMzNmADMz/zMzzDMzmTMzZjMzMzMzADMA/zMAzDMAmTMA
+            ZjMAMzMAAAD//wD/zAD/mQD/ZgD/MwD/AADM/wDMzADMmQDMZgDM
+            MwDMAACZ/wCZzACZmQCZZgCZMwCZAABm/wBmzABmmQBmZgBmMwBm
+            AAAz/wAzzAAzmQAzZgAzMwAzAAAA/wAAzAAAmQAAZgAAM+4AAN0A
+            ALsAAKoAAIgAAHcAAFUAAEQAACIAABEAAADuAADdAAC7AACqAACI
+            AAB3AABVAABEAAAiAAARAAAA7gAA3QAAuwAAqgAAiAAAdwAAVQAA
+            RAAAIgAAEe7u7t3d3bu7u6qqqoiIiHd3d1VVVURERCIiIhEREQAA
+            ACH5BAEAAAAALAAAAAAgABgAAAiNAAH8G0iwoMGDCAcKTMiw4UBw
+            BPXVm0ixosWLFvVBHFjPoUeC9Tb+6/jRY0iQ/8iVbHiS40CVKxG2
+            HEkQZsyCM0mmvGkw50uePUV2tEnOZkyfQA8iTYpTKNOgKJ+C3AhO
+            p9SWVaVOfWj1KdauTL9q5UgVbFKsEjGqXVtP40NwcBnCjXtw7tx/
+            C8cSBBAQADs=
+        """ ),
+
+        'NetLink': PhotoImage( data=r"""
             R0lGODlhFgAWAPcAMf//////zP//mf//Zv//M///AP/M///MzP/M
             mf/MZv/MM//MAP+Z//+ZzP+Zmf+ZZv+ZM/+ZAP9m//9mzP9mmf9m
             Zv9mM/9mAP8z//8zzP8zmf8zZv8zM/8zAP8A//8AzP8Amf8AZv8A
@@ -715,8 +2874,33 @@
         """ )
     }
 
+def addDictOption( opts, choicesDict, default, name, helpStr=None ):
+    """Convenience function to add choices dicts to OptionParser.
+       opts: OptionParser instance
+       choicesDict: dictionary of valid choices, must include default
+       default: default choice key
+       name: long option name
+       help: string"""
+    if default not in choicesDict:
+        raise Exception( 'Invalid  default %s for choices dict: %s' %
+                         ( default, name ) )
+    if not helpStr:
+        helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
+                    '[,param=value...]' )
+    opts.add_option( '--' + name,
+                     type='string',
+                     default = default,
+                     help = helpStr )
+
 if __name__ == '__main__':
     setLogLevel( 'info' )
-    temp_file = parse_args()
-    app = MiniEdit(template_file=temp_file)
+    app = MiniEdit()
+    """ import topology if specified """
+    app.parseArgs()
+    app.importTopo()
+
+    global isHostPopup
+    global isRouterPopup
+    global isLinkPopup
+
     app.mainloop()
