liedekef / spacewalk_scripts

Several spacewalk scripts
52 stars 25 forks source link

Add option for listing available Red Hat Channels #32

Closed jjperry69 closed 8 years ago

jjperry69 commented 8 years ago

When starting to use this script to push Errata into Spacewalk 2.4 I found that while my repo and path names for Red Hat at CDN were correct, I had the wrong errata channels. Looking at your code and the API, I hacked out a quick routine to dump all available channels. I am not a good enough coder to fork and submit a pull request, so I wanted to provide the block of code I just in case you think this may be useful for others as well.

Please pardon my horrid Perl coding style. It was a quick hack to get me moving forward.

BTW. Great work on this code. It solved the issue I had with having RHEL 6 and CentOS 6 channels. Errata were only getting applied to the first package it found in any channel.

print "getting channels \n"; my $channels_rh = $client->call('channel.listSoftwareChannels',$sessionid); print "Channel Label : Channel Name : Channel Parent Label : Channel EOL : Channel Arch\n"; foreach my $rhchan (@$channels_rh) { my $rh_label=$rhchan->{'channel_label'}; my $rh_name=$rhchan->{'channel_name'}; my $rh_parent=$rhchan->{'channel_parent_label'}; my $rh_eol=$rhchan->{'channel_end_of_life'}; my $rh_arch=$rhchan->{'channel_arch'}; print $rh_label," : ",$rh_name," : ",$rh_parent," : ",$rh_eol," : ",$rh_arch,"\n"; }

tautzie commented 8 years ago

Ciao jjperry69,

could you please give a hint on which position I have to paste your code in the script to make it work? I have currently a similar issue as described by you but with RHEL7. (same as this one: RHEL 7 support)

The option "--redhat-channel rhel-x86_64-server-5/6" is working fine for RHEL 5 and 6 but not for 7, so I assume that the channel name style has changed with with the introduction of RHEL7. I hope to findout the correct channel name for RHEL7 with the help of your little script. I also tested "--redhat-channel rhel-7-server-rpms" but its neither working.

jjperry69 commented 8 years ago

To find the list of channels available from Red Hat, you can use the spacewalk-api.

You must have a Red Hat login with an active support agreement for the below command to work.

spacewalk-api --server=xmlrpc.rhn.redhat.com/rpc/api --user --pass channel.listSoftwareChannels '%session%'

jjperry69 commented 8 years ago

API documentation for the xmlrpc.rh.redhat.com site can be found at https://access.redhat.com/documentation/en-US/Red_Hat_Network/5.0.0/html/API_Documentation/index.html.

tautzie commented 8 years ago

The API call does not return any channels suitable for RHEL7, so I think the problem is related to RedHat's move from RHN to RHSM... But thank's for your answer!

liedekef commented 8 years ago

The version 20160401 of the script now shows the redhat channels found in the debug output.