Beispiel #1
0
 def dns(self):
     """ Submenu of network, DNS settings menu """
     logging.debugv("menu/config.py->dns(self)", [])
     (type, prim, sec) = self.c.getDNS()
     choices = [("Type", type)]
     if type == "static":
         choices += [
             ("Primary DNS server", prim),
             ("Secondary DNS server", sec),
         ]
     title = "\\ZbStart > Configure > DNS\\n\\ZBSelect the item you want to configure"
     choice = self.d.menu(title,
                          choices=choices,
                          cancel="Back",
                          ok_label="Edit",
                          colors=1)
     if choice[0] == 1:
         try:
             self.c.validDNSConf()
         except excepts.ConfigException, err:
             self.invalidDNSConfAction()
             return
         else:
             if self.changed:
                 self.c.addRev()
                 f.backupNetConf(self.c.getRev())
                 self.activateChoice()
             return
Beispiel #2
0
 def dns(self):
     """ Submenu of network, DNS settings menu """
     logging.debugv("menu/config.py->dns(self)", [])
     (type, prim, sec) = self.c.getDNS()
     choices = [ ("Type", type) ]
     if type == "static":
         choices += [
                 ("Primary DNS server", prim),
                 ("Secondary DNS server", sec),
             ]
     title = "\\ZbStart > Configure > DNS\\n\\ZBSelect the item you want to configure"
     choice = self.d.menu(title, choices=choices, cancel="Back", ok_label="Edit", colors=1)
     if choice[0] == 1:
         try:
             self.c.validDNSConf()
         except excepts.ConfigException, err:
             self.invalidDNSConfAction()
             return
         else:
             if self.changed:
                 self.c.addRev()
                 f.backupNetConf(self.c.getRev())
                 self.activateChoice()
             return
Beispiel #3
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
Beispiel #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