summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG7
-rw-r--r--cobbler.spec6
-rw-r--r--cobbler/action_sync.py42
3 files changed, 39 insertions, 16 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 81a7158..42745ba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,11 @@
Cobbler CHANGELOG
(all entries mdehaan@redhat.com unless noted otherwise)
-* Mon Jan 28 2007 - 0.4.0
-- Placeholder
+* Tue Feb 12 2007 - 0.4.0
+- Added feature to minimize the need to run "cobbler sync" for add commands
+ Now only need to run sync when files change behind the scenes or when
+ manually editing YAML
+- Moving back to Cheetah for templating (old files still backwards compatible)
* Mon Jan 28 2007 - 0.3.9
- Make init scripts correspond with FC-E guidelines
diff --git a/cobbler.spec b/cobbler.spec
index 5f570ad..450ef3d 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -13,6 +13,7 @@ Requires: tftp-server
Requires: python-devel
Requires: createrepo
Requires: mod_python
+Requires: python-cheetah
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
@@ -91,8 +92,9 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%changelog
-* Mon Jan 28 2007 Michael DeHaan <mdehaan@redhat.com> - 0.4.0-1
-- Placeholder
+* Tue Feb 12 2007 Michael DeHaan <mdehaan@redhat.com> - 0.4.0-1
+- Moving back to Cheetah for templating
+- Upstream changes (see CHANGELOG)
* Mon Jan 28 2007 Michael DeHaan <mdehaan@redhat.com> - 0.3.9-1
- Changed init script pre/post code to match FC-E guidelines/example
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index c4766f5..5a6b6d4 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -29,6 +29,7 @@ import errno
import item_profile
+from Cheetah.Template import Template
class BootSync:
"""
@@ -153,11 +154,14 @@ class BootSync:
"date" : time.asctime(time.gmtime()),
"next_server" : self.settings.next_server
}
- for x in metadata.keys():
- template_data = template_data.replace("$%s" % x, metadata[x])
+ self.apply_template(template_data, metadata, f1)
self.tee(f1,template_data)
self.close_file(f1)
+ def templatify(self, data, metadata, outfile):
+ for x in metadata.keys():
+ template_data = template_data.replace("$%s" % x, metadata[x])
+
def configure_httpd(self):
"""
Create a config file to Apache that will allow access to the
@@ -361,7 +365,9 @@ class BootSync:
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)
- self.apply_template(kickstart_path, meta, dest)
+ kfile = open(kickstart_path)
+ self.apply_template(kfile, meta, dest)
+ kfile.close()
except:
traceback.print_exc() # leave this in, for now...
msg = "err_kickstart2"
@@ -438,25 +444,37 @@ class BootSync:
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)
- self.apply_template(kickstart_path, meta, dest)
+ kfile = open(kickstart_path)
+ self.apply_template(kfile, meta, dest)
+ kfile.close()
except:
msg = "err_kickstart2"
raise cexceptions.CobblerException(msg,s.kickstart,dest)
- def apply_template(self, kickstart_input, metadata, out_path):
+ def apply_template(self, data_input, metadata, out_path):
"""
Take filesystem file kickstart_input, apply metadata using
Cheetah and save as out_path.
"""
- fd = open(kickstart_input)
- data = fd.read()
- fd.close()
- for x in metadata.keys():
- if x != "":
- data = data.replace("TEMPLATE::%s" % x, metadata[x])
+ if type(data_input) != "str":
+ data = data_input.read()
+ else:
+ data = data_input
+
+ # backward support for Cobbler's legacy (and slightly more readable)
+ # template syntax.
+ data.replace("TEMPLATE::","$")
+
+ data = "#errorCatcher Echo\n" + data
+
+ t = Template(source=data, searchList=metadata)
+ data_out = str(t)
+ #for x in metadata.keys():
+ # if x != "":
+ # data = data.replace("TEMPLATE::%s" % x, metadata[x])
self.mkdir(os.path.basename(out_path))
fd = open(out_path, "w+")
- fd.write(data)
+ fd.write(data_out)
fd.close()
def build_trees(self):