2009/2/11 Steven Feltner <[email protected]>:
> I adopted, and now maintain, a database of rhel licenses for hundreds
> servers.  Being a dynamic environment, these servers may live for a few
> days, months or years.  As each server is provisioned, it registers itself
> on RHN using rhnreg_ks.  I have been told that "traditionally", the only way
> to delete a profile from a rhel license is to log into RHN and manage the
> license manually.  Is this truly the case?
>
> I recently ran an audit on server profiles and what we thought we were using
> for licenses.  It turns out that many of our licenses are associated to
> profiles that no longer exist.
>
> Is there a way to perform the opposite of rhnreg_ks to remove a profile from
> a license?  This way, when a server is decommissioned, a separate process
> could delete the profile.
>
> Is there a way for me to delete these profiles after the fact, i.e. to clean
> up my database of now non-existent profiles?

It depends on a few things:

1) Do you know the names of all the profiles that need deleting?
2) How do you feel about Perl?

There is an RHN API you can call with SOAP and do useful things:
https://rhn.redhat.com/rhn/apidoc/

This piece of Perl will delete a profile based on the RHN profile
name. Run it as:

./rhn-delete profilename

I wrote another one that scanned through all our profiles and deleted
anything that hadn't checked in within 6 months - ask me off-list if
that's useful.

--
Sam

-------------BEGIN PERL----------------------
#!/usr/bin/perl -w
use strict;
use Frontier::Client;
use Data::Dumper;
############################################################################
#   Defining an XMLRPC session.                                            #
############################################################################
# Define the host first.  This will be the FQDN of your satellite system.
my $HOST = 'xmlrpc.rhn.redhat.com';
# Now we create the client object that will be used throughout the session.
my $client = new Frontier::Client(url => "http://$HOST/rpc/api";);
# Next, we execute a login call, which returns a session identifier that will
# be passed in all subsequent calls.  The syntax of this call is described at:
#
#   http://$HOST/rpc/api/auth/login/
my $session = $client->call('auth.login', 'yourlogin', 'yourpassword');
############################################################################
#   System calls.                                                          #
############################################################################
my $systems = $client->call('system.list_user_systems', $session);
for my $system (@$systems) {
  if (Dumper($system) =~ /$ARGV[0]/) {
    print "Deleting system ID: $system->{'id'}\n";
    my $result = $client->call('system.delete_systems', $session,
$system->{'id'});
  }
}
-------------------END PERL----------------------------------------

_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list

Reply via email to