Exemplo n.º 1
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global atmsw_id

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'ATM' + str(atmsw_id) == node.hostname:
                atmsw_id = atmsw_id + 1
                break

        self.hostname = 'ATM' + str(atmsw_id)
        atmsw_id = atmsw_id + 1
        AbstractNode.setCustomToolTip(self)

        self.config = None
        self.dynagen = globals.GApp.dynagen
        self.a= 'ATMSW ' + self.hostname
        self.d = None
        self.hypervisor = None
        self.running_config = None
        self.atmsw = None
        self.dynagen.update_running_config()
Exemplo n.º 2
0
    def changeAUXPort(self):
        """ Called to change the aux port
        """

        if self.router.state != 'stopped':
            QtGui.QMessageBox.warning(globals.GApp.mainWindow, translate("IOSRouter", "AUX port"), translate("IOSRouter", "You must restart this router after changing its AUX port"))
        AbstractNode.changeAUXPort(self)
Exemplo n.º 3
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global atmsw_id

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'ATM' + str(atmsw_id) == node.hostname:
                atmsw_id = atmsw_id + 1
                break

        self.hostname = 'ATM' + str(atmsw_id)
        atmsw_id = atmsw_id + 1
        AbstractNode.setCustomToolTip(self)

        self.config = None
        self.dynagen = globals.GApp.dynagen
        self.a = 'ATMSW ' + self.hostname
        self.d = None
        self.hypervisor = None
        self.running_config = None
        self.atmsw = None
        self.dynagen.update_running_config()
Exemplo n.º 4
0
    def showMenuInterface(self):
        """ Call AbstractNode method with unavailable_interfaces argument to allow us to "gray out" interface e1 which is managed by VirtualBox GUI (NAT, Bridge, etc.)
        """

        if not self.local_config['first_nic_managed']:
            AbstractNode.showMenuInterface(self)
        else:
            AbstractNode.showMenuInterface(self, ['e0'])
Exemplo n.º 5
0
 def changeConsolePort(self):
     """ Called to change the console port
     """
     
     if self.emudev.state != 'stopped':
         QtGui.QMessageBox.critical(globals.GApp.mainWindow, translate("AnyEmuDevice", "Console port"), translate("AnyEmuDevice", "Cannot change the console port while the node is running"))
         return
     AbstractNode.changeConsolePort(self)
Exemplo n.º 6
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.emu_vboxdev:
            self.setToolTip(self.emu_vboxdev.info())
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 7
0
    def showMenuInterface(self):
        """ Call AbstractNode method with unavailable_interfaces argument to allow us to "gray out" interface e1 which is managed by VirtualBox GUI (NAT, Bridge, etc.)
        """

        if not self.local_config['first_nic_managed']:
            AbstractNode.showMenuInterface(self)
        else:
            AbstractNode.showMenuInterface(self, ['e0'])
