diff options
Diffstat (limited to 'cobbler/pxegen.py')
-rw-r--r-- | cobbler/pxegen.py | 156 |
1 files changed, 6 insertions, 150 deletions
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py index 7ff07808..0dea5f13 100644 --- a/cobbler/pxegen.py +++ b/cobbler/pxegen.py @@ -177,14 +177,14 @@ class PXEGen: return True def generate_windows_files(self): - utils.mkdir("/tftpboot/profiles") + utils.mkdir(os.path.join(self.bootloc, "profiles")) for p in self.profiles: distro = p.get_conceptual_parent() if distro and distro.breed != "windows": continue else: self.generate_windows_profile_pxe(p) - utils.mkdir("/tftpboot/systems") + utils.mkdir(os.path.join(self.bootloc, "systems")) for s in self.systems: profile = s.get_conceptual_parent() if profile: @@ -197,7 +197,7 @@ class PXEGen: def generate_windows_profile_pxe(self, profile): distro = profile.get_conceptual_parent() - dest_dir = os.path.join("/tftpboot/profiles", profile.name) + dest_dir = os.path.join(self.bootloc, "profiles", profile.name) utils.mkdir(dest_dir) utils.cabextract(distro.kernel, dest_dir, self.api) @@ -245,7 +245,7 @@ class PXEGen: data = self.templar.render(template_data, blended, None) - # write .sif to /tftpboot/profiles/$name/winnt.sif + # write .sif to self.bootloc/profiles/$name/winnt.sif file_name = os.path.join(dest_dir, "winnt.sif") fd = open(file_name, "w") fd.write(data) @@ -260,7 +260,7 @@ class PXEGen: distro = profile.get_conceptual_parent() - dest_dir = os.path.join("/tftpboot/systems", system.name) + dest_dir = os.path.join(self.bootloc, "systems", system.name) utils.mkdir(dest_dir) utils.cabextract(distro.kernel, dest_dir, self.api) @@ -311,151 +311,7 @@ class PXEGen: data = self.templar.render(template_data, blended, None) - # write .sif to /tftpboot/systems/$name/winnt.sif - file_name = os.path.join(dest_dir, "winnt.sif") - fd = open(file_name, "w") - fd.write(data) - fd.close() - - return True - - def generate_windows_files(self): - # FIXME: hard coding of /tftpboot here is wrong - utils.mkdir("/tftpboot/profiles") - for p in self.profiles: - distro = p.get_conceptual_parent() - if distro and distro.breed != "windows": - continue - else: - self.generate_windows_profile_pxe(p) - utils.mkdir("/tftpboot/systems") - for s in self.systems: - profile = s.get_conceptual_parent() - if profile: - distro = profile.get_conceptual_parent() - if distro and distro.breed != "windows": - continue - else: - self.generate_windows_system_pxe(s) - - def generate_windows_profile_pxe(self, profile): - distro = profile.get_conceptual_parent() - - dest_dir = os.path.join("/tftpboot/profiles", profile.name) - utils.mkdir(dest_dir) - - utils.cabextract(distro.kernel, dest_dir, self.api) - - src_file = os.path.join(dest_dir, "startrom.n12") - dest_file = os.path.join(dest_dir, "winpxe.0") - cmd = [ "/bin/sed", "-i", "-e", "s/ntldr/L%s/gi" % profile.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - os.rename(src_file, dest_file) - - utils.cabextract(distro.initrd, dest_dir, self.api) - - src_file = os.path.join(dest_dir, "setupldr.exe") - dest_file = os.path.join(dest_dir, "NTLDR") - cmd = [ "/bin/sed", "-i", "-e", "s/winnt\\.sif/w%s.sif/gi" % profile.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - cmd = [ "/bin/sed", "-i", "-e", "s/ntdetect\\.com/ntd_%s.com/gi" % profile.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - os.rename(src_file, dest_file) - - src_dir = os.path.dirname(distro.kernel) - src_file = os.path.join(src_dir, "ntdetect.com") - file_name = os.path.join(dest_dir, "ntdetect.com") - utils.copyfile(src_file, file_name, self.api) - - template = profile.kickstart - fd = open(template, "r") - template_data = fd.read() - fd.close() - - blended = utils.blender(self.api, False, profile) - blended['next_server'] = self.settings.next_server - - ksmeta = blended.get("ks_meta",{}) - del blended["ks_meta"] - blended.update(ksmeta) # make available at top level - - # this is a workaround for a dumb bug in cheetah... - # a backslash before a variable is always treated as - # escaping the $, so things are not rendered correctly. - # The only option is to use another variable for - # backslashes when leading another variable. i.e.: - # \\$variable - blended['bsp'] = '\\' - - data = self.templar.render(template_data, blended, None) - - # write .sif to /tftpboot/profiles/$name/winnt.sif - file_name = os.path.join(dest_dir, "winnt.sif") - fd = open(file_name, "w") - fd.write(data) - fd.close() - - return True - - def generate_windows_system_pxe(self, system): - profile = system.get_conceptual_parent() - if not profile: - return False - - distro = profile.get_conceptual_parent() - - dest_dir = os.path.join("/tftpboot/systems", system.name) - utils.mkdir(dest_dir) - - utils.cabextract(distro.kernel, dest_dir, self.api) - - src_file = os.path.join(dest_dir, "startrom.n12") - dest_file = os.path.join(dest_dir, "winpxe.0") - cmd = [ "/bin/sed", "-i", "-e", "s/ntldr/L%s/gi" % system.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - os.rename(src_file, dest_file) - - utils.cabextract(distro.initrd, dest_dir, self.api) - - src_file = os.path.join(dest_dir, "setupldr.exe") - dest_file = os.path.join(dest_dir, "NTLDR") - cmd = [ "/bin/sed", "-i", "-e", "s/winnt\\.sif/w%s.sif/gi" % system.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - cmd = [ "/bin/sed", "-i", "-e", "s/ntdetect\\.com/ntd_%s.com/gi" % system.random_id, src_file ] - sub_process.call(cmd, shell=False, close_fds=False) - os.rename(src_file, dest_file) - - src_dir = os.path.dirname(distro.kernel) - src_file = os.path.join(src_dir, "ntdetect.com") - file_name = os.path.join(dest_dir, "ntdetect.com") - utils.copyfile(src_file, file_name, self.api) - - template = system.kickstart - if template == "<<inherit>>": - template = profile.kickstart - - fd = open(template, "r") - template_data = fd.read() - fd.close() - - blended = utils.blender(self.api, False, system) - blended['next_server'] = self.settings.next_server - - ksmeta = blended.get("ks_meta",{}) - del blended["ks_meta"] - blended.update(ksmeta) # make available at top level - - # this is a workaround for a dumb bug in cheetah... - # a backslash before a variable is always treated as - # escaping the $, so things are not rendered correctly. - # The only option is to use another variable for - # backslashes when leading another variable. i.e.: - # \\$variable - blended['bsp'] = '\\' - - data = self.templar.render(template_data, blended, None) - - # write .sif to /tftpboot/systems/$name/winnt.sif + # write .sif to self.bootloc/systems/$name/winnt.sif file_name = os.path.join(dest_dir, "winnt.sif") fd = open(file_name, "w") fd.write(data) |