PDA

View Full Version : Sorted list (by date) of packages in a channel



eblock
16-Jul-2015, 14:12
Hi everyone,

I'm not sure if it is possible, I have a Cloud 5 Compute Node running on SLES12, which I register in SUMA and it gets all available updates. And here is my problem: Is there a way to get a sorted list of these available packages? In the Channel overview I see three columns (Package, Summary and Content Provider), but I can only sort by package name. Then there is the csv export, but there is no (obvious) way to customize the export, the result is similar: ID, name and Provider. When I look into the details of a specific package I can see the date it was last modified. But I can't look into more than 3000 packages, as you can image.
Is there a way to get these details in a list? Maybe I should add that I use SUMA in the web ui, not with the command line.

Thank you very much,
Eugen

kwk
17-Jul-2015, 07:19
You probably have to use the SUSE Manager API (https://www.suse.com/documentation/suse_manager/singlehtml/susemanager_api_doc/susemanager_api_doc.html) to accomplish this.

eblock
17-Jul-2015, 13:03
Thank you, kwk,

I hoped to find an easier way ;-)
But I found it interesting to try and with the help of another thread in this forum and google I wrote a little perl script. If anyone is interested, this worked for me:


#!/usr/bin/perl
use Frontier::Client;
use DateTime;

my $HOST = 'manager.example.com';
my $user = 'username';
my $pass = 'password';
my $channel = 'sles12-updates-x86_64';

my $client = new Frontier::Client(url => "http://$HOST/rpc/api");
my $session = $client->call('auth.login',$user, $pass);

# if you want to list packages greater than a certain date, converted to iso8601-format
my $timestamp = DateTime->new(
year => 2015,
month => 07,
day => 17,
)->iso8601();

# result is an array with all packages greater than $timestamp,
# without $timestamp you get a complete list of all packages
my $result = $client->call('channel.software.listAllPackagesByDate',$ses sion,$channel,$timestamp);

# captions
print "last_modified\tid\tname\n";

# print the required columns
foreach my $list (@$result) {
print $list->{'last_modified'}."\t".$list->{'id'}."\t".$list->{'name'}."\n";
}

$client->call('auth.logout', $session);

I know it's not very pretty, but I got what I wanted ;-)