1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import sys
17 try:
18
19 import xmlrpclib
20 except ImportError:
21
22 import xmlrpc.client as xmlrpclib
23
24 try:
25
26 from cStringIO import StringIO
27 except ImportError:
28
29 from io import StringIO
30
31
32
33 from spacewalk.common.rhnConfig import PRODUCT_NAME
34 from spacewalk.common.rhnTranslate import _
35 from spacewalk.common import rhnFlags
36
37
38
39 templateValues = {
40 'hostname': 'rhn.redhat.com',
41 }
42
43
44
45
46
47
48
49
50
51 FaultArray = {
52
53 1: _("This does not appear to be a valid username."),
54 2: _("Invalid username and password combination."),
55 3: _("This login is already taken, or the password is incorrect."),
56 4: _("Permission denied."),
57 6: _("Object not found."),
58 8: _("Invalid System Digital ID."),
59 9: _("Invalid System Credentials."),
60 10: _("Could not retrieve user data from database."),
61 11: _("Valid username required."),
62 12: _("Valid password required."),
63 13: _("Minimum username length violation."),
64 14: _("Minimum password length violation."),
65 15: _("The username contains invalid characters."),
66 17: _("File not found."),
67 19: _("Architecture and OS version combination is not supported."),
68 20: _("Could not retrieve system data from database."),
69 21: _("Invalid arguments passed to function."),
70 22: _("Unable to retrieve requested entry."),
71 23: _("Could not update database entry."),
72 24: _("Unsupported server architecture."),
73 28: _("""
74 The anonymous server functionality is no longer available.
75
76 Please re-register this system by running rhn_register
77 as root.
78 Please visit https://%(hostname)s/rhn/systems/SystemEntitlements.do
79 or login at https://%(hostname)s, and from the "Overview" tab,
80 select "Subscription Management" to enable the service for this system.
81 """),
82 29: _("Record not available in the database."),
83 30: _("Invalid value for entry."),
84 31: _("""
85 This system does not have a valid entitlement for Red Hat Satellite.
86 Please visit https://%(hostname)s/rhn/systems/SystemEntitlements.do
87 or login at https://%(hostname)s, and from the "Overview" tab,
88 select "Subscription Management" to enable the service for this system.
89 """),
90 32: _("Channel error"),
91 33: _("Client session token is invalid."),
92 34: _("Client session token has expired."),
93 35: _("You are not authorized to retrieve the requested object."),
94 36: _("Invalid action"),
95 37: _("You are not allowed to perform administrative tasks \
96 on this system."),
97 38: _("The system is already subscribed to the specified channel."),
98 39: _("The system is not currently subscribed to the specified channel."),
99 40: _("The specified channel does not exist."),
100 41: _("Invalid channel version."),
101 43: _("""
102 User group membership limits exceeded.
103
104 The current settings for your account do not allow you to add another
105 user account. Please check with the organization administrator for your
106 account if the maximum number of users allowed to subscribe to server needs
107 to be changed.
108 """),
109 44: _("""
110 System group membership limits exceeded.
111
112 The current settings for your account do not allow you to add another
113 system profile. Please check with the organization administrator for your
114 account for modifying the maximum number of system profiles that can be
115 subscribed to your account.
116 """),
117 45: _("""
118 Invalid architecture.
119
120 The architecture of the package is not supported by
121 """ + PRODUCT_NAME),
122 47: _("""Invalid RPM header"""),
123
124 50: _("Invalid information uploaded to the server"),
125 53: _("Error uploading network interfaces configuration."),
126 54: _("""
127 Package Upload Failed due to uniqueness constraint violation.
128 Make sure the package does not have any duplicate dependencies or
129 does not already exists on the server
130 """),
131 55: _("""
132 The --force rhnpush option is disabled on this server.
133 Please contact your Satellite administrator for more help.
134 """),
135
136
137 60: _("""
138 The activation token specified could not be found on the server.
139 Please retry with a valid key.
140 """),
141 61: _("Too many systems registered using this registration token"),
142 62: _("Token contains invalid, obsoleted or insufficient settings"),
143 63: _("Conflicting activation tokens"),
144
145
146 70: _("""
147 No matching base channel found for your system.
148 """),
149 71: _("""
150 You do not have subscription permission to the designated channel.
151 Please refer to your organization's channel or organization
152 administrators for further details.
153 """),
154 72: _("""You can not unsubscribe from base channel."""),
155 73: _("""Satellite or Proxy channel can not be subscribed."""),
156
157
158 80: _("There was an error while trying to join the system to its groups"),
159
160
161 90: _("Unable to entitle system"),
162
163
164 100: _("Maximum e-mail length violation."),
165 105: _("This system has been previously registered."),
166 106: _("Invalid username"),
167
168
169 140: _("Unable to look up server"),
170
171
172 160: _("Required argument is missing"),
173
174
175 601: _("No entitlement information tied to hardware"),
176 602: _("Installation number is not entitling"),
177
178
179 700: _("Maximum username length violation"),
180 701: _("Maximum password length violation"),
181 702: _("This user has read only API access. Action denied."),
182
183 800: _("System Name cannot be less than 1 character"),
184
185
186
187 1000: _("Spacewalk Proxy error."),
188 1001: _("Spacewalk Proxy unable to login."),
189
190 1002: _("""
191 Spacewalk Proxy system ID does not match a Spacewalk Proxy Server
192 in the database.
193 """),
194 1003: _("Spacewalk Proxy session token is invalid."),
195 1004: _("Spacewalk Proxy session token has expired."),
196
197
198
199 2001: _(PRODUCT_NAME + """
200 user creation is not allowed via rhn_register;
201 please contact your sysadmin to have your account created.
202 """),
203 2004: _("""
204 This satellite server is not allowed to use Inter Satellite Sync on this satellite
205 """),
206 2005: _("""
207 Inter Satellite Sync is disabled on this satellite.
208 """),
209
210
211 3000: _("Invalid datatype passed"),
212 3001: _("Unable to retrieve channel"),
213 3003: _("Unable to retrieve package"),
214 3005: _("Unable to retrieve erratum"),
215 3007: _("File is missing"),
216 3008: _("Function retrieval error"),
217 3009: _("Function execution error"),
218 3010: _("Missing version string"),
219 3011: _("Invalid version string"),
220 3012: _("Mismatching versions"),
221 3013: _("Invalid channel version"),
222 3015: _("No comps file for channel"),
223 3016: _("Unable to retrieve comps file"),
224
225
226 4002: _("Configuration action missing"),
227 4003: _("File too large"),
228 4004: _("File contains binary data"),
229 4005: _("Configuration channel is not empty"),
230 4006: _("Permission error"),
231 4007: _("Content missing for configuration file"),
232 4008: _("Template delimiters not specified"),
233 4009: _("Configuration channel does not exist"),
234 4010: _("Configuration channel already exists"),
235 4011: _("File missing from configuration channel"),
236 4012: _("Different revision of this file is uploaded"),
237 4013: _("File already uploaded to configuration channel"),
238 4014: _("File size exceeds remaining quota space"),
239 4015: _("Full path of file must be specified"),
240 4016: _("Invalid revision number"),
241 4017: _("Cannot compare files of different file type"),
242
243
244
245 5000: _("Crash information is invalid or incomplete"),
246 5001: _("Crash file information is invalid or incomplete"),
247 5002: _("Error composing crash directory path"),
248 5003: _("Error composing crash file path"),
249 5004: _("Invalid content encoding"),
250 5005: _("Invalid crash name"),
251 5006: _("Crash reporting is disabled for this organization"),
252
253 5101: _("SCAP results file transfer is invalid or incomplete"),
254 5102: _("Error composing directory path for detailed SCAP results"),
255 5103: _("Error composing file path for detailed SCAP results"),
256 5104: _("Invalid content encoding"),
257 }
258
259
261
262 """
263 This is the generic exception class we raise in the code when we want to
264 abort program execution and send a "500 Internal Server Error" message back
265 to the client.
266 """
267
269 Exception.__init__(self, *args)
270 self.args = args
271
273 """
274 String representation of this object.
275 """
276 s = StringIO()
277 s.write("\nInternal code error. Information available:\n")
278 for a in self.args:
279 s.write(" %s\n" % (a, ))
280
281 return s.getvalue()
282
283
285
286 """
287 pkilambi:This is the exception class we raise when we decide to
288 issue a redirect functions in apacheRequest will catch it and
289 transform it into a redirect path string
290 """
291
293 Exception.__init__(self)
294 self.path = redirectpath
295
297 """
298 Object in string format.
299 """
300 return repr(self.path)
301
302
303 Explain = _("""
304 An error has occurred while processing your request. If this problem
305 persists please enter a bug report at bugzilla.redhat.com.
306 If you choose to submit the bug report, please be sure to include
307 details of what you were trying to do when this error occurred and
308 details on how to reproduce this problem.
309 """)
310
311
313
314 """
315 This is a data exception class that is raised when we detect bad data.
316 The higher level functions in apacheServer will catch it and transform it
317 into an XMLRPC fault message that gets passed back to the client without
318 aborting the current execution of the process (well, we abort, but we don't
319 mail a traceback because this is the type of error we can handle - think
320 user authentication).
321 """
322
323 - def __init__(self, err_code=0, err_text="", explain=1):
324 self.code = err_code
325 self.text = err_text
326 self.explain = explain
327 self.arrayText = ''
328 if self.code and self.code in FaultArray:
329 self.arrayText = FaultArray[self.code]
330 Exception.__init__(self, self.code, self.text, self.arrayText)
331
333 """
334 String representation of this object.
335 """
336 return "<rhnFault class (code = %s, text = '%s')>" % (self.code,
337 self.text)
338
340
341
342
343 templateOverrides = rhnFlags.get('templateOverrides')
344
345
346 if templateOverrides:
347 for label in templateOverrides.keys():
348
349 if label in templateValues:
350 templateValues[label] = templateOverrides[label]
351
352 s = StringIO()
353 s.write("\n")
354 if self.text:
355 s.write(_("Error Message:\n %s\n") % self.text.strip())
356 if self.code:
357 s.write(_("Error Class Code: %s\n") % self.code)
358 if self.arrayText:
359 cinfo = self.arrayText % templateValues
360 s.write(_("Error Class Info: %s\n") % cinfo.rstrip())
361 if self.explain:
362 s.write(_("Explanation: %s") % Explain)
363 if not self.code:
364 return xmlrpclib.Fault(1, s.getvalue())
365 return xmlrpclib.Fault(-self.code, s.getvalue())
366
367
369
370 """ Raised when we want return 404 Not Found """
371 pass
372
373 if __name__ == "__main__":
374 print("You can not run this module by itself")
375 sys.exit(-1)
376