Exemplo n.º 8
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.emudev:
            self.setToolTip(self.emudev.info())
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 9
0
    def console(self):
        """ Start a telnet console and connect it to this router
        """

        if self.emudev and self.emudev.state == 'running' and self.emudev.console:
            proc = console.connect(self.emudev.dynamips.host, self.emudev.console, self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
        AbstractNode.clearClosedConsoles(self)
Exemplo n.º 10
0
 def changeHostname(self):
     """ Called to change the hostname
     """
     
     if self.router.state != 'stopped':
         QtGui.QMessageBox.critical(globals.GApp.mainWindow, translate("IOSRouter", "New hostname"),
                                    translate("IOSRouter", "Cannot change the hostname of a running device"))            
         return
     AbstractNode.changeHostname(self)
Exemplo n.º 11
0
    def console(self):
        """ Start a telnet console and connect it to this router
        """

        if self.router and self.router.state == 'running' and self.router.console:
            proc = console.connect(self.hypervisor.host, self.router.console,
                                   self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
        AbstractNode.clearClosedConsoles(self)
Exemplo n.º 12
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.router:
            try:
                self.setToolTip(self.router.info())
            except:
                AbstractNode.setCustomToolTip(self)
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 13
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.atmsw:
            try:
                self.setToolTip(self.atmsw.info())
            except:
                AbstractNode.setCustomToolTip(self)
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 14
0
    def changeHostname(self):
        """ Called to change the hostname
        """

        if self.emu_vboxdev.state != 'stopped':
            QtGui.QMessageBox.critical(
                globals.GApp.mainWindow,
                translate("AnyVBoxEmuDevice", "New hostname"),
                translate("AnyVBoxEmuDevice",
                          "Cannot change the hostname of a running device"))
            return
        AbstractNode.changeHostname(self)
Exemplo n.º 15
0
    def changeAUXPort(self):
        """ Called to change the aux port
        """

        if self.router.state != 'stopped':
            QtGui.QMessageBox.warning(
                globals.GApp.mainWindow, translate("IOSRouter", "AUX port"),
                translate(
                    "IOSRouter",
                    "You must restart this router after changing its AUX port")
            )
        AbstractNode.changeAUXPort(self)
Exemplo n.º 16
0
    def changeConsolePort(self):
        """ Called to change the console port
        """

        if self.emu_vboxdev.state != 'stopped':
            QtGui.QMessageBox.critical(
                globals.GApp.mainWindow,
                translate(
                    "AnyVBoxEmuDevice",
                    "Cannot change the console port while the node is running")
            )
            return
        AbstractNode.changeConsolePort(self)
Exemplo n.º 17
0
    def aux(self):
        """ Start a telnet console and connect it to this router's AUX port
        """
        if not self.router.aux:
            QtGui.QMessageBox.critical(globals.GApp.mainWindow, translate("IOSRouter", "AUX port"),
                                       translate("AbstractNode", "AUX port not available for this router model or base AUX port is set to 0 in preferences"))
            return False

        if self.router and self.router.state == 'running':
            proc = console.connect(self.hypervisor.host, self.router.aux, self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
        AbstractNode.clearClosedConsoles(self)
Exemplo n.º 18
0
    def mousePressEvent(self, event):
        """ Call when the node is clicked
            event: QtGui.QGraphicsSceneMouseEvent instance
        """

        if globals.addingLinkFlag and globals.currentLinkType != globals.Enum.LinkType.Manual and event.button() == QtCore.Qt.LeftButton:
            interface = self.smart_interface(globals.linkAbrv[globals.currentLinkType])
            if interface:
                self.emit(QtCore.SIGNAL("Add link"), self.id, interface)
            else:
                QtGui.QMessageBox.critical(globals.GApp.mainWindow, translate("IOSRouter", "Connection"),  translate("IOSRouter", "No interface available"))
                return
        else:
            AbstractNode.mousePressEvent(self, event)
        QtSvg.QGraphicsSvgItem.mousePressEvent(self, event)
Exemplo n.º 19
0
    def mousePressEvent(self, event):
        """ Call when the node is clicked
            event: QtGui.QGraphicsSceneMouseEvent instance
        """

        if globals.addingLinkFlag and globals.currentLinkType != globals.Enum.LinkType.Manual and event.button() == QtCore.Qt.LeftButton:
            connected_interfaces = self.getConnectedInterfaceList()
            for interface in self.config['interfaces']:
                if not str(interface) in connected_interfaces:
                    self.emit(QtCore.SIGNAL("Add link"), self.id, str(interface))
                    return
            QtGui.QMessageBox.critical(globals.GApp.mainWindow, translate("DecorativeNode", "Connection"),  translate("DecorativeNode", "No interface available"))
            # tell the scene to cancel the link addition by sending a None id and None interface
            self.emit(QtCore.SIGNAL("Add link"), None, None)
        else:
            AbstractNode.mousePressEvent(self, event)
Exemplo n.º 20
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global decoration_id

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'N' + str(decoration_id) == node.hostname:
                decoration_id = decoration_id + 1
                break

        self.hostname = 'N' + str(decoration_id)
        decoration_id = decoration_id + 1

        self.setCustomToolTip()
        self.config = None
Exemplo n.º 21
0
    def aux(self):
        """ Start a telnet console and connect it to this router's AUX port
        """
        if not self.router.aux:
            QtGui.QMessageBox.critical(
                globals.GApp.mainWindow, translate("IOSRouter", "AUX port"),
                translate(
                    "AbstractNode",
                    "AUX port not available for this router model or base AUX port is set to 0 in preferences"
                ))
            return False

        if self.router and self.router.state == 'running':
            proc = console.connect(self.hypervisor.host, self.router.aux,
                                   self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
        AbstractNode.clearClosedConsoles(self)
Exemplo n.º 22
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global cloud_id

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'C' + str(cloud_id) == node.hostname:
                cloud_id = cloud_id + 1
                break

        self.hostname = 'C' + str(cloud_id)
        cloud_id = cloud_id + 1

        self.config = None
        self.dynagen = globals.GApp.dynagen
        self.setCustomToolTip()
Exemplo n.º 23
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global cloud_id

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'C' + str(cloud_id) == node.hostname:
                cloud_id = cloud_id + 1
                break

        self.hostname = 'C' + str(cloud_id)
        cloud_id = cloud_id + 1

        self.config = None
        self.dynagen = globals.GApp.dynagen
        self.setCustomToolTip()
Exemplo n.º 24
0
    def console(self):
        """ Start a telnet console and connect it to this router
        """

        if self.emu_vboxdev and self.emu_vboxdev.state == 'running' and self.emu_vboxdev.console and self.emu_vboxdev.console_support:
            if not self.emu_vboxdev.console_telnet_server:
                p = re.compile('\s+', re.UNICODE)
                pipe_name = p.sub("_", self.emu_vboxdev.image)
                if sys.platform.startswith('win'):
                    pipe_name = r'\\.\pipe\VBOX\%s' % pipe_name
                elif os.path.exists(self.emu_vboxdev.dynamips.workingdir):
                    pipe_name = self.emu_vboxdev.dynamips.workingdir + os.sep + "pipe_%s" % pipe_name
                else:
                    pipe_name = "/tmp/pipe_%s" % pipe_name
                proc = console.pipe_connect(self.hostname, pipe_name)
            else:
                proc = console.connect(self.emu_vboxdev.dynamips.host, self.emu_vboxdev.console, self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
            AbstractNode.clearClosedConsoles(self)
Exemplo n.º 25
0
    def mousePressEvent(self, event):
        """ Call when the node is clicked
            event: QtGui.QGraphicsSceneMouseEvent instance
        """

        if globals.addingLinkFlag and globals.currentLinkType != globals.Enum.LinkType.Manual and event.button(
        ) == QtCore.Qt.LeftButton:
            interface = self.smart_interface(
                globals.linkAbrv[globals.currentLinkType])
            if interface:
                self.emit(QtCore.SIGNAL("Add link"), self.id, interface)
            else:
                QtGui.QMessageBox.critical(
                    globals.GApp.mainWindow,
                    translate("IOSRouter", "Connection"),
                    translate("IOSRouter", "No interface available"))
                return
        else:
            AbstractNode.mousePressEvent(self, event)
        QtSvg.QGraphicsSvgItem.mousePressEvent(self, event)
Exemplo n.º 26
0
    def console(self):
        """ Start a telnet console and connect it to this router
        """

        if self.emu_vboxdev and self.emu_vboxdev.state == 'running' and self.emu_vboxdev.console and self.emu_vboxdev.console_support:
            if not self.emu_vboxdev.console_telnet_server:
                p = re.compile('\s+', re.UNICODE)
                pipe_name = p.sub("_", self.emu_vboxdev.image)
                if sys.platform.startswith('win'):
                    pipe_name = r'\\.\pipe\VBOX\%s' % pipe_name
                elif os.path.exists(self.emu_vboxdev.dynamips.workingdir):
                    pipe_name = self.emu_vboxdev.dynamips.workingdir + os.sep + "pipe_%s" % pipe_name
                else:
                    pipe_name = "/tmp/pipe_%s" % pipe_name
                proc = console.pipe_connect(self.hostname, pipe_name)
            else:
                proc = console.connect(self.emu_vboxdev.dynamips.host,
                                       self.emu_vboxdev.console, self.hostname)
            if proc:
                self.consoleProcesses.append(proc)
            AbstractNode.clearClosedConsoles(self)
Exemplo n.º 27
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.config:
            info = translate("Cloud", "Cloud name: %s") % self.hostname
            for nio in self.config['nios']:
                info += "\n\n" + nio
                if sys.platform.startswith('win') and self.config['rpcap_mapping'].has_key(nio):
                    info += "\n    " + self.config['rpcap_mapping'][nio]
                neighbor = self.getConnectedNeighbor(nio)
                if neighbor:
                    (neighbor, ifname) = neighbor
                    info += " is connected to " + neighbor.hostname + " " + ifname
                else:
                    info += " is not connected"
            try:
                self.setToolTip(info)
            except:
                AbstractNode.setCustomToolTip(self)
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 28
0
    def __init__(self, renderer_normal, renderer_select):
        #print "AnyVBoxEmuDevice::__init__()"
        AbstractNode.__init__(self, renderer_normal, renderer_select)
        AnyVBoxEmuDefaults.__init__(self)

        # assign a new hostname
        global vbox_emu_id
        if not vbox_emu_id:
            vbox_emu_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if self.basehostname + str(vbox_emu_id) == node.hostname:
                vbox_emu_id = vbox_emu_id + 1
                break

        self.hostname = self.basehostname + str(vbox_emu_id)
        vbox_emu_id = vbox_emu_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.local_config = None
        self.f = '%s %s' %(self.basehostname, self.hostname)
        self.running_config = None
        self.defaults_config = None
        self.emu_vboxdev = None

        self.emu_vboxdev_options = [
            'image',
            'nics',
            'netcard',
            'guestcontrol_user',
            'guestcontrol_password',
            'first_nic_managed',
            'headless_mode',
            'console_support',
            'console_telnet_server',
            ]
Exemplo n.º 29
0
    def __init__(self, renderer_normal, renderer_select):
        #print "AnyVBoxEmuDevice::__init__()"
        AbstractNode.__init__(self, renderer_normal, renderer_select)
        AnyVBoxEmuDefaults.__init__(self)

        # assign a new hostname
        global vbox_emu_id
        if not vbox_emu_id:
            vbox_emu_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if self.basehostname + str(vbox_emu_id) == node.hostname:
                vbox_emu_id = vbox_emu_id + 1
                break

        self.hostname = self.basehostname + str(vbox_emu_id)
        vbox_emu_id = vbox_emu_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.local_config = None
        self.f = '%s %s' % (self.basehostname, self.hostname)
        self.running_config = None
        self.defaults_config = None
        self.emu_vboxdev = None

        self.emu_vboxdev_options = [
            'image',
            'nics',
            'netcard',
            'guestcontrol_user',
            'guestcontrol_password',
            'first_nic_managed',
            'headless_mode',
            'console_support',
            'console_telnet_server',
        ]
Exemplo n.º 30
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)
        AnyEmuDefaults.__init__(self)

        # assign a new hostname
        global emu_id
        if not emu_id:
            emu_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if self.basehostname + str(emu_id) == node.hostname:
                emu_id = emu_id + 1
                break

        self.hostname = self.basehostname + str(emu_id)
        emu_id = emu_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.local_config = None
        self.f = '%s %s' %(self.basehostname, self.hostname)
        self.running_config = None
        self.defaults_config = None
        self.emudev = None

        self.emudev_options = [
            'ram',
            'image',
            'nics',
            'usermod',
            'netcard',
            'flavor',
            'kvm',
            'monitor',
            'options',
            ]
Exemplo n.º 31
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)
        AnyEmuDefaults.__init__(self)

        # assign a new hostname
        global emu_id
        if not emu_id:
            emu_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if self.basehostname + str(emu_id) == node.hostname:
                emu_id = emu_id + 1
                break

        self.hostname = self.basehostname + str(emu_id)
        emu_id = emu_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.local_config = None
        self.f = '%s %s' % (self.basehostname, self.hostname)
        self.running_config = None
        self.defaults_config = None
        self.emudev = None

        self.emudev_options = [
            'ram',
            'image',
            'nics',
            'usermod',
            'netcard',
            'flavor',
            'kvm',
            'monitor',
            'options',
        ]
Exemplo n.º 32
0
    def setCustomToolTip(self):
        """ Set a custom tool tip
        """

        if self.config:
            info = translate("Cloud", "Cloud name: %s") % self.hostname
            for nio in self.config['nios']:
                info += "\n\n" + nio
                if sys.platform.startswith(
                        'win') and self.config['rpcap_mapping'].has_key(nio):
                    info += "\n    " + self.config['rpcap_mapping'][nio]
                neighbor = self.getConnectedNeighbor(nio)
                if neighbor:
                    (neighbor, ifname) = neighbor
                    info += " is connected to " + neighbor.hostname + " " + ifname
                else:
                    info += " is not connected"
            try:
                self.setToolTip(info)
            except:
                AbstractNode.setCustomToolTip(self)
        else:
            AbstractNode.setCustomToolTip(self)
Exemplo n.º 33
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global router_id
        if not router_id:
            router_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'R' + str(router_id) == node.hostname:
                router_id = router_id + 1
                break

        self.hostname = 'R' + str(router_id)
        router_id = router_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.r = 'ROUTER ' + self.hostname
        self.running_config = None
        self.defaults_config = None
        self.router = None
        self.local_config = None

        self.routerInstanceMap = {
            '1710': lib.C1700,
            '1720': lib.C1700,
            '1721': lib.C1700,
            '1750': lib.C1700,
            '1751': lib.C1700,
            '1760': lib.C1700,
            '2691': lib.C2691,
            '3620': lib.C3600,
            '3640': lib.C3600,
            '3660': lib.C3600,
            '3725': lib.C3725,
            '3745': lib.C3745,
            '7200': lib.C7200,
            '2610': lib.C2600,
            '2611': lib.C2600,
            '2620': lib.C2600,
            '2621': lib.C2600,
            '2610XM': lib.C2600,
            '2611XM': lib.C2600,
            '2620XM': lib.C2600,
            '2621XM': lib.C2600,
            '2650XM': lib.C2600,
            '2651XM': lib.C2600,
            }

        self.router_options = [
            'ram',
            'nvram',
            'disk0',
            'disk1',
            'confreg',
            'idlepc',
            'exec_area',
            'idlemax',
            'idlesleep',
            'image',
            'mac',
            'iomem',
            'npe',
            'midplane', 
            ]
Exemplo n.º 34
0
    def __del__(self):

        self.delete_router()
        AbstractNode.__del__(self)
Exemplo n.º 35
0
    def __init__(self, renderer_normal, renderer_select):

        AbstractNode.__init__(self, renderer_normal, renderer_select)

        # assign a new hostname
        global router_id
        if not router_id:
            router_id = 1

        # check if hostname has already been assigned
        for node in globals.GApp.topology.nodes.itervalues():
            if 'R' + str(router_id) == node.hostname:
                router_id = router_id + 1
                break

        self.hostname = 'R' + str(router_id)
        router_id = router_id + 1
        AbstractNode.setCustomToolTip(self)

        self.dynagen = globals.GApp.dynagen
        self.r = 'ROUTER ' + self.hostname
        self.running_config = None
        self.defaults_config = None
        self.router = None
        self.local_config = None

        self.routerInstanceMap = {
            '1710': lib.C1700,
            '1720': lib.C1700,
            '1721': lib.C1700,
            '1750': lib.C1700,
            '1751': lib.C1700,
            '1760': lib.C1700,
            '2691': lib.C2691,
            '3620': lib.C3600,
            '3640': lib.C3600,
            '3660': lib.C3600,
            '3725': lib.C3725,
            '3745': lib.C3745,
            '7200': lib.C7200,
            '2610': lib.C2600,
            '2611': lib.C2600,
            '2620': lib.C2600,
            '2621': lib.C2600,
            '2610XM': lib.C2600,
            '2611XM': lib.C2600,
            '2620XM': lib.C2600,
            '2621XM': lib.C2600,
            '2650XM': lib.C2600,
            '2651XM': lib.C2600,
        }

        self.router_options = [
            'ram',
            'nvram',
            'disk0',
            'disk1',
            'confreg',
            'idlepc',
            'exec_area',
            'idlemax',
            'idlesleep',
            'image',
            'mac',
            'iomem',
            'npe',
            'midplane',
        ]
Exemplo n.º 36
0
    def __del__(self):

        self.delete_emudev()
        AbstractNode.__del__(self)
Exemplo n.º 37
0
    def __del__(self):

        self.delete_router()
        AbstractNode.__del__(self)
Exemplo n.º 38
0
    def mousePressEvent(self, event):
        """ Call when the node is clicked
            event: QtGui.QGraphicsSceneMouseEvent instance
        """

        AbstractNode.mousePressEvent(self, event)
Exemplo n.º 39
0
    def __del__(self):

        self.delete_emudev()
        AbstractNode.__del__(self)
Exemplo n.º 40
0
    def mousePressEvent(self, event):
        """ Call when the node is clicked
            event: QtGui.QGraphicsSceneMouseEvent instance
        """

        AbstractNode.mousePressEvent(self, event)