Esempio n. 1
0
    def load(self):
        #Read in yaml
        defaultsettings = Settings().read(self.parent.defaultsettingsfile)
        oldsettings = defaultsettings
        oldsettings.update(Settings().read(self.parent.settingsfile))

        oldsettings = Settings().read(self.parent.settingsfile)
        for setting in self.defaults.keys():
            try:
                if "/" in setting:
                    part1, part2 = setting.split("/")
                    self.defaults[setting]["value"] = oldsettings[part1][part2]
                else:
                    self.defaults[setting]["value"] = oldsettings[setting]
            except Exception:
                log.warning("No setting named %s found." % setting)
                continue
        #Read hostname if it's already set
        try:
            hostname, sep, domain = os.uname()[1].partition('.')
            oldsettings["HOSTNAME"] = hostname
            oldsettings["DNS_DOMAIN"] = domain
            oldsettings["DNS_SEARCH"] = domain
        except Exception:
            log.warning("Unable to look up system hostname")
        return oldsettings
Esempio n. 2
0
    def load(self):
        #Read in yaml
        defaultsettings = Settings().read(self.parent.defaultsettingsfile)
        oldsettings = defaultsettings
        oldsettings.update(Settings().read(self.parent.settingsfile))

        oldsettings = Settings().read(self.parent.settingsfile)
        for setting in self.defaults.keys():
            try:
                if setting == "ntpenabled":
                    rb_group = \
                        self.edits[self.fields.index("ntpenabled")].rb_group
                    if oldsettings[setting]["value"] == "Yes":
                        rb_group[0].set_state(True)
                        rb_group[1].set_state(False)
                    else:
                        rb_group[0].set_state(False)
                        rb_group[1].set_state(True)
                elif "/" in setting:
                    part1, part2 = setting.split("/")
                    self.defaults[setting]["value"] = oldsettings[part1][part2]
                else:
                    self.defaults[setting]["value"] = oldsettings[setting]
            except Exception:
                log.warning("No setting named %s found." % setting)
                continue
        return oldsettings
Esempio n. 3
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)

        #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.")
Esempio n. 4
0
    def save(self, responses):
        ## Generic settings start ##
        newsettings = OrderedDict()
        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
                    try:
                        newsettings[part1] = self.oldsettings[part1]
                    except Exception:
                        if part1 not in newsettings.keys():
                            newsettings[part1] = OrderedDict()
                        log.warning("issues setting newsettings %s " % setting)
                        log.warning("current newsettings: %s" % newsettings)
                newsettings[part1][part2] = responses[setting]
            else:
                newsettings[setting] = responses[setting]
        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)

        ## Generic settings end ##
        log.debug('done saving servicepws')

        #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]
Esempio n. 5
0
    def save(self, responses):
        ## Generic settings start ##
        newsettings = OrderedDict()
        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
                    try:
                        newsettings[part1] = self.oldsettings[part1]
                    except Exception:
                        if part1 not in newsettings.keys():
                            newsettings[part1] = OrderedDict()
                        log.warning("issues setting newsettings %s " % setting)
                        log.warning("current newsettings: %s" % newsettings)
                newsettings[part1][part2] = responses[setting]
            else:
                newsettings[setting] = responses[setting]
        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)

        self.parent.footer.set_text("Changes applied successfully.")
        # Reset fields
        self.cancel(None)
Esempio n. 6
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 ##

        #log.debug(str(newsettings))
        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)

        #Set oldsettings to reflect new settings
        self.oldsettings = newsettings
        #Update self.defaults
        for index, fieldname in enumerate(self.fields):
            if fieldname != "blank":
                self.defaults[fieldname]['value'] = newsettings[fieldname]
Esempio n. 7
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 ##

        log.info("new settings {0}", str(newsettings))
        Settings().write(newsettings,
                         defaultsfile=self.parent.defaultsettingsfile,
                         outfn=self.parent.settingsfile)

        #Set oldsettings to reflect new settings
        self.oldsettings = newsettings
        #Update self.defaults
        for index, fieldname in enumerate(self.fields):
            if fieldname != "blank":
                log.info("resetting {0}".format(fieldname))
                if fieldname not in self.defaults.keys():
                    log.error("no such field: {0}, valid are {1}", fieldname,
                              ' '.join(self.defaults.keys()))
                    continue
                if fieldname not in newsettings.keys():
                    log.error("newsettings: no such field: {0}, valid are {1}",
                              fieldname, ' '.join(newsettings.keys()))
                    continue
                self.defaults[fieldname]['value'] = newsettings[fieldname]
