def _try_satellite5_configuration(config):
    """
    Attempt to determine Satellite 5 Configuration
    """
    logger.debug("Trying Satellite 5 auto_config")
    rhn_config = '/etc/sysconfig/rhn/up2date'
    systemid = '/etc/sysconfig/rhn/systemid'
    if os.path.isfile(rhn_config):
        if os.path.isfile(systemid):
            config.systemid = _read_systemid_file(systemid)
        else:
            logger.debug("Could not find Satellite 5 systemid file.")
            return False

        logger.debug("Found Satellite 5 Config")
        rhn_conf_file = open(rhn_config, 'r')
        hostname = None
        for line in rhn_conf_file:
            if line.startswith('serverURL='):
                url = urlparse(line.split('=')[1])
                hostname = url.netloc + '/redhat_access'
                logger.debug("Found hostname %s", hostname)
            if line.startswith('sslCACert='):
                rhn_ca = line.strip().split('=')[1]

            # Auto discover proxy stuff
            if line.startswith('enableProxy='):
                proxy_enabled = line.strip().split('=')[1]
            if line.startswith('httpProxy='):
                proxy_host_port = line.strip().split('=')[1]
            if line.startswith('proxyUser='):
                proxy_user = line.strip().split('=')[1]
            if line.startswith('proxyPassword='):
                proxy_password = line.strip().split('=')[1]

        if hostname:
            proxy = None
            if proxy_enabled == "1":
                proxy = "http://"
                if proxy_user != "" and proxy_password != "":
                    logger.debug("Found user and password for rhn_proxy")
                    proxy = proxy + proxy_user + ':' + proxy_password
                    proxy = proxy + "@" + proxy_host_port
                else:
                    proxy = proxy + proxy_host_port
                    logger.debug("RHN Proxy: %s", proxy)
            set_auto_configuration(config, hostname, rhn_ca, proxy)
        else:
            logger.debug("Could not find hostname")
            return False
        return True
    else:
        logger.debug("Could not find rhn config")
        return False
def _try_satellite5_configuration ( config ) : logger . debug ( "Trying Satellite 5 auto_config" ) rhn_config = '/etc/sysconfig/rhn/up2date' systemid = '/etc/sysconfig/rhn/systemid' if os . path . isfile ( rhn_config ) : if os . path . isfile ( systemid ) : config . systemid = _read_systemid_file ( systemid ) else : logger . debug ( "Could not find Satellite 5 systemid file." ) return False logger . debug ( "Found Satellite 5 Config" ) rhn_conf_file = open ( rhn_config , 'r' ) hostname = None for line in rhn_conf_file : if line . startswith ( 'serverURL=' ) : url = urlparse ( line . split ( '=' ) [ 1 ] ) hostname = url . netloc + '/redhat_access' logger . debug ( "Found hostname %s" , hostname ) if line . startswith ( 'sslCACert=' ) : rhn_ca = line . strip ( ) . split ( '=' ) [ 1 ] if line . startswith ( 'enableProxy=' ) : proxy_enabled = line . strip ( ) . split ( '=' ) [ 1 ] if line . startswith ( 'httpProxy=' ) : proxy_host_port = line . strip ( ) . split ( '=' ) [ 1 ] if line . startswith ( 'proxyUser=' ) : proxy_user = line . strip ( ) . split ( '=' ) [ 1 ] if line . startswith ( 'proxyPassword=' ) : proxy_password = line . strip ( ) . split ( '=' ) [ 1 ] if hostname : proxy = None if proxy_enabled == "1" : proxy = "http://" if proxy_user != "" and proxy_password != "" : logger . debug ( "Found user and password for rhn_proxy" ) proxy = proxy + proxy_user + ':' + proxy_password proxy = proxy + "@" + proxy_host_port else : proxy = proxy + proxy_host_port logger . debug ( "RHN Proxy: %s" , proxy ) set_auto_configuration ( config , hostname , rhn_ca , proxy ) else : logger . debug ( "Could not find hostname" ) return False return True else : logger . debug ( "Could not find rhn config" ) return False
Attempt to determine Satellite 5 Configuration