Update Satellite Client Profile (Description, Location, Etc) Via Command Line
I've created a script that is ran after a system is installed. This script prompts the admin if the machine needs to be added to the domain, Satellite server, and so on.
I want to be able to prompt the user for a location. For instance "What building and room is this machine located?" When a client is registered with Red Hat Satellite server, it seems to upload its profile (system architecture and all) but with the current location info blank. I'd like to modify this profile in this script to add the location. This configuration would occur after the system has been registered with the local Satellite server.
Unfortunately, I do not know the command or location where I can do this. I've tried editing the /etc/sysconfig/rhn/systemid file and running rhn_check, but this does not seem to work. I've also tried using /usr/sbin/rhn-profile-sync but this doesn't change anything either.
Any thoughts on how to update a Satellite client's profile via command line, mostly for the location field?
Responses
Hi Jonathan,
To set location details to system profile you can use API - system.setDetails
setDetails
string sessionKey
int serverId - ID of server to lookup details for.
struct - server details
string "profile_name" - System's profile name
string "base_entitlement" - System's base entitlement label. (enterprise_entitled or sw_mgr_entitled)
boolean "auto_errata_update" - True if system has auto errata updates enabled
string "description" - System description
string "address1" - System's address line 1.
string "address2" - System's address line 2.
string "city"
string "state"
string "country"
string "building"
string "room"
string "rack"
Either you can use python script or you can use "spacewalk-api" command to call system.setDetails API.
Regards,
Ashish
Hi Jonathan,
You can find sample API's on your Red Hat Satellite server by accessing the link below:
https://satellite.example.com/rhn/apidoc/scripts.jsp
Here is the sample python script to execute system.setDetails API :
#!/usr/bin/python
import xmlrpclib
server_url='https://satellite.example.com/rpc/api'
xmlrpclib.Server(server_url)
sc = xmlrpclib.Server(server_url)
sk = sc.auth.login('admin', 'secret')
options = {'profile_name': 'test-system.example.com', 'description': 'Custom Description set via API'}
list = sc.system.setDetails(sk, 1000038967, options)
print list
Here in options you can set available variables listed in my earlier update.
Note: Update server_url, username/password, systemid with appropriate values.
Hope this helps.
Regards,
Ashish
Hi Jonathan,
Do you use kickstart to register your host? (I.e. is it registered via the kickstart profile?). Or... do you use bootstrap.sh?
Either way - If you have not used either method for registration, I would recommend creating a "dummy" kickstart profile (which Satellite will add all the registration bits in the profile) and I would also create a bootstrap file. Even if you end up using neither method, the examples in those two files might shed some light on possible ways to interact with Satellite (in addition to what Ashish has provided).
I use bootstrap.sh myself as I feel it provides the most flexibility in my environment. I, like you, have specific needs to provide options during the bootstrap (config channels based on environment or location). So, I have a few "menu options" that will timeout and register using default values.
Also - I thought rhn-profile-sync was a valid response to your original question ;-) So, I am curious what the right answer(s) is.
Instead of input using raw_input to read room number , building no, rack number solves the issue. :)
#!/usr/bin/python
import xmlrpclib
import getpass
server_url = 'http://myurl/rpc/api'
xmlrpclib.Server(server_url)
sc = xmlrpclib.Server(server_url)
systemId = ########
options = {'building': raw_input("Building number: "), 'room': raw_input("Room number: "), 'rack': raw_input("Rack number: ")}
uname = raw_input("Enter your Satellite username: ")
pw = getpass.getpass()
sk = sc.auth.login(uname, pw)
list = sc.system.setDetails(sk, systemId, options)
print list
James/Jonathan,
We can not change systemid file on system, any changes in the systemid file will create problem for system to authenticate with RHN. The rhn-profile-sync command will update system hostname/IP/Package Profile/hardware details .. etc. Using this we can not set building/room/rack number.
Regards,
Ashish
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
