1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import sys
18
19 from spacewalk.common.usix import raise_with_tb
20 from spacewalk.common import rhnFlags, rhnMail
21 from spacewalk.common.rhnLog import log_debug, log_error
22 from spacewalk.common.rhnConfig import CFG
23 from spacewalk.common.rhnException import rhnFault
24 from spacewalk.common.rhnTranslate import _, cat
25 from spacewalk.common.rhnLib import checkValue
26 from spacewalk.server.rhnLib import normalize_server_arch
27 from spacewalk.server.rhnServer import server_route, server_lib
28 from spacewalk.server.rhnServer.server_certificate import Certificate
29 from spacewalk.server.rhnHandler import rhnHandler
30 from spacewalk.server import rhnUser, rhnServer, rhnSQL, rhnCapability, \
31 rhnChannel, rhnVirtualization
32 from spacewalk.common.rhnTB import add_to_seclist
33
34
36 """ verify that a hash has all the keys and those have actual values """
37 for k in keylist:
38 if k not in data:
39 return 0
40 l = data[k]
41 if l is None:
42 return 0
43 if type(l) == type("") and len(l) == 0:
44 return 0
45 return 1
46
47
49 vendor = smbios.get('smbios.bios.vendor')
50 serial = smbios.get('smbios.system.serial', '')
51 manufacturer = smbios.get('smbios.system.manufacturer')
52 product = smbios.get('smbios.system.product')
53
54
55
56 uuid = None
57 if 'smbios.system.uuid' in smbios:
58 uuid = smbios['smbios.system.uuid']
59 uuid = uuid.replace('-', '')
60
61 virttype = None
62 if uuid is not None and (
63 vendor == "QEMU"
64 or manufacturer == 'QEMU'
65 or (manufacturer == 'Bochs' and product == 'Bochs')
66 or (manufacturer == 'RDO' and product == 'OpenStack Compute')
67 or (manufacturer == 'Google' and product == 'Google Compute Engine')
68 or (manufacturer == 'Red Hat' and product in ('KVM', 'RHEV Hypervisor', 'OpenStack Compute'))
69 or (product == 'OpenStack Nova' and (manufacturer in ('Fedora Project', 'RDO Project') or
70 manufacturer and manufacturer.startswith('Red Hat')))
71 or (manufacturer == 'oVirt' and product in ('oVirt Node', 'RHEV Hypervisor'))
72 or (manufacturer == 'Nutanix' and product == 'AHV')):
73 virttype = rhnVirtualization.VirtualizationType.QEMU
74 else:
75 if manufacturer == 'Microsoft Corporation' and product == 'Virtual Machine':
76 virttype = rhnVirtualization.VirtualizationType.HYPERV
77 elif serial.startswith('VMware-'):
78 virttype = rhnVirtualization.VirtualizationType.VMWARE
79 elif manufacturer == 'HITACHI' and product.endswith(' HVM LPAR'):
80 virttype = rhnVirtualization.VirtualizationType.VIRTAGE
81 if uuid is None:
82 uuid = "flex-guest"
83
84 if virttype:
85 return (virttype, uuid)
86 return (None, None)
87
88
90
91 """ encapsulate functions that we will provide for the outside world """
92
94 rhnHandler.__init__(self)
95 self.functions.append("activate_registration_number")
96 self.functions.append("activate_hardware_info")
97 self.functions.append("available_eus_channels")
98 self.functions.append("add_hw_profile")
99 self.functions.append("add_packages")
100 self.functions.append("anonymous")
101 self.functions.append("delete_packages")
102 self.functions.append("delta_packages")
103 self.functions.append("finish_message")
104 self.functions.append("get_possible_orgs")
105 self.functions.append("new_system")
106 self.functions.append("new_system_user_pass")
107
108 self.functions.append("new_user")
109 self.functions.append("privacy_statement")
110 self.functions.append("refresh_hw_profile")
111 self.functions.append("register_osad")
112 self.functions.append("register_osad_jid")
113 self.functions.append("register_product")
114 self.functions.append("remaining_subscriptions")
115 self.functions.append("reserve_user")
116 self.functions.append("send_serial")
117 self.functions.append("upgrade_version")
118 self.functions.append("update_contact_info")
119 self.functions.append("update_packages")
120 self.functions.append("update_systemid")
121 self.functions.append("update_transactions")
122 self.functions.append("virt_notify")
123 self.functions.append("welcome_message")
124
125
126 self.load_user = 0
127 self.check_entitlement = 0
128 self.throttle = 0
129
130
131
132 self.vendor_tags = {'DELL': 'smbios.system.serial'}
133
135 """
136 Get an username and a password and create a record for this user.
137 Eventually mark it as such.
138 Additionaly this method is used to verify login and password in early
139 stage of rhn_register.
140
141 Returns true value if user is reserved, otherwise fault is raised.
142 """
143
144 add_to_seclist(password)
145
146 log_debug(1, username)
147
148
149 ret = rhnUser.reserve_user(username, password)
150 log_debug(3, "rhnUser.reserve_user returned: " + str(ret))
151 if ret < 0:
152 raise rhnFault(3)
153 return ret
154
155 - def new_user(self, username, password, email=None,
156 org_id=None, org_password=None):
157 """
158 Finish off creating the user.
159
160 The user has to exist (must be already reserved), the password must
161 match and we set the e-mail address if one is given
162
163 Return true if success
164 """
165
166 log_debug(1, username, email)
167
168 if not checkValue(email, None, "", type("")):
169 raise rhnFault(30, _faultValueString(email, "email"))
170
171 if org_id and org_password:
172 org_password = str(org_password)
173 try:
174 org_id = int(str(org_id))
175 except ValueError:
176 raise_with_tb(rhnFault(30, _faultValueString(org_id, "org_id")), sys.exc_info()[2])
177 else:
178 org_id = org_password = None
179 username, password = rhnUser.check_user_password(username, password)
180 email = rhnUser.check_email(email)
181
182 ret = rhnUser.new_user(username, password, email, org_id, org_password)
183
184 return ret
185
195
217
218 - def create_system(self, user, profile_name, release_version,
219 architecture, data):
220 """
221 Create a system based on the input parameters.
222
223 Return dict containing a server object for now.
224 Called by new_system (< rhel5)
225 and new_system_user_pass | new_system_activation_key (>= rhel5)
226 """
227
228 if profile_name is not None and not \
229 rhnFlags.test("re_registration_token") and \
230 len(profile_name) < 1:
231 raise rhnFault(800)
232
233
234 if "token" in data:
235 log_item = "token = '%s'" % data["token"]
236 else:
237 log_item = "username = '%s'" % user.username
238
239 log_debug(1, log_item, release_version, architecture)
240
241
242 if "uuid" in data:
243 applet_uuid = data['uuid']
244 log_debug(3, "applet uuid", applet_uuid)
245 else:
246 applet_uuid = None
247
248
249 if "rhnuuid" in data:
250 up2date_uuid = data['rhnuuid']
251 log_debug(3, "up2date uuid", up2date_uuid)
252
253
254 else:
255 up2date_uuid = None
256
257 release = str(release_version)
258
259 if 'token' in data:
260 token_string = data['token']
261
262
263 tokens_obj = rhnServer.search_token(token_string)
264 log_user_id = tokens_obj.get_user_id()
265 else:
266
267 log_user_id = user.getid()
268 tokens_obj = rhnServer.search_org_token(user.contact["org_id"])
269 log_debug(3, "universal_registration_token set as %s" %
270 str(tokens_obj.get_tokens()))
271 rhnFlags.set("universal_registration_token", tokens_obj)
272
273 if 'channel' in data and len(data['channel']) > 0:
274 channel = data['channel']
275 log_debug(3, "requested EUS channel: %s" % str(channel))
276 else:
277 channel = None
278
279 newserv = None
280 if tokens_obj:
281
282
283
284 rhnFlags.set("registration_token", tokens_obj)
285
286 if tokens_obj.is_rereg_token:
287
288 rhnFlags.set("re_registration_token", tokens_obj)
289
290 newserv = rhnServer.search(tokens_obj.get_server_id())
291 newserv.disable_token()
292
293 newserv.delete_hardware()
294
295
296 newserv.set_arch(architecture)
297
298 if not newserv.server['creator_id']:
299 newserv.user = user
300 else:
301 newserv.user = rhnUser.User("", "")
302 newserv.user.reload(newserv.server['creator_id'])
303
304 newserv.gen_secret()
305
306 newserv.dispose_packages()
307
308 newserv.change_base_channel(release)
309
310 if newserv is None:
311
312 rhnSQL.set_log_auth(log_user_id)
313 newserv = rhnServer.Server(user, architecture)
314
315
316 newserv.server["release"] = release
317 if 'release_name' in data:
318 newserv.server["os"] = data['release_name']
319
320
321 if 'packages' in data:
322 for package in data['packages']:
323 newserv.add_package(package)
324
325 if 'hardware_profile' in data:
326 for hw in data['hardware_profile']:
327 newserv.add_hardware(hw)
328
329 if profile_name is not None and not \
330 rhnFlags.test("re_registration_token"):
331 newserv.server["name"] = profile_name[:128]
332 if 'os' in data:
333 newserv.server["os"] = data["os"][:64]
334 if 'description' in data:
335 newserv.server["description"] = data["description"][:256]
336 else:
337 newserv.default_description()
338
339
340
341 if 'virt_uuid' in data:
342 virt_uuid = data['virt_uuid']
343 if virt_uuid is not None \
344 and not rhnVirtualization.is_host_uuid(virt_uuid):
345
346 virt_type = None
347 if 'virt_type' in data:
348 virt_type = data['virt_type']
349 if virt_type == 'para':
350 virt_type = rhnVirtualization.VirtualizationType.PARA
351 elif virt_type == 'fully':
352 virt_type = rhnVirtualization.VirtualizationType.FULLY
353 else:
354 raise Exception(
355 "Unknown virtualization type: %s" % virt_type)
356 else:
357 raise Exception("Virtualization type not provided")
358 newserv.virt_uuid = virt_uuid
359 newserv.virt_type = virt_type
360 else:
361 newserv.virt_uuid = None
362 newserv.virt_type = None
363 else:
364 newserv.virt_uuid = None
365 newserv.virt_type = None
366
367
368 if 'smbios' in data and newserv.virt_uuid is None:
369 (newserv.virt_type, newserv.virt_uuid) = \
370 parse_smbios(data['smbios'])
371
372 if tokens_obj.forget_rereg_token:
373
374
375 tokens_obj.is_rereg_token = 0
376 rhnFlags.set("re_registration_token", 0)
377
378
379
380 if rhnFlags.test("registration_token"):
381
382 newserv.load_token()
383
384
385
386
387
388
389
390
391
392
393
394
395
396 try:
397
398 newserv.save(0, channel)
399 except (rhnChannel.NoBaseChannelError), channel_error:
400 raise_with_tb(rhnFault(70), sys.exc_info()[2])
401 except rhnChannel.BaseChannelDeniedError, channel_error:
402 raise_with_tb(rhnFault(71), sys.exc_info()[2])
403 except server_lib.rhnSystemEntitlementException:
404 e = sys.exc_info()[1]
405 raise_with_tb(rhnFault(90), sys.exc_info()[2])
406
407
408
409
410 log_debug(3, "reg token process_kickstart_info")
411 newserv.process_kickstart_info()
412
413
414 newserv.use_token()
415 else:
416
417 newserv.server["info"] = "rhn_register by %s" % log_item
418 log_debug(3, "rhn_register process_kickstart_info")
419 newserv.process_kickstart_info()
420
421
422 if up2date_uuid:
423 newserv.uuid = up2date_uuid
424
425
426
427
428
429
430
431
432
433
434 try:
435 newserv.save(1, channel)
436 except (rhnChannel.NoBaseChannelError), channel_error:
437 raise_with_tb(rhnFault(70), sys.exc_info()[2])
438 except rhnChannel.BaseChannelDeniedError, channel_error:
439 raise_with_tb(rhnFault(71), sys.exc_info()[2])
440 except server_lib.rhnSystemEntitlementException:
441 e = sys.exc_info()[1]
442
443 raise_with_tb(rhnFault(90), sys.exc_info()[2])
444
445 if CFG.SEND_EOL_MAIL and user and newserv.base_channel_is_eol():
446 self.attempt_eol_mailing(user, newserv)
447
448
449
450
451 server_route.store_client_route(newserv.getid())
452
453 return {'server': newserv, }
454
456 """
457 This function expects at the INPUT a dictionary that has at least
458 the following members: username, password, os_release, email
459 If the username does not exist, it is created. If the username
460 exists, then password is checked for a match.
461 If all is well, we send back a server certificate.
462 --
463 Hash
464 --
465 Struct
466
467 Starting with RHEL 5, the client will use activate_registration_number,
468 activate_hardware_info, new_system_user_pass, and/or
469 new_system_activation_key instead of this.
470
471 In hosted, RHEL 4 and earlier will also call
472 activate_registration_number
473 """
474
475 if "password" in data:
476 add_to_seclist(data["password"])
477
478
479 self.validate_system_input(data)
480
481
482
483 user = None
484 if 'token' not in data:
485 user = self.validate_system_user(data["username"],
486 data["password"])
487
488 release_version = data['os_release']
489 profile_name = data['profile_name']
490 architecture = data['architecture']
491
492
493
494
495
496
497
498
499
500
501
502 server_data = self.create_system(user, profile_name,
503 release_version,
504 architecture, data)
505 newserv = server_data['server']
506
507 system_certificate = newserv.system_id()
508
509
510 return system_certificate
511
512 - def new_system_user_pass(self, profile_name, os_release_name,
513 version, arch, username,
514 password, other):
515 """ Registers a new system to an org specified by a username, password, and
516 optionally an org id.
517
518 New for RHEL 5.
519
520 All args are strings except other.
521 other is a dict with:
522 * org_id - optional. Must be a string that contains the number. If it's
523 not given, the default org is used.
524
525 If a profile is created it will return a dict with:
526 * system_id - the same xml as was previously returned
527 * channels - a list of the channels (as strings) the system was
528 subscribed to
529 * failed_channels - a list of channels (as strings) that
530 the system should have been subscribed to but couldn't be because they
531 don't have the necessary entitlements available. Can contain all the
532 channels including the base channel.
533 * system_slots - a list of the system slots used (as strings).
534 * failed_system_slots - a list of system slots (as strings) that they
535 should have used but couldn't because there weren't available
536 entitlements
537 * universal_activation_key - a list of universal default activation keys
538 (as strings) that were used while registering.
539 The call will try to use the highest system slot available. An entry will
540 be added to failed_system_slots for each one that is tried and fails and
541 system_slots will contain the one that succeeded if any.
542
543 If an error occurs which prevents the creation of a profile, a fault will
544 be raised:
545 TODO
546 """
547
548 add_to_seclist(password)
549
550 log_debug(4, 'in new_system_user_pass')
551
552
553
554 other['release_name'] = os_release_name
555
556
557 user = self.validate_system_user(username, password)
558
559
560
561 server_data = self.create_system(user, profile_name,
562 version,
563 arch,
564 other)
565
566 newserv = server_data['server']
567
568
569 server_id = newserv.getid()
570
571
572 system_certificate = newserv.system_id()
573
574 log_debug(4, 'Server id created as %s' % server_id)
575
576 failures = []
577 unknowns = []
578
579
580 attempted_channels = []
581 successful_channels = []
582 failed_channels = []
583
584 actual_channels = rhnChannel.channels_for_server(server_id)
585 for channel in actual_channels:
586 successful_channels.append(channel['label'])
587
588
589
590 if len(successful_channels) == 0:
591 log_debug(4, 'System %s not subscribed to any channels' % server_id)
592
593
594 try:
595 base = rhnChannel.get_channel_for_release_arch(
596 version,
597 arch, newserv['org_id'])
598 failed_channels.append(base['label'])
599
600
601 except:
602 pass
603
604
605 failed_channels = failed_channels + failures
606
607 attempted_system_slots = ['enterprise_entitled']
608 successful_system_slots = server_lib.check_entitlement(server_id)
609 successful_system_slots = list(successful_system_slots.keys())
610 failed_system_slots = []
611
612
613 i = 0
614 for slot in attempted_system_slots:
615 if slot in successful_system_slots:
616 break
617 i = i + 1
618
619
620 failed_system_slots = attempted_system_slots[0:i]
621
622 universal_activation_key = []
623 if rhnFlags.test("universal_registration_token"):
624 token = rhnFlags.get("universal_registration_token")
625 universal_activation_key = token.get_tokens()
626
627 return {'system_id': system_certificate,
628 'channels': successful_channels,
629 'failed_channels': failed_channels,
630 'failed_options': unknowns,
631 'system_slots': successful_system_slots,
632 'failed_system_slots': failed_system_slots,
633 'universal_activation_key': universal_activation_key
634 }
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
658 """ Gets all the orgs that a user belongs to.
659 In the OCS-future, users may belong to more than one org.
660
661 New for RHEL 5.
662
663 Returns a dict like:
664 {
665 'orgs': {'19': 'Engineering', '4009': 'Finance'},
666 'default_org': '19'
667 }
668 'orgs' must have at least one pair and 'default_org' must exist and point
669 to something in 'orgs'.
670
671 TODO Pick fault number for this and document it here
672 Fault:
673 * Bad credentials
674 """
675 user = rhnUser.auth_username_password(username, password)
676
677
678
679
680
681
682 org_id = user.contact["org_id"]
683 org_name = user.customer["name"]
684 orgs = {str(org_id): org_name}
685 default_org = str(org_id)
686 return {'orgs': orgs, 'default_org': default_org}
687
689 """ Entitle a particular org using an entitlement number.
690
691 New for RHEL 5.
692
693 username, password, and key are strings.
694 other is a dict with:
695 * org_id - optional. If it's not given, the user's default org is used.
696
697 Returns a dict:
698 {
699 'status_code': <status code>,
700 'registration_number': 'EN for this system'
701 'channels' : channels,
702 'system_slots' : system_slots
703 }
704 'status_code' must be 0 for "we just activated the key" or 1 for "this
705 key was already activated."
706 'registration_number' will be the EN corresponding to this activation. If
707 we activated an EN we'll get the same thing back. If we activate an OEM
708 number (eg asset tag) and maybe a pre-rhel 5 subscription number, we'll
709 get back the EN that was generated from it.
710 'channels' is a dict of the channel susbscriptions that the key activated
711 the key/value pairs are label (string) / quantity (int)
712 'system_slots' is a dict of the system slots that the key activated
713 the key/value pairs are label (string) / quantity (int)
714
715 TODO Assign fault values and document them here
716 Faults:
717 * Invalid key (600)
718 * Bad credentials (?) - covers bad username and password, bad org id, and
719 user not in specified org
720 """
721
722
723
724
725
726 raise rhnFault(602)
727
729 """ Given some hardware information, we try to find the asset tag or
730 serial number.
731
732 See activate_hardware_info below for the structure of the
733 hardware_info
734 """
735
736 if vendor in self.vendor_tags:
737 asset_value = ""
738 key = self.vendor_tags[vendor]
739 log_debug(5, "key: " + str(key))
740 if key in hardware_info:
741 return hardware_info[key]
742
743
744 log_debug(5, "no tag found for vendor: " + str(vendor))
745 return None
746
755
757 """
758 Given some hardware-based criteria per-vendor, try giving entitlements.
759
760 New for RHEL 5.
761
762 Mostly the same stuff as activate_registration_number.
763 hardware_info is a dict of stuff we get from hal from
764 Computer -> system.* and smbios.*. For example:
765 {
766 'system.product': '2687D8U ThinkPad T43',
767 'system.vendor': 'IBM',
768 'smbios.chassis.type': 'Notebook',
769 ...
770 }
771 """
772
773 log_debug(5, username, hardware_info, other)
774
775
776
777
778
779
780 raise rhnFault(601)
781
783
784 if not user:
785 raise Exception("user required to attempt eol mailing")
786
787 if "email" in user.info:
788 log_debug(4, "sending eol mail...")
789 body = EOL_EMAIL % {'server': server.server['name']}
790 headers = {}
791 headers['From'] = 'Red Hat Satellite <dev-null@rhn.redhat.com>'
792 headers['To'] = user.info['email']
793 headers['Subject'] = 'End of Life RHN Channel Subscription'
794 rhnMail.send(headers, body)
795
796 - def send_serial(self, system_id, number, vendor=None):
797 """
798 Receive a vendor serial number from the client and tag it to the server.
799 """
800 log_debug(1, number, vendor)
801
802 return 0
803
804
805
806
821
836
851
853 log_debug(5, system_id, packages)
854 if CFG.DISABLE_PACKAGES:
855 return 0
856 if type(packages) != type({}):
857 log_error("Invalid argument type", type(packages))
858 raise rhnFault(21)
859 added_packages = self._normalize_packages(system_id, packages.get('added'), allow_none=1)
860 removed_packages = self._normalize_packages(system_id, packages.get('deleted'), allow_none=1)
861
862 server = self.auth_system(system_id)
863
864 if added_packages is not None:
865 log_debug(1, self.server_id, "added: %d" % len(added_packages))
866 if removed_packages is not None:
867 log_debug(1, self.server_id, "deleted: %d" % len(removed_packages))
868
869 rhnCapability.update_client_capabilities(self.server_id)
870 for package in added_packages or []:
871 server.add_package(package)
872 for package in removed_packages or []:
873 server.delete_package(package)
874 server.save_packages()
875 return 0
876
895
913
970
978
1018
1041
1043 """ returns string of welcome message """
1044 log_debug(1, "lang: %s" % lang)
1045 if lang:
1046 cat.setlangs(lang)
1047 msg = _("Red Hat Satellite Welcome Message")
1048
1049 rhnFlags.set("compress_response", 1)
1050 return msg
1051
1053 """ returns string of privacy statement """
1054 log_debug(1, "lang: %s" % lang)
1055 if lang:
1056 cat.setlangs(lang)
1057 msg = _("Red Hat Satellite Privacy Statement")
1058
1059 rhnFlags.set("compress_response", 1)
1060 return msg
1061
1063 """ register a product and record the data sent with the registration
1064
1065 bretm: hasn't registered a product or recorded anything since 2001, near
1066 as I can tell what it actually appears to be responsible for is
1067 protecting us against people registering systems from t7/t9
1068 countries
1069
1070 actual use of registration numbers has been moved into the
1071 server_class.__save stuff
1072 """
1073
1074 log_debug(5, system_id, product, oeminfo)
1075 if type(product) != type({}):
1076 log_error("Invalid argument type", type(product))
1077 raise rhnFault(21, _(
1078 "Expected a dictionary as a product argument"))
1079 log_debug(4, product)
1080
1081
1082
1083 self.auth_system(system_id)
1084 return 0
1085
1100
1108
1109 - def anonymous(self, release=None, arch=None):
1113
1115 """ Presents the client with a message to display
1116 Returns:
1117 (returnCode, titleText, messageText)
1118 titleText is the window's title, messageText is the message displayed in
1119 that window by the client
1120
1121 if returnCode is 1, the client
1122 will show the message in a window with the
1123 title of titleText, and allow the user to
1124 continue.
1125 if returnCode is -1, the client
1126 will show the message in a window with the
1127 title of titleText, and not allow the user
1128 to continue
1129 if returnCode is 0, no message
1130 screen will be shown.
1131 """
1132 log_debug(1)
1133
1134 self.auth_system(system_id)
1135
1136 return_code, text_title, text_message = \
1137 self.server.fetch_registration_message()
1138 if return_code:
1139 return return_code, text_title, text_message
1140
1141
1142
1143 return_code = int(CFG.REG_FINISH_MESSAGE_RETURN_CODE)
1144 if return_code == 0:
1145
1146 return (0, "", "")
1147
1148
1149 text_title = CFG.REG_FINISH_MESSAGE_TITLE or ""
1150 text_file = CFG.REG_FINISH_MESSAGE_TEXT_FILE
1151 try:
1152 text_message = open(text_file).read()
1153 except IOError:
1154 e = sys.exc_info()[1]
1155 log_error("reg_fishish_message_return_code is set, but file "
1156 "%s invalid: %s" % (text_file, e))
1157 return (0, "", "")
1158 return (return_code, text_title, text_message)
1159
1160 _query_get_dispatchers = rhnSQL.Statement("""
1161 select jabber_id from rhnPushDispatcher
1162 """)
1163
1168
1170 log_debug(1)
1171
1172
1173 server = self.auth_system(system_id)
1174
1175 jabber_server = CFG.JABBER_SERVER
1176 if not jabber_server:
1177 log_error("Jabber server not defined")
1178 return {}
1179
1180 server_timestamp, client_name, shared_key = \
1181 server.register_push_client()
1182
1183 ret = args.copy()
1184 dispatchers = self._get_dispatchers()
1185 ret.update({
1186 'client-name': client_name,
1187 'shared-key': shared_key,
1188 'server-timestamp': server_timestamp,
1189 'jabber-server': jabber_server,
1190 'dispatchers': dispatchers,
1191 })
1192 return ret
1193
1206
1209 '''
1210 Given a server arch, redhat-release version, and redhat-release release
1211 returns the eligible channels for that system based on the entitlements
1212 in the org specified by username/password
1213
1214 Returns a dict of the available channels in the format:
1215 {'default_channel' : 'channel_label',
1216 'receiving_updates' : ['channel_label1', 'channel_label2'],
1217 'channels' : {'channel_label1' : 'channel_name1',
1218 'channel_lable2' : 'channel_name2'}
1219 }
1220 '''
1221
1222 user = rhnUser.search(username)
1223
1224 if user is None:
1225 log_error("invalid username", username)
1226 raise rhnFault(2)
1227
1228 if not user.check_password(password):
1229 log_error("User password check failed", username)
1230 raise rhnFault(2)
1231
1232 server_arch = normalize_server_arch(arch)
1233 user_id = user.getid()
1234 org_id = user.contact['org_id']
1235
1236 channels = rhnChannel.base_eus_channel_for_ver_rel_arch(
1237 version, release, server_arch,
1238 org_id, user_id)
1239
1240 log_debug(4, "EUS Channels are: %s" % str(channels))
1241
1242 default_channel = ''
1243 eus_channels = {}
1244 receiving_updates = []
1245
1246 if channels is not None:
1247 eus_channels = {}
1248 for channel in channels:
1249 eus_channels[channel['label']] = channel['name']
1250 if channel['is_default'] == 'Y':
1251 default_channel = channel['label']
1252 if channel['receiving_updates'] == 'Y':
1253 receiving_updates.append(channel['label'])
1254
1255 return {'default_channel': default_channel,
1256 'receiving_updates': receiving_updates,
1257 'channels': eus_channels}
1258
1259 - def remaining_subscriptions(self, username, password, arch, release):
1260 """ This is an obsoleted API call used in old RHEL5 clients to determine
1261 if they should show the "activate a subscription" page.
1262 """
1263 return 1
1264
1285
1286
1288 return _("Invalid value '%s' for %s (%s)") % (
1289 str(value), str(name), type(value))
1290
1291
1292 EOL_EMAIL = """
1293 Dear Red Hat Satellite User,
1294
1295 This email has been autogenerated to alert you that you recently subscribed the
1296 following system to an RHN channel related to a Red Hat Linux distribution that
1297 has reached End of Life:
1298
1299 %(server)s
1300
1301 Distributions that have reached End of Life are no longer receiving maintenance
1302 support (errata), which may make them unsuitable to your needs.
1303
1304 For more information regarding Red Hat Linux support, please go to:
1305
1306 http://www.redhat.com/apps/support/errata/
1307
1308 If you are interested in a distribution of Red Hat with a longer release
1309 lifecycle, 5+ year maintenance period, ISV support, and enhanced functionality,
1310 check out Red Hat Enterprise Linux at:
1311
1312 http://www.redhat.com/software/rhel/
1313
1314
1315 Thank you for using Red Hat Satellite.
1316 """
1317
1318
1319
1320