summaryrefslogtreecommitdiffstats
path: root/cobbler/utils.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-03-25 15:55:18 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-03-25 15:55:18 -0400
commit0ceedaa6657d4b31267a3a7224d3c9db3bd124aa (patch)
treed8ebe6a0311ad02092f523d2c8ec68faa82841e5 /cobbler/utils.py
parentbfbb6a2527e3a943b8ace33ed589799b3b8978ab (diff)
downloadthird_party-cobbler-0ceedaa6657d4b31267a3a7224d3c9db3bd124aa.tar.gz
third_party-cobbler-0ceedaa6657d4b31267a3a7224d3c9db3bd124aa.tar.xz
third_party-cobbler-0ceedaa6657d4b31267a3a7224d3c9db3bd124aa.zip
tftpboot location discovery for F9
Diffstat (limited to 'cobbler/utils.py')
-rw-r--r--cobbler/utils.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/cobbler/utils.py b/cobbler/utils.py
index c6a6154..86ff41d 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -468,3 +468,51 @@ def fix_mod_python_select_submission(repos):
repos = repos.lstrip().rstrip()
return repos
+def redhat_release():
+ if not os.path.exists("/bin/rpm"):
+ return ("unknown", 0)
+ args = ["/bin/rpm", "-q", "--whatprovides", "redhat-release"]
+ cmd = sub_process.Popen(args,shell=False,stdout=sub_process.PIPE)
+ data = cmd.communicate()[0]
+ data = data.rstrip().lower()
+ make = "other"
+ if data.find("redhat") != -1:
+ make = "redhat"
+ elif data.find("centos") != -1:
+ make = "centos"
+ elif data.find("fedora") != -1:
+ make = "fedora"
+ version = data.split("release-")[-1]
+ rest = 0
+ if version.find("-"):
+ parts = version.split("-")
+ version = parts[0]
+ rest = parts[1]
+ return (make, float(version), rest)
+
+def tftpboot_location():
+
+ # if possible, read from TFTP config file to get the location
+ if os.path.exists("/etc/xinetd.d/tftp"):
+ fd = open("/etc/xinetd.d/tftp")
+ lines = fd.read().split("\n")
+ for line in lines:
+ if line.find("server_args") != -1:
+ tokens = line.split(None)
+ mark = False
+ for t in tokens:
+ if t == "-s":
+ mark = True
+ elif mark:
+ return t
+
+ # otherwise, guess based on the distro
+ (make,version,rest) = redhat_release()
+ if make == "fedora" and version >= 9:
+ return "/var/lib/tftpboot"
+ return "/tftpboot"
+
+if __name__ == "__main__":
+ # print redhat_release()
+ print tftpboot_location()
+