Package backend :: Package satellite_tools :: Package repo_plugins :: Module uln_src
[hide private]
[frames] | no frames]

Source Code for Module backend.satellite_tools.repo_plugins.uln_src

 1  """ 
 2  Copyright (C) 2014 Oracle and/or its affiliates. All rights reserved. 
 3   
 4  This program is free software; you can redistribute it and/or 
 5  modify it under the terms of the GNU General Public License 
 6  as published by the Free Software Foundation, version 2 
 7   
 8   
 9  This program is distributed in the hope that it will be useful, 
10  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
12  GNU General Public License for more details. 
13   
14  You should have received a copy of the GNU General Public License 
15  along with this program; if not, write to the Free Software 
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17  02110-1301, USA. 
18   
19  ULN plugin for spacewalk-repo-sync. 
20  """ 
21  # pylint: disable=E0012, C0413 
22  import sys 
23  sys.path.append('/usr/share/rhn') 
24  from up2date_client.rpcServer import RetryServer, ServerList 
25   
26  from spacewalk.satellite_tools.repo_plugins.yum_src import ContentSource as yum_ContentSource 
27  from spacewalk.satellite_tools.syncLib import RhnSyncException 
28   
29  ULNSRC_CONF = '/etc/rhn/spacewalk-repo-sync/uln.conf' 
30  DEFAULT_UP2DATE_URL = "linux-update.oracle.com" 
31   
32   
33 -class ContentSource(yum_ContentSource):
34
35 - def __init__(self, url, name, org="1", channel_label="", no_mirrors=False, ca_cert_file=None, 36 client_cert_file=None, client_key_file=None):
37 if url[:6] != "uln://": 38 raise RhnSyncException("url format error, url must start with uln://") 39 yum_ContentSource.__init__(self, url, name, yumsrc_conf=ULNSRC_CONF, org=org, channel_label=channel_label, 40 no_mirrors=no_mirrors, ca_cert_file=ca_cert_file, client_cert_file=client_cert_file, 41 client_key_file=client_key_file) 42 self.uln_url = None 43 self.uln_user = None 44 self.uln_pass = None 45 self.key = None
46
47 - def _authenticate(self, url):
48 if url.startswith("uln:///"): 49 self.uln_url = "https://" + DEFAULT_UP2DATE_URL 50 label = url[7:] 51 elif url.startswith("uln://"): 52 parts = url[6:].split("/") 53 self.uln_url = "https://" + parts[0] 54 label = parts[1] 55 else: 56 raise RhnSyncException("url format error, url must start with uln://") 57 self.uln_user = self.yumbase.conf.username 58 self.uln_pass = self.yumbase.conf.password 59 self.url = self.uln_url + "/XMLRPC/GET-REQ/" + label 60 print("The download URL is: " + self.url) 61 if self.proxy_addr: 62 print("Trying proxy " + self.proxy_addr) 63 slist = ServerList([self.uln_url+"/rpc/api",]) 64 s = RetryServer(slist.server(), 65 refreshCallback=None, 66 proxy=self.proxy_addr, 67 username=self.proxy_user, 68 password=self.proxy_pass, 69 timeout=5) 70 s.addServerList(slist) 71 self.key = s.auth.login(self.uln_user, self.uln_pass)
72 73 # pylint: disable=arguments-differ
74 - def setup_repo(self, repo, *args, **kwargs):
75 repo.http_headers = {'X-ULN-Api-User-Key': self.key} 76 yum_ContentSource.setup_repo(self, repo, *args, **kwargs)
77