diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | cobbler/action_validate.py | 46 | ||||
-rwxr-xr-x | cobbler/cobbler.py | 2 |
3 files changed, 31 insertions, 18 deletions
@@ -31,6 +31,7 @@ Cobbler CHANGELOG - optional MAC registration is now built-in to requesting kickstarts - legacy static file generation from /var/www/cobbler removed - implement "cobbler ___ dumpvars --name=X" feature to show template vars +- validateks now works against all URLs as opposed to rendered local files - ??? - 0.8.3 - Make createrepo get run for local cobbler reposync invocations as needed diff --git a/cobbler/action_validate.py b/cobbler/action_validate.py index 8ede60c..44f3a9a 100644 --- a/cobbler/action_validate.py +++ b/cobbler/action_validate.py @@ -16,6 +16,7 @@ import os import re import sub_process from utils import _ +import utils class Validate: @@ -39,16 +40,10 @@ class Validate: failed = False for x in self.config.profiles(): - distro = x.get_conceptual_parent() - if distro.breed != "redhat": - continue - if not self.checkfile(x.name, "%s/kickstarts/%s/ks.cfg" % (self.settings.webdir, x.name)): + if not self.checkfile(x, True): failed = True for x in self.config.systems(): - distro = x.get_conceptual_parent().get_conceptual_parent() - if distro.breed != "redhat": - continue - if not self.checkfile(x.name, "%s/kickstarts_sys/%s/ks.cfg" % (self.settings.webdir, x.name)): + if not self.checkfile(x, False): failed = True if failed: @@ -58,15 +53,32 @@ class Validate: return failed - def checkfile(self,name,file): - # print _("scanning rendered kickstart template: %s" % file) - if not os.path.exists(file): - print _("kickstart file does not exist for: %s") % name - return False - rc = os.system("/usr/bin/ksvalidator %s" % file) - if not rc == 0: - print _("ksvalidator detected a possible problem for: %s") % name - print _(" rendered kickstart template at: %s" % file) + def checkfile(self,obj,is_profile): + blended = utils.blender(self.config.api, False, obj) + ks = blended["kickstart"] + breed = blended["breed"] + if breed != "redhat": + print "%s has a breed of %s, skipping" % (obj.name, breed) + return True + if ks is None or ks == "": + print "%s has no kickstart, skipping" % obj.name + return True + + server = blended["server"] + if not ks.startswith("/"): + url = self.kickstart + elif is_profile: + url = "http://%s/cblr/svc/?op=ks;profile=%s" % (server,obj.name) + else: + url = "http://%s/cblr/svc/?op=ks;system=%s" % (server,obj.name) + + print "----------------------------" + print "checking url: %s" % url + + + rc = os.system("/usr/bin/ksvalidator \"%s\"" % url) + if rc != 0: return False + return True diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index 5cd0c2e..c164244 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -56,7 +56,7 @@ def main(): except SystemExit: pass # probably exited from optparse, nothing extra to print except Exception, exc2: - if str(type(exc2)).find("CX") != -1: + if str(type(exc2)).find("CX") == -1: traceback.print_exc() else: print str(exc2)[1:-1] # remove framing air quotes |