def setTrunkIf(self): """ Submenu for choosing the trunk interface """ logging.debugv("menu/config.py->setTrunkIf(self)", []) title = "\\Zb... > Configure > Network > Setup trunk interface\\n\\ZB" title += "Select the trunk interface" infs = f.ifList() choices = [(x, self.c.chkMainInf(x), int(self.c.getTrunkIf() == x)) for x in infs] choice = self.d.radiolist(title, choices=choices, cancel="Back", ok_label="Ok", height=20, colors=1) if choice[0] == 1: return # returns to configNetwork() else: if choice[1] == self.c.getMainIf(): self.d.msgbox( "The trunk interface cannot be the same as the main interface!" ) else: logging.info("Setting trunk interface to %s" % choice[1]) self.c.setTrunk(choice[1]) self.changed = True return # returns to configNetwork()
def setMainIf(self): """ Submenu for choosing the main interface """ logging.debugv("menu/config.py->setMainIf(self)", []) title = "\\Zb... > Configure > Network > Setup main interface\\n\\ZB" title += "Select the main interface" infs = f.ifList() choices = [(x, self.c.chkInfType(x), int(self.c.getMainIf() == x)) for x in infs] choice = self.d.radiolist(title, choices=choices, cancel="Back", ok_label="Ok", height=20, colors=1) if choice[0] == 1: return # returns to configNetwork() else: self.c.setMainIf(choice[1]) self.changed = True return # returns to configNetwork()
def setTrunkIf(self): """ Submenu for choosing the trunk interface """ logging.debugv("menu/config.py->setTrunkIf(self)", []) title = "\\Zb... > Configure > Network > Setup trunk interface\\n\\ZB" title += "Select the trunk interface" infs = f.ifList() choices = [(x, self.c.chkMainInf(x), int(self.c.getTrunkIf() == x)) for x in infs] choice = self.d.radiolist(title, choices=choices, cancel="Back", ok_label="Ok", height=20, colors=1) if choice[0] == 1: return # returns to configNetwork() else: if choice[1] == self.c.getMainIf(): self.d.msgbox("The trunk interface cannot be the same as the main interface!") else: logging.info("Setting trunk interface to %s" % choice[1]) self.c.setTrunk(choice[1]) self.changed = True return # returns to configNetwork()
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
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