summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_check.py11
-rw-r--r--cobbler/settings.py9
-rw-r--r--cobbler/utils.py48
3 files changed, 61 insertions, 7 deletions
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index f7bc9d9..a4a09f6 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -17,6 +17,7 @@ import os
import re
import sub_process
import action_sync
+import utils
from rhpl.translate import _, N_, textdomain, utf8
class BootCheck:
@@ -152,17 +153,15 @@ class BootCheck:
if os.path.exists(self.settings.tftpd_conf):
f = open(self.settings.tftpd_conf)
re_disable = re.compile(r'disable.*=.*yes')
- found_bootdir = False
for line in f.readlines():
if re_disable.search(line):
status.append(_("change 'disable' to 'no' in %(file)s") % { "file" : self.settings.tftpd_conf })
- if line.find("-s %s" % self.settings.tftpboot) != -1:
- found_bootdir = True
- if not found_bootdir:
- status.append(_("change 'server_args' to '-s %(args)s' in %(file)s") % { "file" : "/etc/xinetd.d/tftp", "args" : self.settings.tftpboot })
-
else:
status.append(_("file %(file)s does not exist") % { "file" : self.settings.tftpd_conf })
+
+ bootloc = utils.tftpboot_location()
+ if not os.path.exists(bootloc):
+ status.append(_("directory needs to be created: %s" % bootloc))
def check_dhcpd_conf(self,status):
diff --git a/cobbler/settings.py b/cobbler/settings.py
index ccaf04d..cdbcabd 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -54,7 +54,7 @@ DEFAULTS = {
"server" : "127.0.0.1",
"snippetsdir" : "/var/lib/cobbler/snippets",
"syslog_port" : 25150,
- "tftpboot" : "/tftpboot",
+ "tftpboot" : -1, # special, see note below
"tftpd_bin" : "/usr/sbin/in.tftpd",
"tftpd_conf" : "/etc/xinetd.d/tftp",
"webdir" : "/var/www/cobbler",
@@ -102,7 +102,14 @@ class Settings(serializable.Serializable):
if datastruct is None:
print _("warning: not loading empty structure for %s") % self.filename()
return
+
self._attributes = datastruct
+
+ # this last attribute is special. In F9, the tftpboot location moves, so
+ # what we have in settings is not (neccessarily) correct. So instead
+ # of using settings we determine it by looking at the OS.
+ self._attributes["tftpboot"] = utils.tftpboot_location()
+
return self
def __getattr__(self,name):
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()
+