diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rw-r--r-- | cobbler.spec | 1 | ||||
-rw-r--r-- | cobbler/action_sync.py | 19 | ||||
-rw-r--r-- | cobbler/cobblerd.py | 22 | ||||
-rw-r--r-- | cobbler/settings.py | 3 | ||||
-rw-r--r-- | docs/cobbler.pod | 10 | ||||
-rwxr-xr-x | scripts/nopxe.cgi | 80 | ||||
-rw-r--r-- | setup.py | 2 |
9 files changed, 130 insertions, 9 deletions
@@ -7,6 +7,7 @@ Cobbler CHANGELOG - Added -v/--version - Added SNIPPET::foo capability to pull /var/lib/cobbler/snippets/foo into templates (anywhere) - Import can now take an --available-as=nfs://server:/mount/point to do cobbler import without mirroring +- Feature to enable "pxe_just_once" for boot loop prevention * Fri Jul 20 2007 - 0.5.1 - Added logging for cobblerd -- /var/log/cobbler/cobblerd.log diff --git a/MANIFEST.in b/MANIFEST.in index efc0bf2..a4662aa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,6 +12,7 @@ include COPYING AUTHORS README CHANGELOG NEWS include scripts/watcher.py include scripts/cobblerd include scripts/findks.cgi +include scripts/nopxe.cgi include snippets/* recursive-include po *.pot recursive-include po *.po diff --git a/cobbler.spec b/cobbler.spec index 56add4b..55e2b98 100644 --- a/cobbler.spec +++ b/cobbler.spec @@ -71,6 +71,7 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT %files %defattr(2744,apache,apache) /var/www/cgi-bin/findks.cgi +/var/www/cgi-bin/nopxe.cgi %dir /var/log/cobbler %dir /var/log/cobbler/kicklog %dir /var/www/cobbler/ diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index 9f45fb0..bc587be 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -338,7 +338,7 @@ class BootSync: meta.update(ksmeta) # make available at top level meta["yum_repo_stanza"] = self.generate_repo_stanza(g) meta["yum_config_stanza"] = self.generate_config_stanza(g) - meta["kickstart_done"] = self.generate_kickstart_signal(g, is_system=False) + meta["kickstart_done"] = self.generate_kickstart_signal(g, None) meta["kernel_options"] = utils.hash_to_string(meta["kernel_options"]) kfile = open(kickstart_path) self.apply_template(kfile, meta, dest) @@ -348,12 +348,17 @@ class BootSync: msg = "err_kickstart2" raise CX(_("Error copying kickstart file %(src)s to %(dest)s") % { "src" : kickstart_path, "dest" : dest }) - def generate_kickstart_signal(self, obj, is_system=False): - pattern = "wget http://%s/cblr/watcher.py?%s_%s=%s -b" - if is_system: - return pattern % (self.settings.server, "system", "done", obj.name) + def generate_kickstart_signal(self, profile, system=None): + pattern1 = "wget http://%s/cblr/watcher.py?%s_%s=%s -b" + pattern2 = "wget http://%s/cgi-bin/nopxe.cgi?system=%s -b" + buf = "" + if system is not None: + buf = buf + pattern1 % (self.settings.server, "system", "done", system.name) + if str(self.settings.pxe_just_once).upper() in [ "1", "Y", "YES", "TRUE" ]: + buf = buf + "\n" + pattern2 % (self.settings.server, system.name) else: - return pattern % (self.settings.server, "profile", "done", obj.name) + buf = buf + pattern1 % (self.settings.server, "profile", "done", profile.name) + return buf def generate_repo_stanza(self, profile): # returns the line of repo additions (Anaconda supports in FC-6 and later) that adds @@ -441,7 +446,7 @@ class BootSync: meta.update(ksmeta) # make available at top level meta["yum_repo_stanza"] = self.generate_repo_stanza(profile) meta["yum_config_stanza"] = self.generate_config_stanza(profile) - meta["kickstart_done"] = self.generate_kickstart_signal(profile, is_system=True) + meta["kickstart_done"] = self.generate_kickstart_signal(profile, s) meta["kernel_options"] = utils.hash_to_string(meta["kernel_options"]) kfile = open(kickstart_path) self.apply_template(kfile, meta, dest) diff --git a/cobbler/cobblerd.py b/cobbler/cobblerd.py index c796567..54294cb 100644 --- a/cobbler/cobblerd.py +++ b/cobbler/cobblerd.py @@ -104,6 +104,28 @@ class CobblerXMLRPCInterface: def __sorter(self,a,b): return cmp(a["name"],b["name"]) + def get_settings(self): + self.api.clear() + self.api.deserialize() + data = self.api.settings().to_datastruct() + return self.fix_none(data) + + def disable_netboot(self,name): + # used by nopxe.cgi + self.api.clear() + self.api.deserialize() + if not self.api.settings().pxe_just_once: + # feature disabled! + return False + systems = self.api.systems() + obj = systems.find(name) + if obj == None: + # system not found! + return False + obj.set_netboot_enabled(0) + systems.add(obj,with_copy=True) + return True + def __get_all(self,collection): self.api.clear() self.api.deserialize() diff --git a/cobbler/settings.py b/cobbler/settings.py index ac89715..d2e4b39 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -48,7 +48,8 @@ DEFAULTS = { "xmlrpc_port" : 25151, "minimize_syncs" : 1, "yum_core_mirror_from_server" : 0, - "default_virt_type" : "auto" + "default_virt_type" : "auto", + "pxe_just_once" : 0 } diff --git a/docs/cobbler.pod b/docs/cobbler.pod index ebcfc36..382a2c2 100644 --- a/docs/cobbler.pod +++ b/docs/cobbler.pod @@ -620,6 +620,16 @@ outside world. If this feature is desirable, it can be turned on by setting yum to 1 in /var/lib/cobbler/settings (and rerunning "cobbler sync"). You should not enable this feature if machines are provisioned on a different VLAN/network than production. +=head2 PXE BOOT LOOP PREVENTION + +If you have your machines set to PXE first in the boot order (ahead of hard drives), change +the "pxe_just_once" flag in /var/lib/cobbler/settings to 1. This will set the machines +to not PXE on successive boots once they complete one install. + +To re-enable PXE for a specific system, run the following command: + +B<cobbler system edit --name=name --netboot-enabled=1> + =head2 KICKSTART TRACKING Cobbler knows how to keep track of the status of kickstarting machines. diff --git a/scripts/nopxe.cgi b/scripts/nopxe.cgi new file mode 100755 index 0000000..e90e886 --- /dev/null +++ b/scripts/nopxe.cgi @@ -0,0 +1,80 @@ +#!/usr/bin/env python + +# This software may be freely redistributed under the terms of the GNU +# general public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This script disables the netboot flag for a given +# system if (and only if) pxe_just_once is enabled in settings. +# It must not be able to do anything else for security +# reasons. +# +# +# (C) Red Hat, 2007 +# Michael DeHaan <mdehaan@redhat.com> +# + +import cgi +import cgitb +import time +import os +import sys +import socket +import xmlrpclib +from cobbler import sub_process as sub_process + +COBBLER_BASE = "/var/www/cobbler" +XMLRPC_SERVER = "http://127.0.0.1:25151" + +#---------------------------------------------------------------------- + +class ServerProxy(xmlrpclib.ServerProxy): + + def __init__(self, url=None): + xmlrpclib.ServerProxy.__init__(self, url, allow_none=True) + +#---------------------------------------------------------------------- + +def parse_query(): + """ + Read arguments from query string. + """ + + form = cgi.parse() + + if form.has_key("system"): + return form["system"][0] + return 0 + +def disable(name): + """ + Determine if this feature is enabled. + """ + + #try: + xmlrpc_server = ServerProxy(XMLRPC_SERVER) + print xmlrpc_server.disable_netboot(name) + #except: + # print "# could not contact cobblerd at %s" % XMLRPC_SERVER + # sys.exit(1) + + return True + +#---------------------------------------------------------------------- + +def header(): + print "Content-type: text/plain" + print + +#---------------------------------------------------------------------- + +if __name__ == "__main__": + cgitb.enable(format='text') + header() + name = parse_query() + disable(name) + + @@ -50,7 +50,7 @@ if __name__ == "__main__": ], scripts = ["scripts/cobbler", "scripts/cobblerd"], data_files = [ - (cgipath, ['scripts/findks.cgi']), + (cgipath, ['scripts/findks.cgi', 'scripts/nopxe.cgi']), (rotpath, ['config/cobblerd_rotate']), (wwwconf, ['config/cobbler.conf']), (cobpath, ['loaders/elilo-3.6-ia64.efi']), |