Esempio n. 1
0
 def from_yum_config(cls):
     """
     Yields Repo instances loaded from the system-wide Yum 
     configuration in :file:`/etc/yum.conf` and :file:`/etc/yum.repos.d/`.
     """
     yumvars = get_yumvars()
     config = configparser.RawConfigParser()
     config.read([cls.yum_main_config_path] + glob.glob(cls.yum_repos_config_glob))
     for section in config.sections():
         if section == 'main':
             continue
         if (config.has_option(section, 'enabled') and
                 not config.getboolean(section, 'enabled')):
             continue
         skip_if_unavailable = False
         if config.has_option(section, 'skip_if_unavailable'):
             skip_if_unavailable = config.getboolean(section, 'skip_if_unavailable')
         if config.has_option(section, 'baseurl'):
             baseurl = substitute_yumvars(config.get(section, 'baseurl'), yumvars)
             yield cls(section, baseurl=baseurl, skip_if_unavailable=skip_if_unavailable)
         elif config.has_option(section, 'metalink'):
             metalink = substitute_yumvars(config.get(section, 'metalink'), yumvars)
             yield cls(section, metalink=metalink, skip_if_unavailable=skip_if_unavailable)
         elif config.has_option(section, 'mirrorlist'):
             mirrorlist = substitute_yumvars(config.get(section, 'mirrorlist'), yumvars)
             yield cls(section, metalink=mirrorlist, skip_if_unavailable=skip_if_unavailable)
         else:
             raise ValueError('Yum config section %s has no '
                     'baseurl or metalink or mirrorlist' % section)
Esempio n. 2
0
 def from_yum_config(cls):
     """
     Yields Repo instances loaded from the system-wide Yum 
     configuration in /etc/yum.conf and /etc/yum.repos.d/.
     """
     yumvars = get_yumvars()
     config = configparser.RawConfigParser()
     config.read([cls.yum_main_config_path] + glob.glob(cls.yum_repos_config_glob))
     for section in config.sections():
         if section == 'main':
             continue
         if (config.has_option(section, 'enabled') and
                 not config.getboolean(section, 'enabled')):
             continue
         if config.has_option(section, 'baseurl'):
             baseurl = substitute_yumvars(config.get(section, 'baseurl'), yumvars)
             yield cls(section, baseurl=baseurl)
         elif config.has_option(section, 'metalink'):
             metalink = substitute_yumvars(config.get(section, 'metalink'), yumvars)
             yield cls(section, metalink=metalink)
         elif config.has_option(section, 'mirrorlist'):
             mirrorlist = substitute_yumvars(config.get(section, 'mirrorlist'), yumvars)
             yield cls(section, metalink=mirrorlist)
         else:
             raise ValueError('Yum config section %s has no '
                     'baseurl or metalink or mirrorlist' % section)
Esempio n. 3
0
 def get_awscli_credentials(self):
     try:
         config = ConfigParser.ConfigParser()
         config.read("%s/.aws/config" % self.get_home_path())
         self.access_key = config.get("default", "aws_access_key_id")
         self.secret_key = config.get("default", "aws_secret_access_key")
         self.token = None
         if self.access_key and self.secret_key:
             return True
     except:
         pass
     return False
Esempio n. 4
0
 def get_awscli_credentials(self):
     try:
         config = ConfigParser.ConfigParser()
         config.read("%s/.aws/config" % self.get_home_path())
         self.access_key = config.get("default", "aws_access_key_id")
         self.secret_key = config.get("default", "aws_secret_access_key")
         self.token = None
         if self.access_key and self.secret_key:
             return True
     except:
         pass
     return False
Esempio n. 5
0
    def get_credentials_from_config(self):
        """Read S3 credentials from Local Configuration.
        Note: This method should be explicitly called after constructing new
              object, as in 'explicit is better than implicit'.
        """
        import ConfigParser
        configInfo = {}
        config = ConfigParser.ConfigParser()
        try:
            config.read(CONFIG_PATH)
        except:
           msgerr = "cannot find this file %s" % CONFIG_PATH
           return False, msgerr

        for section in config.sections():
            configInfo[section] = {}

        for section in config.sections():
            for option in config.options(section):
                configInfo[section][option] = config.get(section, option)

        if configInfo:
            try:
                # FIXME
                self.access_key = configInfo["Credentials"]["access_key"]
                self.secret_key = configInfo["Credentials"]["secret_key"]
                self.token = ""
            finally:
                return True
        else:
            msgerr = "empty file %s" % CONFIG_PATH
            return False