def getGETServer(logininfo, serverSettings): server= rpclib.GETServer(serverSettings.httpServerUrl, proxy = serverSettings.proxyUrl, username = serverSettings.proxyUser, password = serverSettings.proxyPassword, headers = logininfo) server.add_header("X-Up2date-Version", rhnUtils.version()) return server
def getGETServer(logininfo, serverSettings): server = rpclib.GETServer(serverSettings.httpServerUrl, proxy=serverSettings.proxyUrl, username=serverSettings.proxyUser, password=serverSettings.proxyPassword, headers=logininfo) server.add_header("X-Up2date-Version", rhnUtils.version()) return server
def getServer(refreshCallback=None): log = rhnLog.initLog() cfg = config.initUp2dateConfig() # Where do we keep the CA certificate for RHNS? # The servers we're talking to need to have their certs # signed by one of these CA. ca = cfg["sslCACert"] if type(ca) == type(""): ca = [ca] rhns_ca_certs = ca or ["%s/usr/share/rhn/RHNS-CA-CERT" % config.PREFIX] if cfg["enableProxy"]: proxyHost = rhnUtils.getProxySetting() else: proxyHost = None if hasSSL(): serverUrl = cfg["serverURL"] else: serverUrl = cfg["noSSLServerURL"] proxyUser = None proxyPassword = None if cfg["enableProxyAuth"]: proxyUser = cfg["proxyUser"] or None proxyPassword = cfg["proxyPassword"] or None lang = None for env in 'LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG': if os.environ.has_key(env): if not os.environ[env]: # sometimes unset continue lang = string.split(os.environ[env], ':')[0] lang = string.split(lang, '.')[0] break s = rpclib.Server(serverUrl, refreshCallback=refreshCallback, proxy=proxyHost, username=proxyUser, password=proxyPassword) s.add_header("X-Up2date-Version", rhnUtils.version()) if lang: s.setlang(lang) # require RHNS-CA-CERT file to be able to authenticate the SSL connections for rhns_ca_cert in rhns_ca_certs: if not os.access(rhns_ca_cert, os.R_OK): log.log_me("ERROR: can not find RHNS CA file: %s" % rhns_ca_cert) sys.exit(-1) # force the validation of the SSL cert s.add_trusted_cert(rhns_ca_cert) clientCaps.loadLocalCaps() # send up the capabality info headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: s.add_header(headerName, value) return s