예제 #1
0
    def __init__( self, net, parent=None, width=4 ):
        Frame.__init__( self, parent )
        self.top = self.winfo_toplevel()
        self.top.title( 'Mininet' )
        self.net = net
        self.menubar = self.createMenuBar()
        cframe = self.cframe = Frame( self )
        self.consoles = {}  # consoles themselves
        titles = {
            'hosts': 'Host',
            'switches': 'Switch',
            'controllers': 'Controller'
        }
        for name in titles:
            nodes = getattr( net, name )
            frame, consoles = self.createConsoles(
                cframe, nodes, width, titles[ name ] )
            self.consoles[ name ] = Object( frame=frame, consoles=consoles )
        self.selected = None
        self.select( 'hosts' )
        self.cframe.pack( expand=True, fill='both' )
        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol( self.top, name='WM_DELETE_WINDOW', func=self.quit )

        # Initialize graph
        graph = Graph( cframe )
        self.consoles[ 'graph' ] = Object( frame=graph, consoles=[ graph ] )
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len( self.consoles[ 'hosts' ].consoles )
        self.bw = 0

        self.pack( expand=True, fill='both' )
예제 #2
0
    def __init__(self, net, parent=None, width=4):
        Frame.__init__(self, parent)
        self.top = self.winfo_toplevel()
        self.top.title('Mininet')
        self.net = net
        self.menubar = self.createMenuBar()
        cframe = self.cframe = Frame(self)
        self.consoles = {}  # consoles themselves
        titles = {
            'hosts': 'Host',
            'switches': 'Switch',
            'controllers': 'Controller'
        }
        for name in titles:
            nodes = getattr(net, name)
            frame, consoles = self.createConsoles(cframe, nodes, width,
                                                  titles[name])
            self.consoles[name] = Object(frame=frame, consoles=consoles)
        self.selected = None
        self.select('hosts')
        self.cframe.pack(expand=True, fill='both')
        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol(self.top, name='WM_DELETE_WINDOW', func=self.quit)

        # Initialize graph
        graph = Graph(cframe)
        self.consoles['graph'] = Object(frame=graph, consoles=[graph])
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len(self.consoles['hosts'].consoles)
        self.bw = 0

        self.pack(expand=True, fill='both')
예제 #3
0
파일: consoles.py 프로젝트: rad1dlp/mininet
    def __init__(self, net, parent=None, width=4):
        Frame.__init__(self, parent)
        self.top = self.winfo_toplevel()
        self.top.title("Mininet")
        self.net = net
        self.menubar = self.createMenuBar()
        cframe = self.cframe = Frame(self)
        self.consoles = {}  # consoles themselves
        titles = {"hosts": "Host", "switches": "Switch", "controllers": "Controller"}
        for name in titles:
            nodes = getattr(net, name)
            frame, consoles = self.createConsoles(cframe, nodes, width, titles[name])
            self.consoles[name] = Object(frame=frame, consoles=consoles)
        self.selected = None
        self.select("hosts")
        self.cframe.pack(expand=True, fill="both")
        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol(self.top, name="WM_DELETE_WINDOW", func=self.quit)

        # Initialize graph
        graph = Graph(cframe)
        self.consoles["graph"] = Object(frame=graph, consoles=[graph])
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len(self.consoles["hosts"].consoles)
        self.bw = 0

        self.pack(expand=True, fill="both")
예제 #4
0
    def about( self ):
        "Display about box."
        about = self.aboutBox
        if about is None:
            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'
            line1 = Label( about, text=info, font='Helvetica 10 bold', bg=bg )
            line2 = Label( about, text=warning, 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 )
            line1.pack( padx=20, pady=10 )
            line2.pack(pady=10 )
            line3.pack(pady=10 )
	    line4.pack(pady=10 )
            hide = ( lambda about=about: about.withdraw() )
            self.aboutBox = about
            # Hide on close rather than destroying window
            Wm.wm_protocol( about, name='WM_DELETE_WINDOW', func=hide )
        # Show (existing) window
        about.deiconify()
예제 #5
0
	def __init__( self, net, controllerRESTApi, parent=None, width=4 ):
		Frame.__init__( self, parent )
		self.top = self.winfo_toplevel()
		self.top.title( 'Mininet' )
		self.net = net
		self.controllerRESTApi = controllerRESTApi
		self.menubar = self.createMenuBar()
		cframe = self.cframe = Frame( self )
		self.consoles = {}  # consoles themselves
		titles = {
			'hosts': 'Host',
			'switches': 'Switch',
			'controllers': 'Controller'
		}
		for name in titles:
			nodes = getattr( net, name )
			frame, consoles = self.createConsoles(
				cframe, nodes, width, titles[ name ] )
			self.consoles[ name ] = Object( frame=frame, consoles=consoles )
		self.selected = None
		self.select( 'hosts' )
		self.cframe.pack( expand=True, fill='both' )
		cleanUpScreens()
		# Close window gracefully
		Wm.wm_protocol( self.top, name='WM_DELETE_WINDOW', func=self.quit )

		self.pack( expand=True, fill='both' )
