How to remove/unregister a System from Red Hat Satellite 5.x?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Satellite 5.x

Issue

  • A system needs to be unregistered from Red Hat Satellite 5.x.
  • How to delete system using API on Red Hat Satellite 5.x?
  • How to delete system using CLI (spacecmd) in Red Hat Satellite 5.x?

Resolution

  • Red Hat Satellite-5.x does not provide an option to unregister client.
  • The only option available to remove a client from satellite server is to delete the client's profile from satellite server.
  • To remove clients profile from satellite server perform these steps:
    1. Log in to the Satellite server's web-ui.
    2. Click on the Systems tab in the top navigation bar and then click on the name of the system from the System List which you want to remove from the satellite.
    3. Click the Delete System link in the top-right corner of the page.
    4. Confirm system profile deletion by clicking the Delete System button.
    5. Now go to the client system and execute below command to remove the associated systemid file:
     # rm -rf /etc/sysconfig/rhn/systemid
  • Delete system from Red Hat Satellite Server using API

    • To delete a system from Satellite using spacewalk-api run the below command on satellite server:
    # spacewalk-api --server=localhost --user=admin --password=****  system.deleteSystem %session%  <SYSTEM_ID>
  • For eg:
    # spacewalk-api --server=localhost --user=admin --password=mypassword  system.deleteSystem %session%  100983563
  • Delete system from Red Hat Satellite Server using Command Line Tool (spacecmd)

    • To delete a system from Satellite using spacecmd run the below commands on satellite server:
     # spacecmd
     spacecmd {SSM:1}> system_list
     spacecmd {SSM:1}> system_delete <hostname>
     spacecmd {SSM:1}> clear_caches
     spacecmd {SSM:1}> exit
  • The above command would remove the system from satellite server, but the client system would still have stale information in order to remove the same please run below command on the Client system:
     # rm -rf /etc/sysconfig/rhn/systemid

Diagnostic Steps

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

6 Comments

what the command line equivalent of these process?

Roger,

There isn't any command line tool available for this, but you may use API
to delete system profiles. Refer https://access.redhat.com/site/solutions/513363 for more details.

i run all these commands but still am unable to get my system to register to red hat instead of to my local satellite.

subscription-manager unregister works well to remove from Satellite 6.

There is no command for removing system from Sattelite 5.x but we can use two little hacks to do so:

1) Using spacewalk-cmd: spacecmd system_delete 2) Using sattelite xml-rpc api. https://access.redhat.com/documentation/en-US/Red_Hat_Satellite/5.6/html/API_Overview/sect-system-deleteSystem.html

I'm surprised that Red Hat hasn't made it available out of box.

I have tried first one with success, but second one should work as well.

Hi guys. I made custom script for that issue :). GIST If you don't like following links you have raw script here :)

#!/usr/bin/env python2
'''
Red Hat satellite 5.x script for unregister system(s)
sample usage:
./remove_id.py -i 1001440837 1001440835 -u satadmin -p redhat
'''

import argparse
import xmlrpclib
import socket
from sys import stderr, exit, argv

# FIXME YOUR URL
SAT_URL = ''

def connect(username, password, VERBOSE_LEVEL=0):
    print('Attempting to connect to {0}').format(SAT_URL)

    # Open connection to XML RPC server
    client = xmlrpclib.Server(SAT_URL, verbose=VERBOSE_LEVEL)
    try:
        key = client.auth.login(username, password)
        stderr.write('Login succeeded\n')
    except xmlrpclib.Fault as err:
        stderr.write('Failed Login')
        stderr.write('ERROR code: {0}'.format(err.faultCode))
        stderr.write('Message: {0}'.format(err.faultString))
        exit(1)
    except socket.error as (err, errstr):
        stderr.write('ERROR Code: {0}\tString: {1}\n').format(err, errstr)
        exit(1)

    return (client, key)


# Parsing args
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--user", help='Sat user', required=True)
parser.add_argument("-p", "--password", help='Sat pass', required=True)
parser.add_argument("-id", "--ids", help='System id[s]', required=True, nargs='+',type=int)
args = parser.parse_args(argv[1:])

# Connecting to satellite
client, key = connect(args.user, args.password)

# Removing systems
for id in args.ids:
    try:
        status =  client.system.deleteSystem(key,id)
        if status == 1:
            print 'System with id {0} unregistered successful'.format(id)
    except Exception as e:
        print "There was ERROR with id {0}".format(id)
        print e

client.auth.logout(key)