[Spacewalk-list] ? How to list taskomatic repository synch schedule
Boyd, Robert
Robert.Boyd at peoplefluent.com
Tue Apr 16 20:20:29 UTC 2013
Thanks to Tomas Lestach I was able to tinker around with the taskomatic information and generated this small script. I suggest we put this script or a variant of it on the website as an example and/or a link to it under the Taskomatic pages.
Also, if there’s a more clever way to cross the channel names and taskomatic schedules I’d be happy to see it. I’m a rank novice when it comes to python programming.
#!/usr/bin/python
#
# taskomatic_repo-sync_list.py
#
# Generate a list of channels and taskomatic schedule for repository sync jobs.
# The list is sorted alphabetically by channel name
#
# The schedules are listed in crontab format
# Channel names and schedules are associated to an internal channel id number.
# In some lists these ids are returned as numeric values and others come back as text strings.
# In order to match them up between the channel names and schedules I found it necessary to convert
# the ids returned from the taskomatic repo-sync list from text to integer.
#
#
import xmlrpclib, struct
from array import *
#
# Replace the userid and password with your information before running this
#
SATELLITE_URL = "http://localhost/rpc/api"
SATELLITE_LOGIN = "YourSpacewalkUserid"
SATELLITE_PASSWORD = "YourSpacewalkPassword"
#
# Connect and login to the spacewalk server
#
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key_session = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
#
# Get a list of all channels
#
channels = client.channel.listAllChannels(key_session)
chan_name = {}
chan_sched = {}
#
# Build an array of channel names indexed by internal channel id number
#
for c in channels:
chan_name[ c['id'] ] = c['label']
chan_sched[ c['id'] ] = ''
#
# Get a list of all the Taskomatic repo-sync jobs
#
schedules = client.taskomatic.org.listActiveSchedulesByBunch(key_session, 'repo-sync-bunch')
#
# Build an array of schedules indexed by internal channel id number
#
for s in schedules:
chan_sched[int(s['data_map']['channel_id'])] = s['cron_expr']
# Print headers
csched_fmt = '{0:>5s} {1:<40s} {2:<20s}'
print csched_fmt.format('key', 'Channel Name', 'Update Schedule')
print csched_fmt.format('-----', '---------------------', '---------------')
#
# Sort and print the channel names and associated repo-sync schedule (if any)
#
for key, value in sorted(chan_name.iteritems(), key=lambda (k,v): (v,k)):
print csched_fmt.format(str(key), value, chan_sched[int(key)])
# Logout from spacewalk
client.auth.logout(key_session)
Here’s the output it generates on my spacewalk master server:
key Channel Name Update Schedule
----- --------------------- ---------------
151 centos-i386-server-4
152 centos-x86_64-server-4
121 centos5-i386
122 centos5-i386-addons
123 centos5-i386-centosplus
124 centos5-i386-contrib
125 centos5-i386-extras
126 centos5-i386-fasttrack
127 centos5-i386-updates
128 centos5-x86_64
129 centos5-x86_64-addons
130 centos5-x86_64-centosplus
131 centos5-x86_64-contrib
132 centos5-x86_64-extras
133 centos5-x86_64-fasttrack
134 centos5-x86_64-updates
120 cluster-5-x86_64
114 epel-5-i386 0 0 13 ? * 1
115 epel-5-x86_64
116 epel-6-x86_64 0 0 13 ? * 7
105 rhel-i386-server-4 0 30 5 ? * *
106 rhel-i386-server-5 0 3 21 ? * *
113 rhel-server-5-supplementary-i386 0 30 0 ? * *
108 rhel-server-6-supplementary-x86_64 0 0 19 ? * 2
104 rhel-x86_64-server-4 0 45 4 ? * *
102 rhel-x86_64-server-5 0 30 3 ? * *
103 rhel-x86_64-server-6 0 30 2 ? * *
107 rhel-x86_64-server-optional-6 0 25 0 ? * *
109 rhel-x86_64-server-supplementary-5 0 5 1 ? * *
112 spacewalk-5-i386 0 30 20 ? * *
111 spacewalk-5-x86_64 0 15 20 ? * *
110 spacewalk-6-x86_64 0 0 20 ? * *
118 spacewalk-client-5-i386
117 spacewalk-client-5-x86_64
119 spacewalk-client-6-x86_64
157 vmware-tools-4-i386
156 vmware-tools-4-x86_64
155 vmware-tools-5-i386
154 vmware-tools-5-x86_64
153 vmware-tools-6-x86_64
Robert Boyd
Senior Systems Engineer | Peoplefluent
p. 919-645-2972 | c. 919-306-4681
e. Robert.Boyd at peoplefluent.com<mailto:michael.dileonardo at peoplefluent.com>
Visit: www.peoplefluent.com<http://www.peoplefluent.com/> | Read: Peoplefluent Blog<http://peoplefluent.com/resources/peoplefluent-blog>
Follow: @peoplefluent<http://twitter.com/peoplefluent> | Download: iPad App<http://itunes.apple.com/us/app/peoplefluent/id474251804?mt=8>
[cid:image003.png at 01CE3ABC.500C7760]
[cid:image004.png at 01CE3ABC.500C7760]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20130416/0dd42c48/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 8604 bytes
Desc: image003.png
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20130416/0dd42c48/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 22864 bytes
Desc: image004.png
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20130416/0dd42c48/attachment-0001.png>
More information about the Spacewalk-list
mailing list