예제 #6
0
    def __init__(self, net, parent=None, width=4):
        Frame.__init__(self, parent)
        self.top = self.winfo_toplevel()
        self.gheight = 800
        self.top.title('Mininet')
        self.net = net
        self.menubar = self.createMenuBar()
        self.consoles = {}

        self.sconsoles = {}  # consoles themselves
        titles = {
            'hosts': 'Host',
            'switches': 'Switch',
            'controllers': 'Controller'
        }
        # (servers + clients) * 20

        canvas = self.canvas = Canvas(
            self,
            width=1600,
            height=800,
            scrollregion=(0, 0, 0,
                          ((servers + nathost + clients + 200) // 4) * 280))

        # cframe = self.cframe = Frame(canvas, width=1600, height=((servers + nathost + clients + 3) // 4) * 264)
        cframe = self.cframe = Frame(canvas)
        for name in titles:
            nodes = getattr(net, name)
            frame, consoles = self.createConsoles(cframe, nodes, width,
                                                  titles[name])
            self.consoles[name] = Object(frame=frame, consoles=consoles)
        canvas.create_window(
            (800, ((servers + nathost + clients + 100) // 4) * 132),
            window=cframe)
        self.selected = None
        self.select('hosts')

        ybar = Scrollbar(self, orient='vertical', command=canvas.yview)
        canvas.config(yscrollcommand=ybar.set)

        ybar.pack(side='right', fill='y')
        canvas.pack(expand=True, fill='both')

        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol(self.top, name='WM_DELETE_WINDOW', func=self.quit)

        # Initialize graph
        graph = Graph(cframe)
        self.consoles['graph'] = Object(frame=graph, consoles=[graph])
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len(self.consoles['hosts'].consoles)
        self.bw = 0

        self.pack(expand=True, fill='both')
예제 #7
0
    def __init__( self, parent=None, cheight=200, cwidth=500 ):

        Frame.__init__( self, parent )
        self.action = None
        self.appName = 'MiniEdit'

        # Style
        self.font = ( 'Geneva', 9 )
        self.smallFont = ( 'Geneva', 7 )
        self.bg = 'white'

        # Title
        self.top = self.winfo_toplevel()
        self.top.title( self.appName )

        # Menu bar
        self.createMenubar()

        # Editing canvas
        self.cheight, self.cwidth = cheight, cwidth
        self.cframe, self.canvas = self.createCanvas()

        # Toolbar
        self.images = miniEditImages()
        self.buttons = {}
        self.active = None
        self.tools = ( 'Select', 'Host', 'Switch', 'Link' )
        self.customColors = { 'Switch': 'darkGreen', 'Host': 'blue' }
        self.toolbar = self.createToolbar()

        # Layout
        self.toolbar.grid( column=0, row=0, sticky='nsew')
        self.cframe.grid( column=1, row=0 )
        self.columnconfigure( 1, weight=1 )
        self.rowconfigure( 0, weight=1 )
        self.pack( expand=True, fill='both' )

        # About box
        self.aboutBox = None

        # Initialize node data
        self.nodeBindings = self.createNodeBindings()
        self.nodePrefixes = { 'Switch': 's', 'Host': 'h' }
        self.widgetToItem = {}
        self.itemToWidget = {}

        # Initialize link tool
        self.link = self.linkWidget = None

        # Selection support
        self.selection = None

        # Keyboard bindings
        self.bind( '<Control-q>', lambda event: self.quit() )
        self.bind( '<KeyPress-Delete>', self.deleteSelection )
        self.bind( '<KeyPress-BackSpace>', self.deleteSelection )
        self.focus()

        # Event handling initalization
        self.linkx = self.linky = self.linkItem = None
        self.lastSelection = None

        # Model initialization
        self.links = {}
        self.nodeCount = 0
        self.net = None

        # Close window gracefully
        Wm.wm_protocol( self.top, name='WM_DELETE_WINDOW', func=self.quit )
예제 #8
0
    def __init__( self, parent=None, cheight=200, cwidth=500 ):

        Frame.__init__( self, parent )
        self.action = None
        self.appName = 'MiniEdit'

        # Style
        self.font = ( 'Geneva', 9 )
        self.smallFont = ( 'Geneva', 7 )
        self.bg = 'white'

        # Title
        self.top = self.winfo_toplevel()
        self.top.title( self.appName )

        # Menu bar
        self.createMenubar()

        # Editing canvas
        self.cheight, self.cwidth = cheight, cwidth
        self.cframe, self.canvas = self.createCanvas()

        # Toolbar
        self.images = miniEditImages()
        self.buttons = {}
        self.active = None
        self.tools = ( 'Select', 'Host', 'Switch', 'Link' )
        self.customColors = { 'Switch': 'darkGreen', 'Host': 'blue' }
        self.toolbar = self.createToolbar()

        # Layout
        self.toolbar.grid( column=0, row=0, sticky='nsew')
        self.cframe.grid( column=1, row=0 )
        self.columnconfigure( 1, weight=1 )
        self.rowconfigure( 0, weight=1 )
        self.pack( expand=True, fill='both' )

        # About box
        self.aboutBox = None

        # Initialize node data
        self.nodeBindings = self.createNodeBindings()
        self.nodePrefixes = { 'Switch': 's', 'Host': 'h' }
        self.widgetToItem = {}
        self.itemToWidget = {}

        # Initialize link tool
        self.link = self.linkWidget = None

        # Selection support
        self.selection = None

        # Keyboard bindings
        self.bind( '<Control-q>', lambda event: self.quit() )
        self.bind( '<KeyPress-Delete>', self.deleteSelection )
        self.bind( '<KeyPress-BackSpace>', self.deleteSelection )
        self.focus()

        # Event handling initalization
        self.linkx = self.linky = self.linkItem = None
        self.lastSelection = None

        # Model initialization
        self.links = {}
        self.nodeCount = 0
        self.net = None

        # Close window gracefully
        Wm.wm_protocol( self.top, name='WM_DELETE_WINDOW', func=self.quit )