[Spacewalk-list] Set Custom Info from the cmd line

Kobus Bensch Kobus.Bensch at the-logic-group.com
Fri Sep 2 13:22:08 UTC 2011


This Is great to start with , thank you

The Logic Group Enterprises Limited. Logic House, Waterfront Business Park, Fleet Road, Fleet,   Hampshire, GU51 3SB, United Kingdom. Registered in England. Registered No. 2609323



The information in this email and any attachments are confidential and may be legally privileged and protected by law. It is for the intended recipient only. If you are not the intended recipient you may not use, disclose, copy, distribute, print or rely on the content of this email or its attachments. If this email has been received by you in error please advise the sender and delete the email from your computer.

-----Original Message-----
From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-bounces at redhat.com] On Behalf Of Brian Collins
Sent: 02 September 2011 14:07
To: spacewalk-list at redhat.com
Subject: Re: [Spacewalk-list] Set Custom Info from the cmd line

File attached.  I have simplified it greatly from what I use, because I
don't know how familiar you are with Python and just wanted to pass
along something easy to use.
Here's how it works:
-Logs in to Satellite server.  Inside the program, you need to change
"username" and "password" to those of a user with enough permission to
change custom values.  You may also import the getpass() function to ask
for the password (which is what I do).  Also, change
"satellite.example.com" to the FQDN of your Spacewalk server.
-Assumes the first argument is the system ID to which you want to upload
this data
-Assumes the second argument is the field name
-Assume the third argument is the value you want to match with the field
name
(you could use Python's OptionParser [or argparse for 2.7 and newer] to
process command line options so that you aren't depending on the order
in which things are entered, but I just wanted to give you a short
example)
-Calls the set_CustomValues() method to upload the data

Not knowing your level of comfort with Python, I don't want to overwhelm
you, but there are things that can be done to make this more robust.
-Instead of a system ID (who has those memorized, right?), you could
pass a hostname, and have the program lookup the system ID by the
hostname.
-Keep one text file for each system, and have the program  parse through
the file to upload multiple values per run.
-Even further, make the file name be the same as the system's hostname
(i.e. webserver.txt), then have Python cut out the ".txt" and lookup the
system ID using the host name.
All those things are what we do, but I wanted to give you a basic
example first.  I can pass on the more complicated one later.




> -----Original Message-----
> From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-
> bounces at redhat.com] On Behalf Of Kobus Bensch
> Sent: Friday, September 02, 2011 7:49 AM
> To: spacewalk-list at redhat.com
> Subject: Re: [Spacewalk-list] Set Custom Info from the cmd line
>
> That would be very helpful and kind.
>
> Thank you
>
> The Logic Group Enterprises Limited. Logic House, Waterfront Business
Park,
> Fleet Road, Fleet,   Hampshire, GU51 3SB, United Kingdom. Registered
in
> England. Registered No. 2609323
>
>
>
> The information in this email and any attachments are confidential and
may
> be legally privileged and protected by law. It is for the intended
recipient
> only. If you are not the intended recipient you may not use, disclose,
copy,
> distribute, print or rely on the content of this email or its
attachments. If this
> email has been received by you in error please advise the sender and
delete
> the email from your computer.
>
> -----Original Message-----
> From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-
> bounces at redhat.com] On Behalf Of Brian Collins
> Sent: 02 September 2011 12:39
> To: spacewalk-list at redhat.com
> Subject: Re: [Spacewalk-list] Set Custom Info from the cmd line
>
> > Hi everyone
> >
> > Is it possible to set a servers custom info on the command line?
> >
>
> Yes. We do this in the commercial product (RHN Satellite) using Python
to
> make API calls.  I can post some sample code if you'd like.
>
>
> Brian Collins, RHCE
> Sr. Systems Engineer
> Southeastern Data Cooperative
> brianc at sedata.com
>
>
>
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list
>
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list




More information about the Spacewalk-list mailing list