summaryrefslogtreecommitdiffstats
path: root/cobbler/action_validate.py
diff options
context:
space:
mode:
authorroot <root@mdehaan.rdu.redhat.com>2007-07-27 17:01:00 -0400
committerroot <root@mdehaan.rdu.redhat.com>2007-07-27 17:01:00 -0400
commit1af8a3da4437bbd4bc82498749eb93624b2e741c (patch)
tree12f7c9655e5cafbca5c57d8fccc867eb87bc8f33 /cobbler/action_validate.py
parent26f130cea5926219cb00185ba5ff53fe1c8a8510 (diff)
downloadthird_party-cobbler-1af8a3da4437bbd4bc82498749eb93624b2e741c.tar.gz
third_party-cobbler-1af8a3da4437bbd4bc82498749eb93624b2e741c.tar.xz
third_party-cobbler-1af8a3da4437bbd4bc82498749eb93624b2e741c.zip
Missing file.
Diffstat (limited to 'cobbler/action_validate.py')
-rw-r--r--cobbler/action_validate.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/cobbler/action_validate.py b/cobbler/action_validate.py
new file mode 100644
index 0000000..f898478
--- /dev/null
+++ b/cobbler/action_validate.py
@@ -0,0 +1,72 @@
+"""
+Validates rendered kickstart files.
+
+Copyright 2007, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+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.
+"""
+
+import os
+import re
+import sub_process
+from rhpl.translate import _, N_, textdomain, utf8
+
+class Validate:
+
+ def __init__(self,config):
+ """
+ Constructor
+ """
+ self.config = config
+ self.settings = config.settings()
+
+ def run(self):
+ """
+ Returns None if there are no errors, otherwise returns a list
+ of things to correct prior to running application 'for real'.
+ (The CLI usage is "cobbler check" before "cobbler sync")
+ """
+
+ if not os.path.exists("/usr/bin/ksvalidator"):
+ print _("ksvalidator not installed, please install pykickstart")
+ return False
+
+ 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)):
+ 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)):
+ failed = True
+
+ if failed:
+ print _("*** potential errors detected in kickstarts ***")
+ else:
+ print _("*** all kickstarts seem to be ok ***")
+
+ 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)
+ return False
+ return True
+