summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_check.py29
-rw-r--r--cobbler/action_reposync.py2
-rw-r--r--cobbler/item_profile.py11
-rw-r--r--cobbler/serializer.py4
-rw-r--r--cobbler/utils.py18
-rw-r--r--cobbler/yumgen.py4
6 files changed, 51 insertions, 17 deletions
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index 044b56b..f5f86f0 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -66,6 +66,8 @@ class BootCheck:
self.check_iptables(status)
self.check_yum(status)
self.check_for_default_password(status)
+ self.check_for_unreferenced_repos(status)
+ self.check_for_unsynced_repos(status)
return status
@@ -134,6 +136,33 @@ class BootCheck:
status.append(_("One or more kickstart templates references default password 'cobbler' and should be changed for security reasons: %s") % ", ".join(files))
+ def check_for_unreferenced_repos(self,status):
+ repos = []
+ referenced = []
+ not_found = []
+ for r in self.config.api.repos():
+ repos.append(r.name)
+ for p in self.config.api.profiles():
+ my_repos = p.repos
+ referenced.extend(my_repos)
+ for r in referenced:
+ if r not in repos:
+ not_found.append(r)
+ if len(not_found) > 0:
+ status.append(_("One or more repos referenced by profile objects is no longer defined in cobbler: %s") % ", ".join(not_found))
+
+ def check_for_unsynced_repos(self,status):
+ need_sync = []
+ for r in self.config.repos():
+ if r.mirror_locally == 1:
+ lookfor = os.path.join(self.settings.webdir, "repo_mirror", r.name)
+ print "DEBUG: looking for: %s" % lookfor
+ if not os.path.exists(lookfor):
+ need_sync.append(r.name)
+ if len(need_sync) > 0:
+ status.append(_("One or more repos need to be processed by cobbler reposync for the first time before kickstarting against them: %s") % ", ".join(need_sync))
+
+
def check_httpd(self,status):
"""
Check if Apache is installed.
diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py
index 495aa3a..57c2d08 100644
--- a/cobbler/action_reposync.py
+++ b/cobbler/action_reposync.py
@@ -314,7 +314,7 @@ class RepoSync:
if os.path.exists(getenforce):
data = sub_process.Popen(getenforce, shell=True, stdout=sub_process.PIPE).communicate()[0]
if data.lower().find("disabled") == -1:
- cmd3 = "chcon --reference /var/www %s" % repo_path
+ cmd3 = "chcon --reference /var/www %s >/dev/null 2>/dev/null" % repo_path
sub_process.call(cmd3, shell=True)
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index c5c9bdb..0e16f46 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -70,7 +70,10 @@ class Profile(item.Item):
# backwards compatibility
if type(self.repos) != list:
- self.set_repos(self.repos)
+ # ensure we are formatted correctly though if some repo
+ # defs don't exist on this side, don't fail as we need
+ # to convert everything -- cobbler check can report it
+ self.set_repos(self.repos,bypass_check=True)
self.set_parent(self.parent)
# virt specific
@@ -87,7 +90,7 @@ class Profile(item.Item):
if self.ks_meta != "<<inherit>>" and type(self.ks_meta) != dict:
self.set_ksmeta(self.ks_meta)
if self.repos != "<<inherit>>" and type(self.ks_meta) != list:
- self.set_repos(self.repos)
+ self.set_repos(self.repos,bypass_check=True)
self.set_owners(self.owners)
@@ -171,8 +174,8 @@ class Profile(item.Item):
def set_virt_path(self,path):
return utils.set_virt_path(self,path)
- def set_repos(self,repos):
- return utils.set_repos(self,repos)
+ def set_repos(self,repos,bypass_check=False):
+ return utils.set_repos(self,repos,bypass_check)
def get_parent(self):
diff --git a/cobbler/serializer.py b/cobbler/serializer.py
index 25d0d60..ac98412 100644
--- a/cobbler/serializer.py
+++ b/cobbler/serializer.py
@@ -59,10 +59,8 @@ def serialize_item(collection, item):
storage_module = __get_storage_module(collection.collection_type())
save_fn = getattr(storage_module, "serialize_item", None)
if save_fn is None:
- # print "DEBUG: WARNING: full serializer"
rc = storage_module.serialize(collection)
else:
- # print "DEBUG: partial serializer"
rc = save_fn(collection,item)
__release_lock()
return rc
@@ -75,10 +73,8 @@ def serialize_delete(collection, item):
storage_module = __get_storage_module(collection.collection_type())
delete_fn = getattr(storage_module, "serialize_delete", None)
if delete_fn is None:
- # print "DEBUG: full delete"
rc = storage_module.serialize(collection)
else:
- # print "DEBUG: partial delete"
rc = delete_fn(collection,item)
__release_lock()
return rc
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 112d94b..c62ec6c 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -634,7 +634,7 @@ def mkdir(path,mode=0777):
print oe.errno
raise CX(_("Error creating") % path)
-def set_repos(self,repos):
+def set_repos(self,repos,bypass_check=False):
# WARNING: hack
repos = fix_mod_python_select_submission(repos)
@@ -653,7 +653,6 @@ def set_repos(self,repos):
else:
repolist = repos
-
# make sure there are no empty strings
try:
repolist.remove('')
@@ -662,13 +661,18 @@ def set_repos(self,repos):
self.repos = []
- # if any repos don't exist, fail the operation
+ # if any repos don't exist, fail the set operation
+ # unless called from the deserializer stage in which
+ # case we have a soft error that check can report
ok = True
for r in repolist:
- if self.config.repos().find(name=r) is not None:
- self.repos.append(r)
- else:
- print _("warning: repository not found: %s" % r)
+ if bypass_check:
+ self.repos.append(r)
+ else:
+ if self.config.repos().find(name=r) is not None:
+ self.repos.append(r)
+ else:
+ raise CX(_("repo %s is not defined") % r)
return True
diff --git a/cobbler/yumgen.py b/cobbler/yumgen.py
index e39a72e..8c10be3 100644
--- a/cobbler/yumgen.py
+++ b/cobbler/yumgen.py
@@ -98,7 +98,9 @@ class YumGen:
try:
infile_h = open(infile)
except:
- print _("WARNING: cobbler reposync needs to be run on repo (%s), then re-run cobbler sync") % dispname
+ # file does not exist and the user needs to run reposync
+ # before we will use this, cobbler check will mention
+ # this problem
continue
infile_data = infile_h.read()
infile_h.close()