diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-10-15 16:32:40 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2007-10-15 16:32:40 -0400 |
commit | cdfa3979d40766f9192c5a940f778ed6d9c81453 (patch) | |
tree | 8edf11fc5387f20730517e3236ba29ae9ccf085c /cobbler | |
parent | 2a1fbfa0f3bf6e8a9ac8cb8b43a70425d77ba0a6 (diff) | |
download | third_party-cobbler-cdfa3979d40766f9192c5a940f778ed6d9c81453.tar.gz third_party-cobbler-cdfa3979d40766f9192c5a940f778ed6d9c81453.tar.xz third_party-cobbler-cdfa3979d40766f9192c5a940f778ed6d9c81453.zip |
Applied patch to symlink distro kernel/initrd parameters if they live in /tftpboot.
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/action_sync.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index 3de38a8..ee707f3 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -302,8 +302,14 @@ class BootSync: raise CX(_("initrd not found: %(file)s, distro: %(distro)s") % { "file" : d.initrd, "distro" : d.name }) b_kernel = os.path.basename(kernel) b_initrd = os.path.basename(initrd) - self.copyfile(kernel, os.path.join(distro_dir, b_kernel)) - self.copyfile(initrd, os.path.join(distro_dir, b_initrd)) + if kernel.startswith(dirtree): + self.linkfile(kernel, os.path.join(distro_dir, b_kernel)) + else: + self.copyfile(kernel, os.path.join(distro_dir, b_kernel)) + if initrd.startswith(dirtree): + self.linkfile(initrd, os.path.join(distro_dir, b_initrd)) + else: + self.copyfile(initrd, os.path.join(distro_dir, b_initrd)) def validate_kickstarts(self): """ @@ -840,6 +846,25 @@ class BootSync: fd.write(yaml.dump(blended)) fd.close() + def linkfile(self, src, dst): + """ + Attempt to create a link dst that points to src. Because file + systems suck we attempt several different methods or bail to + self.copyfile() + """ + + try: + return os.link(src, dst) + except (IOError, OSError): + pass + + try: + return os.symlink(src, dst) + except (IOError, OSError): + pass + + return self.copyfile(src, dst) + def copyfile(self,src,dst): try: return shutil.copyfile(src,dst) |