summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-04-23 13:16:55 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-04-23 13:16:55 -0400
commita3583f38b6bf136a683b14394ee24988a8f206ca (patch)
treeaa31aa0ee5d9a423c745b2def478cc614bdefce1 /cobbler
parent7ca984b22725d19890c60423e5156aaa179809ad (diff)
downloadthird_party-cobbler-a3583f38b6bf136a683b14394ee24988a8f206ca.tar.gz
third_party-cobbler-a3583f38b6bf136a683b14394ee24988a8f206ca.tar.xz
third_party-cobbler-a3583f38b6bf136a683b14394ee24988a8f206ca.zip
validateks now works against all URLs, not just local files
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_validate.py46
-rwxr-xr-xcobbler/cobbler.py2
2 files changed, 30 insertions, 18 deletions
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