Red Hat Bugzilla – Bug 809905
RFE: Enhancement for kickstart_addscript command to allow for setting of cobbler templating option via command line
Last modified: 2012-11-01 12:20:06 EDT
Description of problem:
While writing some scripts that use spacecmd to query data to do backups and recovery of kickstart profiles. From these backups I have found that during the kickstart_addscript command one can set all of the options with the exception of the Template option which had to be done manually after the kickstart was imported and the scripts added using the GUI. After looking at the http://host/rpc/api documentation I found that the template option is not mentioned at all in kickstart.profile.addScript but while query the system call using api.getApiNamespaceCallList for the kickstart.profile.addScript
Once I was able to test on my system that I could set the template checkmark it displays on the web GUI I was able to do so by adding the code outlined at the end of this report
Version-Release number of selected component (if applicable):
- Tested on spacecmd-1.2.2-1.el5
- Also tested on EL6 version
- Also tested against nightly git build
Use the following patch to add the enhancement
diff -crB a/lib/kickstart.py b/lib/kickstart.py
*** a/lib/kickstart.py 2012-04-03 16:34:13.000000000 -0400
--- b/lib/kickstart.py 2012-04-04 11:56:13.000000000 -0400
*** 1638,1643 ****
--- 1638,1644 ----
options = [ Option('-p', '--profile', action='store'),
Option('-e', '--execution-time', action='store'),
Option('-c', '--chroot', action='store_true'),
+ Option('-t', '--template', action='store_true'),
Option('-i', '--interpreter', action='store'),
Option('-f', '--file', action='store') ]
*** 1668,1673 ****
--- 1669,1679 ----
options.chroot = True
+ if re.match('n', options.template, re.I):
+ options.template = False
+ options.template = True
if re.match('pre', options.execution_time, re.I):
options.execution_time = 'pre'
*** 1698,1703 ****
--- 1704,1710 ----
print 'Profile Name: %s' % options.profile
print 'Execution Time: %s' % options.execution_time
print 'Chroot: %s' % options.chroot
+ print 'Template: %s' % options.template
print 'Interpreter: %s' % options.interpreter
*** 1709,1715 ****
--- 1716,1723 ----
Steps to Reproduce:
1. Apply the patch
2. Test by adding a script using snippets
3. Answer Y on the addscript questionaire, or use -t or --template on the command line to pass the setting to enable templating
4. Check on the GUI to assure it is checked after its added
5. Optional. Provision a system using the kickstart with said template script and assure its working as expected.
Capability to set the template boolean option from the command line using the -t or --template or it will prompt you when its blank and you are at the spacecmd prompt much like other prompts
When used on the command line to add the script with the template option it will enable the setting to use the script being added as a template.
This is an enhancement fix that will allow for people to write a script to set the template option on the script being added to the kickstart without having to do it from the Web GUI.
Forwarded to upstream.
Hey Jose, this looks great, thanks for the patch!
And as a side note RE template option not being mentioned in the API doc, it actually is there, but there are two versions of the addScript method and the template option is available in the second form. So you have to scroll a little bit further down the page, but it should be there. :)
Committed to Spacewalk master as b9a232dd1f79ab46e23d0654189bf4fd0009f5fb.
While we're at it, there's also:
< options.chroot = True
> options.chroot = False
Without that the "-c" switch can not e turned off.
(In reply to comment #3)
> While we're at it, there's also:
> < options.chroot = True
> > options.chroot = False
> Without that the "-c" switch can not e turned off.
Good point. Committed to Spacewalk master: 03c611ea7710bd606d46d44a432ae67c3af1b875
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18