Esempio n. 8
0
 def load(cls, modobj):
     # Read in yaml
     defaultsettings = Settings().read(modobj.parent.defaultsettingsfile)
     oldsettings = defaultsettings.copy()
     oldsettings.update(Settings().read(modobj.parent.settingsfile))
     for setting in modobj.defaults.keys():
         if "label" in setting:
             continue
         elif "/" in setting:
             part1, part2 = setting.split("/")
             modobj.defaults[setting]["value"] = oldsettings[part1][part2]
         else:
             modobj.defaults[setting]["value"] = oldsettings[setting]
     if modobj.netsettings and oldsettings["ADMIN_NETWORK"]["interface"] in modobj.netsettings.keys():
         modobj.activeiface = oldsettings["ADMIN_NETWORK"]["interface"]
     return oldsettings
Esempio n. 9
0
 def load(cls, modobj):
     #Read in yaml
     defaultsettings = Settings().read(modobj.parent.defaultsettingsfile)
     oldsettings = defaultsettings.copy()
     oldsettings.update(Settings().read(modobj.parent.settingsfile))
     for setting in modobj.defaults.keys():
         if "label" in setting:
             continue
         elif "/" in setting:
             part1, part2 = setting.split("/")
             modobj.defaults[setting]["value"] = oldsettings[part1][part2]
         else:
             modobj.defaults[setting]["value"] = oldsettings[setting]
     if modobj.netsettings and oldsettings["ADMIN_NETWORK"]["interface"] \
             in modobj.netsettings.keys():
         modobj.activeiface = oldsettings["ADMIN_NETWORK"]["interface"]
     return oldsettings
 def load(self):
     #Read in yaml
     defaultsettings = Settings().read(self.parent.defaultsettingsfile)
     oldsettings = defaultsettings.copy()
     oldsettings.update(Settings().read(self.parent.settingsfile))
     log.debug("Old settings %s" % oldsettings)
     for setting in self.defaults.keys():
         if "label" in setting:
             continue
         elif "/" in setting:
             part1, part2 = setting.split("/")
             self.defaults[setting]["value"] = oldsettings[part1][part2]
         else:
             self.defaults[setting]["value"] = oldsettings[setting]
     if oldsettings["ADMIN_NETWORK"]["interface"] \
             in self.netsettings.keys():
         self.activeiface = oldsettings["ADMIN_NETWORK"]["interface"]
     return oldsettings
Esempio n. 11
0
 def load(self):
     #Read in yaml
     defaultsettings = Settings().read(self.parent.defaultsettingsfile)
     oldsettings = defaultsettings.copy()
     oldsettings.update(Settings().read(self.parent.settingsfile))
     log.debug("Old settings %s" % oldsettings)
     for setting in self.defaults.keys():
         if "label" in setting:
             continue
         elif "/" in setting:
             part1, part2 = setting.split("/")
             self.defaults[setting]["value"] = oldsettings[part1][part2]
         else:
             self.defaults[setting]["value"] = oldsettings[setting]
     if oldsettings["ADMIN_NETWORK"]["interface"] \
             in self.netsettings.keys():
         self.activeiface = oldsettings["ADMIN_NETWORK"]["interface"]
     return oldsettings
Esempio n. 12
0
    def load(self):
        #Read in yaml
        defaultsettings = Settings().read(self.parent.defaultsettingsfile)
        oldsettings = defaultsettings
        oldsettings.update(Settings().read(self.parent.settingsfile))

        oldsettings = Settings().read(self.parent.settingsfile)
        for setting in self.defaults.keys():
            try:
                if "/" in setting:
                    part1, part2 = setting.split("/")
                    self.defaults[setting]["value"] = oldsettings[part1][part2]
                else:
                    self.defaults[setting]["value"] = oldsettings[setting]
            except Exception:
                log.warning("No setting named %s found." % setting)
                continue
        return oldsettings
Esempio n. 13
0
    def load(self):
        #Read in yaml
        defaultsettings = Settings().read(self.parent.defaultsettingsfile)
        oldsettings = defaultsettings
        oldsettings.update(Settings().read(self.parent.settingsfile))

        for setting in self.defaults:
            try:
                if BOOTSTRAP_FLAVOR_KEY == setting:
                    section, key = BOOTSTRAP_FLAVOR_KEY.split('/')
                    flavor = oldsettings[section][key]
                    self._set_bootstrap_flavor(flavor)
                elif "/" in setting:
                    part1, part2 = setting.split("/")
                    self.defaults[setting]["value"] = oldsettings[part1][part2]
                else:
                    self.defaults[setting]["value"] = oldsettings[setting]
            except KeyError:
                log.warning("no setting named {0} found.", setting)
            except Exception as e:
                log.warning("unexpected error: {0}", e.message)
        return oldsettings
Esempio n. 14
0
 def _read_version_info(self):
     settings = Settings()
     dat = settings.read(VERSION_YAML_FILE)
     version_info = dat['VERSION']
     self._mos_version = version_info['release']
     self._distro_release = version_info.get('ubuntu_release', 'trusty')
Esempio n. 15
0
 def _read_version_info(self):
     settings = Settings()
     dat = settings.read(VERSION_YAML_FILE)
     version_info = dat['VERSION']
     self._mos_version = version_info['release']
     self._distro_release = version_info.get('ubuntu_release', 'trusty')