Created
November 18, 2013 15:07
-
-
Save mschmitt/7529305 to your computer and use it in GitHub Desktop.
Script to find the satellite channels that provide a given package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use Frontier::Client; | |
use Data::Dumper; | |
use Term::ReadKey; | |
my $find_package; | |
if ($ARGV[0]){ | |
$find_package = $ARGV[0]; | |
}else{ | |
die "Please specify package name!\n"; | |
} | |
# | |
# Establish connection | |
# | |
my $HOST = 'satellite.megacorp.local'; | |
my $client = new Frontier::Client(url => "http://$HOST/rpc/api"); | |
print "Enter RHN username: "; | |
my $username = ReadLine(0); | |
ReadMode('noecho'); | |
print "Enter password: "; | |
my $password = ReadLine(0); | |
print "\n"; | |
ReadMode('normal'); | |
my $session = $client->call('auth.login', $username, $password); | |
my $package_infos = $client->call('packages.search.name', $session, $find_package); | |
my $package_id = 0; | |
my $package_desc; | |
foreach my $this_package_info (@{$package_infos}){ | |
if ($package_id < $this_package_info->{'id'}){ | |
$package_id = $this_package_info->{'id'}; | |
$package_desc = $this_package_info->{'description'}; | |
} | |
} | |
unless ($package_id){ | |
print "No such package found.\n"; | |
exit 1; | |
} | |
print "Found: $package_id - $package_desc\n"; | |
my $providing_channels_info = $client->call('packages.listProvidingChannels', $session, $package_id); | |
my @providing_channels; | |
foreach my $this_channel_info (@{$providing_channels_info}){ | |
push @providing_channels, $this_channel_info->{'label'}; | |
printf "%s\n", $this_channel_info->{'label'}; | |
} | |
print "\n"; | |
print "rhnpush "; | |
foreach (@providing_channels){ | |
printf "-c%s ", $_; | |
} | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment