summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-08-18 17:40:37 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-08-18 17:40:37 -0400
commit7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb (patch)
tree05431684d09bb86e6128a55ec88b4388379fabd8 /cobbler
parentb0ad5cf706d1040b88726c28741b888b8d04e22d (diff)
downloadcobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.tar.gz
cobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.tar.xz
cobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.zip
Use pxesystem and pxeprofile templates correctly
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/kickgen.py3
-rw-r--r--cobbler/pxegen.py14
-rw-r--r--cobbler/templar.py8
-rw-r--r--cobbler/utils.py26
4 files changed, 32 insertions, 19 deletions
diff --git a/cobbler/kickgen.py b/cobbler/kickgen.py
index 385a0641..2c35545a 100644
--- a/cobbler/kickgen.py
+++ b/cobbler/kickgen.py
@@ -90,7 +90,8 @@ class KickGen:
return data
except:
utils.log_exc(self.api.logger)
- return _("# Error while rendering kickstart file, see /var/log/cobbler/cobbler.log for details")
+ raise
+
elif kickstart_path is not None and not os.path.exists(kickstart_path):
if kickstart_path.find("http://") == -1 and kickstart_path.find("ftp://") == -1 and kickstart_path.find("nfs:") == -1:
return "# Error, cannot find %s" % kickstart_path
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py
index 9eebd095..b634512f 100644
--- a/cobbler/pxegen.py
+++ b/cobbler/pxegen.py
@@ -378,14 +378,14 @@ class PXEGen:
initrd_path = None
# ---
# choose a template
- if arch in [ "standard", "x86", "i386", "i386", "x86_64" ] or (arch is None and system is None):
- template = "/etc/cobbler/pxeprofile.template"
- elif arch == "s390x":
- template = "/etc/cobbler/pxesystem_s390x.template"
- elif arch == "ia64":
- template = "/etc/cobbler/pxesystem_ia64.template"
- else:
+ if system:
template = "/etc/cobbler/pxesystem.template"
+ if arch == "s390x":
+ template = "/etc/cobbler/pxesystem_s390x.template"
+ elif arch == "ia64":
+ template = "/etc/cobbler/pxesystem_ia64.template"
+ else:
+ template = "/etc/cobbler/pxeprofile.template"
# now build the kernel command line
diff --git a/cobbler/templar.py b/cobbler/templar.py
index 40d44a85..9a936447 100644
--- a/cobbler/templar.py
+++ b/cobbler/templar.py
@@ -79,16 +79,14 @@ class Templar:
raw_data = newdata
# tell Cheetah not to blow up if it can't find a symbol for something
- raw_data = "#errorCatcher Echo\n" + raw_data
+ #raw_data = "#errorCatcher Echo\n" + raw_data
# now do full templating scan, where we will also templatify the snippet insertions
t = Template(source=raw_data, searchList=[search_table])
try:
data_out = str(t)
- except:
- print "There appears to be an formatting error in the template file."
- print "For completeness, the traceback from Cheetah has been included below."
- raise
+ except Exception, e:
+ return utils.cheetah_exc(e)
# now apply some magic post-filtering that is used by cobbler import and some
# other places, but doesn't use Cheetah. Forcing folks to double escape
diff --git a/cobbler/utils.py b/cobbler/utils.py
index d55cf149..be1c416e 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -85,19 +85,33 @@ def log_exc(logger):
logger.info("Exception occured: %s" % t )
logger.info("Exception value: %s" % v)
logger.info("Exception Info:\n%s" % string.join(traceback.format_list(traceback.extract_tb(tb))))
+
-def print_exc(exc,full=False):
+def get_exc(exc,full=True):
(t, v, tb) = sys.exc_info()
+ buf = ""
try:
getattr(exc, "from_cobbler")
- print >> sys.stderr, str(exc)[1:-1]
+ buf = str(exc)[1:-1] + "\n"
except:
- print >> sys.stderr, t
- print >> sys.stderr, v
+ buf = buf + "%s" % exc.message
+ buf = sys.stderr, t
+ buf = "%s\n%s" % (buf,v)
if full:
- print >> sys.stderr, string.join(traceback.format_list(traceback.extract_tb(tb)))
- return 1
+ buf = buf + "\n" + "\n".join(traceback.format_list(traceback.extract_tb(tb)))
+ return buf
+def print_exc(exc,full=False):
+ buf = get_exc(exc)
+ sys.stderr.write(buf+"\n")
+ return buf
+
+def cheetah_exc(exc,full=False):
+ lines = get_exc(exc).split("\n")
+ buf = ""
+ for l in lines:
+ buf = buf + "# %s\n" % l
+ return buf
def trace_me():
x = traceback.extract_stack()