File pathes_fix.diff of Package cobbler.import4280
--- cobbler/action_check.py
+++ cobbler/action_check.py 2011/03/03 16:43:42
@@ -188,7 +188,7 @@
rule1 = True
if line.startswith("/var/lib/tftpboot/.*"):
rule2 = True
- if line.startswith("/var/www/cobbler/images/.*"):
+ if line.startswith(self.settings.webdir+"/images/.*"):
rule3 = True
rules = []
@@ -198,7 +198,7 @@
if not rule2:
rules.append(selinux_msg % "/var/lib/tftpboot/.*")
if not rule3:
- rules.append(selinux_msg % "/var/www/cobbler/images/.*")
+ rules.append(selinux_msg % self.settings.webdir+"/images/.*")
if len(rules) > 0:
status.append("you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: %s" % " && ".join(rules))
--- cobbler/action_hardlink.py
+++ cobbler/action_hardlink.py 2011/03/03 16:47:35
@@ -54,7 +54,12 @@
self.logger.info("now hardlinking to save space, this may take some time.")
- rc = utils.subprocess_call(self.logger,"/usr/sbin/hardlink -c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror",shell=True)
+ # FIXME: how about settings? (self.settings.webdir)
+ webdir = "/var/www/cobbler"
+ if os.path.isdir("/srv/www"):
+ webdir = "/srv/www/cobbler"
+
+ rc = utils.subprocess_call(self.logger,"/usr/sbin/hardlink -c -v "+webdir+"/ks_mirror /var/www/cobbler/repo_mirror",shell=True)
return rc
--- cobbler/action_reposync.py
+++ cobbler/action_reposync.py 2011/03/03 16:39:07
@@ -212,7 +212,7 @@
self.logger.warning("--rpm-list is not supported for rsync'd repositories")
# FIXME: don't hardcode
- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
+ dest_path = os.path.join(self.settings.webdir+"/repo_mirror", repo.name)
spacer = ""
if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
@@ -255,7 +255,7 @@
# create yum config file for use by reposync
# FIXME: don't hardcode
- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
+ dest_path = os.path.join(self.settings.webdir+"/repo_mirror", repo.name)
temp_path = os.path.join(dest_path, ".origin")
if not os.path.isdir(temp_path):
@@ -273,7 +273,7 @@
if has_rpm_list:
self.logger.warning("warning: --rpm-list is not supported for RHN content")
rest = repo.mirror[6:] # everything after rhn://
- cmd = "/usr/bin/reposync %s -r %s --download_path=%s" % (self.rflags, rest, "/var/www/cobbler/repo_mirror")
+ cmd = "/usr/bin/reposync %s -r %s --download_path=%s" % (self.rflags, rest, self.settings.webdir+"/repo_mirror")
if repo.name != rest:
args = { "name" : repo.name, "rest" : rest }
utils.die(self.logger,"ERROR: repository %(name)s needs to be renamed %(rest)s as the name of the cobbler repository must match the name of the RHN channel" % args)
@@ -334,7 +334,7 @@
has_rpm_list = True
# create yum config file for use by reposync
- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
+ dest_path = os.path.join(self.settings.webdir+"/repo_mirror", repo.name)
temp_path = os.path.join(dest_path, ".origin")
if not os.path.isdir(temp_path) and repo.mirror_locally:
@@ -348,7 +348,7 @@
if not has_rpm_list and repo.mirror_locally:
# if we have not requested only certain RPMs, use reposync
- cmd = "/usr/bin/reposync %s --config=%s --repoid=%s --download_path=%s" % (self.rflags, temp_file, repo.name, "/var/www/cobbler/repo_mirror")
+ cmd = "/usr/bin/reposync %s --config=%s --repoid=%s --download_path=%s" % (self.rflags, temp_file, repo.name, self.settings.webdir+"/repo_mirror")
if repo.arch != "":
if repo.arch == "x86":
repo.arch = "i386" # FIX potential arch errors
--- cobbler/collection_distros.py
+++ cobbler/collection_distros.py 2011/03/03 16:57:24
@@ -80,7 +80,8 @@
# look through all mirrored directories and find if any directory is holding
# this particular distribution's kernel and initrd
- possible_storage = glob.glob("/var/www/cobbler/ks_mirror/*")
+ settings = self.config.settings()
+ possible_storage = glob.glob(settings.webdir+"/ks_mirror/*")
path = None
for storage in possible_storage:
if os.path.dirname(obj.kernel).find(storage) != -1:
@@ -89,7 +90,7 @@
# if we found a mirrored path above, we can delete the mirrored storage /if/
# no other object is using the same mirrored storage.
- if with_delete and path is not None and os.path.exists(path) and kernel.find("/var/www/cobbler") != -1:
+ if with_delete and path is not None and os.path.exists(path) and kernel.find(settings.webdir) != -1:
# this distro was originally imported so we know we can clean up the associated
# storage as long as nothing else is also using this storage.
found = False
--- cobbler/collection_repos.py
+++ cobbler/collection_repos.py 2011/03/03 17:01:16
@@ -66,8 +66,10 @@
utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/post/*", [], logger)
utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/change/*", [], logger)
-
+ #FIXME: better use config.settings() webdir?
path = "/var/www/cobbler/repo_mirror/%s" % obj.name
+ if os.path.exists("/srv/www/"):
+ path = "/srv/www/cobbler/repo_mirror/%s" % obj.name
if os.path.exists(path):
utils.rmtree(path)
--- cobbler/remote.py
+++ cobbler/remote.py 2011/03/03 17:18:40
@@ -143,8 +143,12 @@
profiles without using PXE.
"""
def runner(self):
+ # FIXME: better use webdir from the settings?
+ webdir = "/var/www/cobbler/"
+ if os.path.exists("/srv/www"):
+ webdir = "/srv/www/cobbler/"
return self.remote.api.build_iso(
- self.options.get("iso","/var/www/cobbler/pub/generated.iso"),
+ self.options.get("iso",webdir+"/pub/generated.iso"),
self.options.get("profiles",None),
self.options.get("systems",None),
self.options.get("tempdir",None),
@@ -155,7 +159,7 @@
self.logger
)
def on_done(self):
- if self.options.get("iso","") == "/var/www/cobbler/pub/generated.iso":
+ if self.options.get("iso","") == webdir+"/pub/generated.iso":
msg = "ISO now available for <A HREF=\"/cobbler/pub/generated.iso\">download</A>"
self.remote._new_event(msg)
return self.__start_task(runner, token, "buildiso", "Build Iso", options, on_done)
--- cobbler/services.py
+++ cobbler/services.py 2011/03/03 17:22:05
@@ -320,7 +320,11 @@
api.add_image(image)
# perhaps an artifact of the test process?
- utils.os_system("rm -rf /var/www/cobbler/repo_mirror/repo0")
+ # FIXME: get path (at least webdir) from settings?
+ if os.path.exists("/var/www/cobbler/repo_mirror/"):
+ utils.os_system("rm -rf /var/www/cobbler/repo_mirror/repo0")
+ elif os.path.exists("/srv/www/cobbler/repo_mirror/"):
+ utils.os_system("rm -rf /srv/www/cobbler/repo_mirror/repo0")
api.reposync(name="repo0")
--- cobbler/utils.py
+++ cobbler/utils.py 2011/03/04 11:31:37
@@ -983,6 +983,8 @@
(make,version) = os_release()
if make == "fedora" and version >= 9:
return "/var/lib/tftpboot"
+ if make == "suse":
+ return "/srv/tftpboot"
return "/tftpboot"
def can_do_public_content(api):
@@ -1962,10 +1964,13 @@
def dhcpconf_location(api):
version = api.os_version
+ (dist, ver) = api.get_os_details()
if version[0] in [ "redhat", "centos" ] and version[1] < 6:
return "/etc/dhcpd.conf"
elif version[0] in [ "fedora" ] and version[1] < 11:
return "/etc/dhcpd.conf"
+ elif dist == "suse":
+ return "/etc/dhcpd.conf"
else:
return "/etc/dhcp/dhcpd.conf"
--- cobbler/modules/sync_post_restart_services.py
+++ cobbler/modules/sync_post_restart_services.py 2011/03/04 12:47:06
@@ -34,6 +34,9 @@
has_restarted_dnsmasq = False
rc = 0
+ init_scripts_dir = "/etc/rc.d/"
+ if os.path.exists(init_scripts_dir+"init.d/"):
+ init_scripts_dir = init_scripts_dir + "init.d/"
if manage_dhcp != "0":
if which_dhcp_module == "manage_isc":
if restart_dhcp != "0":
@@ -41,10 +44,10 @@
if rc != 0:
logger.error("dhcpd -t failed")
return 1
- rc = utils.subprocess_call(logger,"/etc/rc.d/init.d/dhcpd restart", shell=True)
+ rc = utils.subprocess_call(logger,init_scripts_dir + "dhcpd restart", shell=True)
elif which_dhcp_module == "manage_dnsmasq":
if restart_dhcp != "0":
- rc = utils.subprocess_call(logger, "/etc/rc.d/init.d/dnsmasq restart")
+ rc = utils.subprocess_call(logger, init_scripts_dir + "dnsmasq restart")
has_restarted_dnsmasq = True
else:
logger.error("unknown DHCP engine: %s" % which_dhcp_module)
@@ -52,9 +55,9 @@
if manage_dns != "0" and restart_dns != "0":
if which_dns_module == "manage_bind":
- rc = utils.subprocess_call(logger, "/etc/rc.d/init.d/named restart", shell=True)
+ rc = utils.subprocess_call(logger, init_scripts_dir + "named restart", shell=True)
elif which_dns_module == "manage_dnsmasq" and not has_restarted_dnsmasq:
- rc = utils.subprocess_call(logger, "/etc/rc.d/init.d/dnsmasq restart", shell=True)
+ rc = utils.subprocess_call(logger, init_scripts_dir + "dnsmasq restart", shell=True)
elif which_dns_module == "manage_dnsmasq" and has_restarted_dnsmasq:
rc = 0
else:
--- cobbler/settings.py
+++ cobbler/settings.py 2011/03/07 10:05:39
@@ -23,6 +23,8 @@
import utils
from utils import _
+import os.path
+
TESTMODE = False
# defaults is to be used if the config file doesn't contain the value
@@ -104,6 +106,8 @@
"reposync_flags" : "-l -m -d"
}
+if os.path.exists("/srv/www/"):
+ DEFAULTS["webdir"] = "/srv/www/cobbler"
class Settings: