Beispiel #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 ##

        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)
        #Write naily.facts
        factsettings = dict()
        #log.debug(newsettings)
        for key in newsettings.keys():
            if key != "blank":
                factsettings[key] = newsettings[key]
        n = nailyfactersettings.NailyFacterSettings()
        n.write(factsettings)

        #Set oldsettings to reflect new settings
        self.oldsettings = newsettings
        #Update defaults
        for index, fieldname in enumerate(self.fields):
            if fieldname != "blank" and fieldname in newsettings:
                self.defaults[fieldname]['value'] = newsettings[fieldname]
Beispiel #2
0
    def save(self, responses):
        ## Generic settings start ##
        newsettings = ModuleHelper.save(self, responses)
        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 netmask
        newsettings['ADMIN_NETWORK']['netmask'] = self.netsettings[
            newsettings['ADMIN_NETWORK']['interface']]["netmask"]

        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 self.defaults
        for index, fieldname in enumerate(self.fields):
            if fieldname != "blank" and "label" not in fieldname:
                self.defaults[fieldname]['value'] = responses[fieldname]

        self.parent.footer.set_text("Changes saved successfully.")