[et-mgmt-tools] Cobbler netboot_enable utility

Matt Hyclak hyclak at math.ohiou.edu
Wed May 23 14:51:29 UTC 2007

On Wed, May 23, 2007 at 10:42:49AM -0400, Matt Hyclak enlightened us:
> I just shared this with Michael on IRC and he suggested I posted it to the
> list, so here it is. 
> Running koan on a target machine seemed too cumbersome sometimes, so I wrote
> this little app to more or less flip the netboot_enabled bit on a system, so
> that you could run this utility:
> cobbler_change_netboot.py enable mysystem
> and simply reboot the target machine.
> The next logical step, then, is to have the system phone home when it is
> finished reinstalling to flip the bit back to 0. I've done this in the past
> (on a homegrown system) by having the target wget a webpage which was a
> script that changed the status from 'reinstall' to 'installed'. This could
> also be done via some ssh magic.
> I would also like to add in some sort of trigger ability much like cobbler
> has to do things like 'puppetca --clean hostname' when preparing for a
> reinstall.
> This is a very basic proof of concept of the idea, but to be a good "release
> early, release often" type guy, here it is. 

This time with an attachment...


Matt Hyclak
Department of Mathematics 
Department of Social Work
Ohio University
(740) 593-1263
-------------- next part --------------
#!/usr/bin/env python

from cobbler import api
import getopt, sys

def usage():
	print """
Usage: cobbler_change_netboot.py [-hv] COMMAND SYSTEMNAME

def extended_usage():
	print """
Usage: cobbler_change_netboot.py [-hv] COMMAND SYSTEMNAME

	-h|--help			Print help
	-v|--verbose		Turns on more verbose messages

	enable		Enables netboot for this system (causes reinstall)
	disable		Disables netboot for this system (causes default boot)

def vprint(msg):
		if verbose:
			print msg
	except NameError:

	opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "verbose"])
except getopt.GetoptError:

verbose = 0

for o, a in opts:
	if o in ("-h", "--help"):
	if o in ("-v", "--verbose"):
		verbose = 1

if len(args) != 2:
	command = args[0]
	systemname = args[1]

if command not in ["enable", "disable"]:
elif (command == "enable"):
	netboot = 1
	netboot = 0

shoehorn = api.BootAPI()
systems = shoehorn.systems()

found = systems.find(systemname)

if (found):
	found.netboot_enabled = netboot
	retval = shoehorn.serialize()
	syncval = shoehorn.sync()

# vim:tabstop=4

More information about the et-mgmt-tools mailing list