Ejemplo n.º 1
0
    def save(self, responses):
        ## Generic settings start ##
        newsettings = dict()
        for setting in responses.keys():
            if "/" in setting:
                part1, part2 = setting.split("/")
                if part1 not in newsettings:
                    #We may not touch all settings, so copy oldsettings first
                    newsettings[part1] = self.oldsettings[part1]
                newsettings[part1][part2] = responses[setting]
            else:
                newsettings[setting] = responses[setting]
        ## Generic settings end ##

        ## Need to calculate and set cidr, netmask, size
        newsettings['ADMIN_NETWORK']['netmask'] = self.netsettings[newsettings
                   ['ADMIN_NETWORK']['interface']]["netmask"]
        newsettings['ADMIN_NETWORK']['cidr'] = network.getCidr(
            self.netsettings[newsettings['ADMIN_NETWORK']['interface']][
                "addr"], newsettings['ADMIN_NETWORK']['netmask'])
        newsettings['ADMIN_NETWORK']['size'] = network.getCidrSize(
            newsettings['ADMIN_NETWORK']['cidr'])

        log.debug(str(newsettings))
        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)
        #Write naily.facts
        factsettings = dict()
        #for key in newsettings.keys():
        log.debug(str(facter_translate))
        log.debug(str(newsettings))
        for key in facter_translate.keys():
            factsettings[facter_translate[key]] = responses[key]
        n = nailyfactersettings.NailyFacterSettings()
        log.debug("Facts to write: %s" % factsettings)
        n.write(factsettings)

        #Set oldsettings to reflect new settings
        self.oldsettings = newsettings
        #Update DEFAULTS
        for index, fieldname in enumerate(fields):
            if fieldname != "blank" and "label" not in fieldname:
                DEFAULTS[fieldname]['value'] = responses[fieldname]

        self.parent.footer.set_text("Changes saved successfully.")
Ejemplo n.º 2
0
    def check(self, args):
        self.parent.footer.set_text("Checking data...")
        self.parent.refreshScreen()

        responses = dict()
        for index, fieldname in enumerate(self.fields):
            if fieldname != helper.BLANK_KEY:
                responses[fieldname] = self.edits[index].get_edit_text()

        ssh_network = responses[SSH_NETWORK]
        errors = []

        if len(ssh_network) == 0:
            self.parent.footer.set_text("Address is empty, "
                                        "will be changed to 0.0.0.0/0")
            log.warning("Empty address, changed to 0.0.0.0/0")
            responses[SSH_NETWORK] = "0.0.0.0/0"

            msg = "If you continue without the address, you may able to"\
                  + " access the Fuel through SSH from any network. The"\
                  + " address will be changed to 0.0.0.0/0. This can lead"\
                  + " to the security issues."

            dialog.display_dialog(self, widget.TextLabel(msg),
                                  "Empty Address Warning")

        else:
            if not network.getCidrSize(ssh_network):
                errors.append("Incorrect network address format: {0}.".format(
                    ssh_network))

        if len(errors) > 0:
            log.error("Errors: %s %s", len(errors), errors)
            helper.ModuleHelper.display_failed_check_dialog(self, errors)
            return False

        self.parent.footer.set_text("No errors found.")
        return responses
Ejemplo n.º 3
0
    def check(self, args):
        self.parent.footer.set_text("Checking data...")
        self.parent.refreshScreen()

        responses = dict()
        for index, fieldname in enumerate(self.fields):
            if fieldname != helper.BLANK_KEY:
                responses[fieldname] = self.edits[index].get_edit_text()

        ssh_network = responses[SSH_NETWORK]
        errors = []

        if len(ssh_network) == 0:
            self.parent.footer.set_text("Address is empty, "
                                        "will be changed to 0.0.0.0/0")
            log.warning("Empty address, changed to 0.0.0.0/0")
            responses[SSH_NETWORK] = "0.0.0.0/0"

            msg = "If you continue without the address, you may able to"\
                  + " access the Fuel through SSH from any network. The"\
                  + " address will be changed to 0.0.0.0/0. This can lead"\
                  + " to the security issues."

            dialog.display_dialog(
                self, widget.TextLabel(msg), "Empty Address Warning")

        else:
            if not network.getCidrSize(ssh_network):
                errors.append("Incorrect network address format: {0}."
                              .format(ssh_network))

        if len(errors) > 0:
            log.error("Errors: %s %s", len(errors), errors)
            helper.ModuleHelper.display_failed_check_dialog(self, errors)
            return False

        self.parent.footer.set_text("No errors found.")
        return responses