Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2008--2015 Red Hat, Inc. 3 # 4 # This software is licensed to you under the GNU General Public License, 5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 8 # along with this software; if not, see 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 10 # 11 # Red Hat trademarks are not licensed under GPLv2. No permission is 12 # granted to use or replicate Red Hat trademarks that are incorporated 13 # in this software or its documentation. 14 # 15 # 16 17 from spacewalk.common.rhnLog import log_debug, log_error 18 from spacewalk.common.rhnConfig import CFG 19 from spacewalk.common.rhnException import rhnFault 20 from spacewalk.common.rhnTranslate import _ 21 from spacewalk.common.RPC_Base import RPC_Base 22 23 from spacewalk.server import rhnServer 24 25 # extend the RPC_Base base class 26 27299331 RPC_Base.__init__(self) 32 # extra class members we handle 33 self.server = None 34 self.server_id = None 35 36 # XXX Some subclasses set this as a string, others as an rhnUser 37 self.user = None 38 39 # defaults that can be easily overridden through assignement of self.* 40 # do we load the user infomation (seldomly needed) 41 self.load_user = 0 42 # do we check for entitlement of the server 43 self.check_entitlement = 1 44 # do we attempt throttling 45 self.throttle = CFG.THROTTLE 46 # attempt quality of service checks 47 self.set_qos = CFG.QOS 48 # do we update the checking counters 49 self.update_checkin = 150 51 # Authenticate a system based on the certificate. There are a lot 52 # of modifiers that can be set before this function is called (see 53 # the __init__ function for this class). 5456 log_debug(3) 57 58 server = rhnServer.get(system_id, load_user=self.load_user) 59 if not server: 60 # Invalid server certificate. 61 raise rhnFault(9, _( 62 "Please run rhn_register as root on this client")) 63 self.server_id = server.getid() 64 self.server = server 65 # update the latest checkin time 66 if self.update_checkin: 67 server.checkin() 68 69 # is the server entitled? 70 if self.check_entitlement: 71 entitlements = server.check_entitlement() 72 if not entitlements: # we require entitlement for this functionality 73 log_error("Server Not Entitled", self.server_id) 74 raise rhnFault(31, _( 75 'Service not enabled for system profile: "%s"') 76 % server.server["name"]) 77 78 # Kind of poking where we shouldn't, but what the hell 79 if self.load_user and self.user is not None: 80 self.user = server.user.username 81 else: 82 self.user = None 83 84 if self.user is None: 85 self.user = "" 86 # Throttle users if necessary 87 if self.throttle: 88 server.throttle() 89 # Set QOS 90 if self.set_qos: 91 server.set_qos() 92 return server
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:49 2020 | http://epydoc.sourceforge.net |