Пример #1
0
    def setVlanConfig(self, vlanIndex):
        """ Submenu for configuring a specific vlan """
        logging.debugv("menu/config.py->setVlanConfig(self, vlanIndex)", [vlanIndex])

        vlanConf = self.c.getVlan(vlanIndex)

        choices = t.formatMenuItem("VLAN ID", vlanConf["vlanid"])
        if vlanConf["vlanid"] != "":
            choices += t.formatMenuItem("Type", vlanConf["type"])
            choices += t.formatMenuItem("Description", vlanConf["description"])
            if vlanConf["type"] == "static":
                choices += t.formatMenuItem("Endpoint IP address", vlanConf["tunnel"])
                choices += t.formatMenuItem("Netmask", vlanConf["netmask"])
                choices += t.formatMenuItem("Gateway", vlanConf["gateway"])
                choices += t.formatMenuItem("Broadcast", vlanConf["broadcast"])

        vlanID = vlanConf["vlanid"]
        if vlanID == "":
            vlanID = "Unknown-%s" % str(vlanIndex)

        title = "\\Zb... > Network > VLAN config %s\\n\\ZBSelect the item you want to (re-)configure" % str(vlanID)
        choice = self.d.menu(title, choices=choices, cancel="Back", ok_label="Edit", height=20, colors=1)
        if choice[0] == 1: return
        elif choice[1] == "VLAN ID":
            self.setVlanID(vlanIndex)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after setIfType()
        elif choice[1] == "Type":
            self.setVlanType(vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after setVlanType()
        elif choice[1] == "Description":
            self.setVlanDesc(vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after setVlanDesc()
        elif choice[1] == "Local IP address":
            self.popupVlanConfig("address", vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Endpoint IP address":
            self.popupVlanConfig("tunnel", vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Netmask":
            self.popupVlanConfig("netmask", vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Gateway":
            self.popupVlanConfig("gateway", vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Broadcast":
            self.popupVlanConfig("broadcast", vlanIndex, vlanID)
            self.setVlanConfig(vlanIndex)           # Make sure setVlanConfig() is loaded after popupVlanConfig()

        return                  # returns to configNetwork()
Пример #2
0
    def setIfConfig(self, inf):
        """ Submenu for configuring a specific interface """
        logging.debugv("menu/config.py->setIfConfig(self, inf)", [inf])

        infConf = self.c.getIf(inf)

        choices = t.formatMenuItem("Type", infConf["type"])
        if infConf["type"] == "static":
            choices += t.formatMenuItem("Local IP address", infConf["address"])
            if self.c.getSensorType() == "normal":
                choices += t.formatMenuItem("Endpoint IP address",
                                            infConf["tunnel"])
            choices += t.formatMenuItem("Netmask", infConf["netmask"])
            choices += t.formatMenuItem("Gateway", infConf["gateway"])
            choices += t.formatMenuItem("Broadcast", infConf["broadcast"])

        title = "\\Zb... > Configure > Network > IP config %s\\n\\ZBSelect the item you want to (re-)configure" % str(
            inf)
        choice = self.d.menu(title,
                             choices=choices,
                             cancel="Back",
                             ok_label="Edit",
                             height=20,
                             colors=1)
        if choice[0] == 1: return
        elif choice[1] == "Type":
            self.setIfType(inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after setIfType()
        elif choice[1] == "Local IP address":
            self.popupIfConfig("address", inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Endpoint IP address":
            self.popupIfConfig("tunnel", inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Netmask":
            self.popupIfConfig("netmask", inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Gateway":
            self.popupIfConfig("gateway", inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Broadcast":
            self.popupIfConfig("broadcast", inf)
            self.setIfConfig(
                inf)  # Make sure setIfConfig() is loaded after popupIfConfig()

        return  # returns to configNetwork()
Пример #3
0
    def setIfConfig(self, inf):
        """ Submenu for configuring a specific interface """
        logging.debugv("menu/config.py->setIfConfig(self, inf)", [inf])

        infConf = self.c.getIf(inf)

        choices = t.formatMenuItem("Type", infConf["type"])
        if infConf["type"] == "static":
            choices += t.formatMenuItem("Local IP address", infConf["address"])
            if self.c.getSensorType() == "normal":
                choices += t.formatMenuItem("Endpoint IP address", infConf["tunnel"])
            choices += t.formatMenuItem("Netmask", infConf["netmask"])
            choices += t.formatMenuItem("Gateway", infConf["gateway"])
            choices += t.formatMenuItem("Broadcast", infConf["broadcast"])

        title = "\\Zb... > Configure > Network > IP config %s\\n\\ZBSelect the item you want to (re-)configure" % str(inf)
        choice = self.d.menu(title, choices=choices, cancel="Back", ok_label="Edit", height=20, colors=1)
        if choice[0] == 1: return
        elif choice[1] == "Type":
            self.setIfType(inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after setIfType()
        elif choice[1] == "Local IP address":
            self.popupIfConfig("address", inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Endpoint IP address":
            self.popupIfConfig("tunnel", inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Netmask":
            self.popupIfConfig("netmask", inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Gateway":
            self.popupIfConfig("gateway", inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after popupIfConfig()
        elif choice[1] == "Broadcast":
            self.popupIfConfig("broadcast", inf)
            self.setIfConfig(inf)           # Make sure setIfConfig() is loaded after popupIfConfig()

        return                  # returns to configNetwork()
Пример #4
0
    def configNetwork(self):
        """ GUI rebuild of network configuration screen """
        logging.debugv("menu/config.py->configNetwork(self)", [])

        # ITEM - Sensor Type
        sensorType = self.c.getSensorType()
        choices = t.formatMenuItem("Sensor type", sensorType)

        # Some autoconfig stuff here
        # Set the main interface if there's only 1 interface
        totalInfs = f.ifList()
        if len(totalInfs) == 1:
            logging.debug("Auto configuration: Setting mainIf to %s" % str(totalInfs[0]))
            self.c.setMainIf(totalInfs[0])

        # ITEM - Main Interface
        mainIf = self.c.getMainIf()
        choices += t.formatMenuItem("Main interface", mainIf)

        # ITEM - Trunk Interface
        if sensorType == "vlan":
            trunkIf = self.c.getTrunkIf()
            if trunkIf == mainIf and trunkIf != "":
                choices += t.formatMenuItem("Trunk interface", trunkIf, False)
            else:
                choices += t.formatMenuItem("Trunk interface", trunkIf)
            # ITEM - Number of vlans
            totalVlans = self.c.getTotalVlans()
            choices += t.formatMenuItem("Number of VLANs", str(totalVlans))

        # ITEM - Main interface - IP config
        if mainIf != "":
            infType = self.c.getIf(mainIf)["type"]
            choices += t.formatMenuItem("IP config - %s" % str(mainIf), infType, self.c.validInfConf("normal", mainIf, 0))

        # ITEMs - VLANS
        if sensorType == "vlan":
            for (vlan, vlanConf) in self.c.getVlans().items():
                vlanID = vlanConf["vlanid"]
                if vlanID == "":
                    vlanID = "Unknown-%s" % str(vlan)
                    vlanType = ""
                    vlanDesc = ""
                else:
                    vlanType = vlanConf["type"]
                    vlanDesc = vlanConf["description"]
                choices += t.formatMenuItem("Config vlan %s" % str(vlanID), vlanType, self.c.validInfConf("vlan", vlan, 0))

        title = "\\ZbStart > Configure > Network\\n\\ZBSelect the item you want to (re-)configure"
        choice = self.d.menu(title, choices=choices, cancel="Back", ok_label="Edit", colors=1, height=20, menu_height=12)
        if choice[0] == 1: 
            try:
                self.c.validNetConf()
            except excepts.ConfigException, err:
                self.invalidNetConfAction(err)
                return
            else:
                if self.changed:
                    self.c.addRev()
                    f.backupNetConf(self.c.getRev())
                    self.activateChoice()
                return
Пример #5
0
    def configNetwork(self):
        """ GUI rebuild of network configuration screen """
        logging.debugv("menu/config.py->configNetwork(self)", [])

        # ITEM - Sensor Type
        sensorType = self.c.getSensorType()
        choices = t.formatMenuItem("Sensor type", sensorType)

        # Some autoconfig stuff here
        # Set the main interface if there's only 1 interface
        totalInfs = f.ifList()
        if len(totalInfs) == 1:
            logging.debug("Auto configuration: Setting mainIf to %s" %
                          str(totalInfs[0]))
            self.c.setMainIf(totalInfs[0])

        # ITEM - Main Interface
        mainIf = self.c.getMainIf()
        choices += t.formatMenuItem("Main interface", mainIf)

        # ITEM - Trunk Interface
        if sensorType == "vlan":
            trunkIf = self.c.getTrunkIf()
            if trunkIf == mainIf and trunkIf != "":
                choices += t.formatMenuItem("Trunk interface", trunkIf, False)
            else:
                choices += t.formatMenuItem("Trunk interface", trunkIf)
            # ITEM - Number of vlans
            totalVlans = self.c.getTotalVlans()
            choices += t.formatMenuItem("Number of VLANs", str(totalVlans))

        # ITEM - Main interface - IP config
        if mainIf != "":
            infType = self.c.getIf(mainIf)["type"]
            choices += t.formatMenuItem(
                "IP config - %s" % str(mainIf), infType,
                self.c.validInfConf("normal", mainIf, 0))

        # ITEMs - VLANS
        if sensorType == "vlan":
            for (vlan, vlanConf) in self.c.getVlans().items():
                vlanID = vlanConf["vlanid"]
                if vlanID == "":
                    vlanID = "Unknown-%s" % str(vlan)
                    vlanType = ""
                    vlanDesc = ""
                else:
                    vlanType = vlanConf["type"]
                    vlanDesc = vlanConf["description"]
                choices += t.formatMenuItem(
                    "Config vlan %s" % str(vlanID), vlanType,
                    self.c.validInfConf("vlan", vlan, 0))

        title = "\\ZbStart > Configure > Network\\n\\ZBSelect the item you want to (re-)configure"
        choice = self.d.menu(title,
                             choices=choices,
                             cancel="Back",
                             ok_label="Edit",
                             colors=1,
                             height=20,
                             menu_height=12)
        if choice[0] == 1:
            try:
                self.c.validNetConf()
            except excepts.ConfigException, err:
                self.invalidNetConfAction(err)
                return
            else:
                if self.changed:
                    self.c.addRev()
                    f.backupNetConf(self.c.getRev())
                    self.activateChoice()
                return
Пример #6
0
    def setVlanConfig(self, vlanIndex):
        """ Submenu for configuring a specific vlan """
        logging.debugv("menu/config.py->setVlanConfig(self, vlanIndex)",
                       [vlanIndex])

        vlanConf = self.c.getVlan(vlanIndex)

        choices = t.formatMenuItem("VLAN ID", vlanConf["vlanid"])
        if vlanConf["vlanid"] != "":
            choices += t.formatMenuItem("Type", vlanConf["type"])
            choices += t.formatMenuItem("Description", vlanConf["description"])
            if vlanConf["type"] == "static":
                choices += t.formatMenuItem("Endpoint IP address",
                                            vlanConf["tunnel"])
                choices += t.formatMenuItem("Netmask", vlanConf["netmask"])
                choices += t.formatMenuItem("Gateway", vlanConf["gateway"])
                choices += t.formatMenuItem("Broadcast", vlanConf["broadcast"])

        vlanID = vlanConf["vlanid"]
        if vlanID == "":
            vlanID = "Unknown-%s" % str(vlanIndex)

        title = "\\Zb... > Network > VLAN config %s\\n\\ZBSelect the item you want to (re-)configure" % str(
            vlanID)
        choice = self.d.menu(title,
                             choices=choices,
                             cancel="Back",
                             ok_label="Edit",
                             height=20,
                             colors=1)
        if choice[0] == 1: return
        elif choice[1] == "VLAN ID":
            self.setVlanID(vlanIndex)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after setIfType()
        elif choice[1] == "Type":
            self.setVlanType(vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after setVlanType()
        elif choice[1] == "Description":
            self.setVlanDesc(vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after setVlanDesc()
        elif choice[1] == "Local IP address":
            self.popupVlanConfig("address", vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Endpoint IP address":
            self.popupVlanConfig("tunnel", vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Netmask":
            self.popupVlanConfig("netmask", vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Gateway":
            self.popupVlanConfig("gateway", vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after popupVlanConfig()
        elif choice[1] == "Broadcast":
            self.popupVlanConfig("broadcast", vlanIndex, vlanID)
            self.setVlanConfig(
                vlanIndex
            )  # Make sure setVlanConfig() is loaded after popupVlanConfig()

        return  # returns to configNetwork()