Esempio n. 1
0
 def _read_hostname(self, filename, default=None):
     if self._dist_uses_systemd():
         (out, _err) = util.subp(['hostname'])
         if len(out):
             return out
         else:
             return default
     else:
         (_exists, contents) = rhel_util.read_sysconfig_file(filename)
         if 'HOSTNAME' in contents:
             return contents['HOSTNAME']
         else:
             return default
Esempio n. 2
0
 def _read_hostname(self, filename, default=None):
     if self.uses_systemd() and filename.endswith('/previous-hostname'):
         return util.load_file(filename).strip()
     elif self.uses_systemd():
         (out, _err) = util.subp(['hostname'])
         if len(out):
             return out
         else:
             return default
     else:
         (_exists, contents) = rhel_util.read_sysconfig_file(filename)
         if 'HOSTNAME' in contents:
             return contents['HOSTNAME']
         else:
             return default
Esempio n. 3
0
 def _read_hostname(self, filename, default=None):
     if self.uses_systemd() and filename.endswith('/previous-hostname'):
         return util.load_file(filename).strip()
     elif self.uses_systemd():
         (out, _err) = util.subp(['hostname'])
         if len(out):
             return out
         else:
             return default
     else:
         (_exists, contents) = rhel_util.read_sysconfig_file(filename)
         if 'HOSTNAME' in contents:
             return contents['HOSTNAME']
         else:
             return default
Esempio n. 4
0
    def _read_system_locale(self, keyname="LANG"):
        """Read system default locale setting, if present"""
        if self.uses_systemd():
            locale_fn = self.systemd_locale_conf_fn
        else:
            locale_fn = self.locale_conf_fn

        if not locale_fn:
            raise ValueError("Invalid path: %s" % locale_fn)

        if os.path.exists(locale_fn):
            (_exists, contents) = rhel_util.read_sysconfig_file(locale_fn)
            if keyname in contents:
                return contents[keyname]
            else:
                return None
Esempio n. 5
0
 def _read_hostname(self, filename, default=None):
     (_exists, contents) = rhel_util.read_sysconfig_file(filename)
     if contents.get('hostname'):
         return contents['hostname']
     else:
         return default