summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--cobbler/action_check.py32
-rw-r--r--cobbler/action_enchant.py16
-rw-r--r--cobbler/action_import.py71
-rw-r--r--cobbler/action_litesync.py10
-rw-r--r--cobbler/action_reposync.py37
-rw-r--r--cobbler/action_status.py30
-rw-r--r--cobbler/action_sync.py60
-rw-r--r--cobbler/api.py1
-rw-r--r--cobbler/cexceptions.py13
-rwxr-xr-xcobbler/cobbler.py100
-rw-r--r--cobbler/cobbler_msg.py152
-rw-r--r--cobbler/collection.py11
-rw-r--r--cobbler/collection_distros.py6
-rw-r--r--cobbler/collection_profiles.py6
-rw-r--r--cobbler/collection_repos.py4
-rw-r--r--cobbler/collection_systems.py5
-rw-r--r--cobbler/item.py3
-rw-r--r--cobbler/item_distro.py31
-rw-r--r--cobbler/item_profile.py68
-rw-r--r--cobbler/item_repo.py15
-rw-r--r--cobbler/item_system.py22
-rw-r--r--cobbler/serializer.py11
-rw-r--r--cobbler/settings.py6
-rw-r--r--cobbler/utils.py2
-rw-r--r--tests/tests.py3
26 files changed, 260 insertions, 457 deletions
diff --git a/TODO b/TODO
index cf68a0d..e846d4c 100644
--- a/TODO
+++ b/TODO
@@ -12,5 +12,5 @@ cobbler TODO list.
- no logrotate or cleanup for /var/log/cobbler (kickstart tracking)
- build net-install CD images
- build non-net-install CD from cobbler profile
-
+- have pre and post triggers, check return codes and validate
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index 17f4292..88345e1 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -15,7 +15,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
import re
-import cobbler_msg
import action_sync
from rhpl.translate import _, N_, textdomain, utf8
@@ -44,7 +43,7 @@ class BootCheck:
elif mode == "dnsmasq":
self.check_dnsmasq_bin(status)
else:
- status.append(cobbler_msg.lookup("dhcp_choice"))
+ status.append(_("manage_dhcp_mode in /var/lib/cobbler/settings should be 'isc' or 'dnsmasq'"))
self.check_bootloaders(status)
self.check_tftpd_bin(status)
@@ -61,16 +60,16 @@ class BootCheck:
parameters.
"""
if self.settings.server == "127.0.0.1":
- status.append(cobbler_msg.lookup("bad_server"))
+ status.append(_("The 'server' field in /var/lib/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it."))
if self.settings.next_server == "127.0.0.1":
- status.append(cobbler_msg.lookup("bad_next"))
+ status.append(_("For PXE to be functional, the 'next_server' field in /var/lib/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network."))
def check_httpd(self,status):
"""
Check if Apache is installed.
"""
if not os.path.exists(self.settings.httpd_bin):
- status.append(cobbler_msg.lookup("no_httpd"))
+ status.append(_("Apache doesn't appear to be installed"))
def check_dhcpd_bin(self,status):
@@ -78,14 +77,14 @@ class BootCheck:
Check if dhcpd is installed
"""
if not os.path.exists(self.settings.dhcpd_bin):
- status.append(cobbler_msg.lookup("no_dhcpd"))
+ status.append(_("dhcpd isn't installed, but is enabled in /var/lib/cobbler/settings"))
def check_dnsmasq_bin(self,status):
"""
Check if dnsmasq is installed
"""
if not os.path.exists(self.settings.dnsmasq_bin):
- status.append(cobbler_msg.lookup("no_dnsmasq"))
+ status.append(_("dnsmasq isn't installed, but is enabled in /var/lib/cobbler/settings"))
def check_bootloaders(self,status):
"""
@@ -94,7 +93,7 @@ class BootCheck:
for loader in self.settings.bootloaders.keys():
filename = self.settings.bootloaders[loader]
if not os.path.exists(filename):
- status.append(cobbler_msg.lookup("no_bootloader"))
+ status.append(_("missing 1 or more bootloader files listed in /var/lib/cobbler/settings"))
return
def check_tftpd_bin(self,status):
@@ -102,14 +101,14 @@ class BootCheck:
Check if tftpd is installed
"""
if not os.path.exists(self.settings.tftpd_bin):
- status.append(cobbler_msg.lookup("no_tftpd"))
+ status.append(_("tftp-server is not installed."))
def check_tftpd_dir(self,status):
"""
Check if cobbler.conf's tftpboot directory exists
"""
if not os.path.exists(self.settings.tftpboot):
- status.append(cobbler_msg.lookup("no_dir") % self.settings.tftpboot)
+ status.append(_("please create directory: %(dirname)s") % { "dirname" : self.settings.tftpboot })
def check_tftpd_conf(self,status):
@@ -123,13 +122,14 @@ class BootCheck:
found_bootdir = False
for line in f.readlines():
if re_disable.search(line):
- status.append(cobbler_msg.lookup("chg_attrib") % ('disable','no',self.settings.tftpd_conf))
+ 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(cobbler_msg.lookup("chg_attrib") % ('server_args',"-s %s" % self.settings.tftpboot, self.settings.tftpd_conf))
+ status.append(_("change 'server_args' to '-s %(args)' in %(file)s") % { "file" : self.settings.tftpboot, "args" : self.settings.tftpboot })
+
else:
- status.append(cobbler_msg.lookup("no_exist") % self.settings.tftpd_conf)
+ status.append(_("file %(file)s does not exist") % { "file" : self.settings.tftpd_conf })
def check_dhcpd_conf(self,status):
@@ -155,10 +155,10 @@ class BootCheck:
if line.find("filename") != -1:
match_file = True
if not match_next:
- status.append(cobbler_msg.lookup("no_next_server") % (self.settings.dhcpd_conf))
+ status.append(_("expecting next-server entry in %(file)s") % { "file" : self.settings.dhcpd_conf })
if not match_file:
- status.append(cobbler_msg.lookup("no_filename") % (self.settings.dhcpd_conf))
+ status.append(_("missing file: %(file)s") % { "file" : self.settings.dhcpd_conf })
else:
- status.append(cobbler_msg.lookup("no_exist") % self.settings.dhcpd_conf)
+ status.append(_("missing file: %(file)s") % { "file" : self.settings.dhcpd_conf })
diff --git a/cobbler/action_enchant.py b/cobbler/action_enchant.py
index 260d134..7dcc097 100644
--- a/cobbler/action_enchant.py
+++ b/cobbler/action_enchant.py
@@ -13,7 +13,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
-import cexceptions
+from cexceptions import *
import os
import os.path
import sub_process
@@ -37,13 +37,13 @@ class Enchant:
self.system = system
self.is_virt = is_virt
if address is None:
- raise cexceptions.CobblerException("enchant_failed","no address specified")
+ raise CX(_("enchant failed. no address specified"))
if system is None and profile is None:
- raise cexceptions.CobblerException("enchant_failed","no profile specified")
+ raise CX(_("enchant failed. no profile specified"))
if system is not None and self.config.systems().find(system) is None:
- raise cexceptions.CobblerException("enchant_failed","system name not found")
+ raise CX(_("enchant failed. system not found"))
if profile is not None and self.config.profiles().find(profile) is None:
- raise cexceptions.CobblerException("enchant_failed","profile name not found")
+ raise CX(_("enchant failed. profile name not found"))
def ssh_exec(self,cmd,catch_fail=True):
@@ -56,7 +56,7 @@ class Enchant:
rc = sub_process.call(cmd2,shell=True)
print "returns: %d" % rc
if catch_fail and rc != 0:
- raise cexceptions.CobblerException("enchant_failed","ssh failure")
+ raise CX(_("enchant failed. SSH error."))
def run(self):
"""
@@ -79,7 +79,7 @@ class Enchant:
koan = os.path.basename(self.settings.koan_path)
where_is_koan = os.path.join(self.settings.webdir,os.path.basename(koan))
if not os.path.exists(where_is_koan) or os.path.isdir(where_is_koan):
- raise cexceptions.CobblerException("enchant_failed","koan is missing")
+ raise CX(_("enchant failed. koan_path is not correct in /var/lib/cobbler/settings"))
try:
self.ssh_exec("wget http://%s/cobbler/%s" % (self.settings.server, koan))
@@ -107,6 +107,6 @@ class Enchant:
return True
except:
traceback.print_exc()
- raise cexceptions.CobblerException("enchant_failed","exception")
+ raise CX(_("enchant failed. an exception occurred."))
return False # shouldn't be here
diff --git a/cobbler/action_import.py b/cobbler/action_import.py
index 61c2d84..3693e63 100644
--- a/cobbler/action_import.py
+++ b/cobbler/action_import.py
@@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
-import cexceptions
+from cexceptions import *
import os
import os.path
import traceback
@@ -51,12 +51,12 @@ class Importer:
def run(self):
if self.mirror is None:
- raise cexceptions.CobblerException("import_failed","no mirror specified")
+ raise CX(_("import failed. no --mirror specified"))
if self.mirror_name is None:
- raise cexceptions.CobblerException("import_failed","no mirror-name specified")
+ raise CX(_("import failed. no --name specified"))
if self.mirror_name is None:
- raise cexceptions.CobblerException("import_failed","must specify --mirror-name")
+ raise CX(_("import failed. no --name specified"))
# make the output path
self.path = "%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name)
@@ -80,16 +80,16 @@ class Importer:
self.processed_repos = {}
- print "---------------- (adding distros)"
+ print _("---------------- (adding distros)")
os.path.walk(self.path, self.distro_adder, {})
- print "---------------- (associating repos)"
+ print _("---------------- (associating repos)")
self.repo_finder()
- print "---------------- (associating kickstarts)"
+ print _("---------------- (associating kickstarts)")
self.kickstart_finder()
- print "---------------- (syncing)"
+ print _("---------------- (syncing)")
self.api.sync()
return True
@@ -106,10 +106,10 @@ class Importer:
def run_this(self, cmd, args):
my_cmd = cmd % args
- print "- %s" % my_cmd
+ print _("- %s") % my_cmd
rc = sub_process.call(my_cmd,shell=True)
if rc != 0:
- raise cexceptions.CobblerException("Command failed.")
+ raise CX(_("Command failed"))
# ----------------------------------------------------------------------
@@ -124,11 +124,11 @@ class Importer:
for profile in self.profiles:
distro = self.distros.find(profile.distro)
if distro is None or not (distro in self.distros_added):
- print "- skipping distro %s since it wasn't imported this time" % profile.distro
+ print _("- skipping distro %s since it wasn't imported this time") % profile.distro
continue
if not distro.kernel.startswith("%s/ks_mirror/" % self.settings.webdir):
# this isn't a mirrored profile, so we won't touch it
- print "- skipping %s since profile isn't mirrored" % profile.name
+ print _("- skipping %s since profile isn't mirrored") % profile.name
continue
kdir = os.path.dirname(distro.kernel)
@@ -145,9 +145,9 @@ class Importer:
if results is None:
continue
(flavor, major, minor) = results
- print "- determining best kickstart for %s %s" % (flavor, major)
+ print _("- determining best kickstart for %(flavor)s %(major)s") % { "flavor" : flavor, "major" : major }
kickstart = self.set_kickstart(profile, flavor, major, minor)
- print "- kickstart=%s" % kickstart
+ print _("- kickstart=%s") % kickstart
self.configure_tree_location(distro)
self.distros.add(distro) # re-save
self.api.serialize()
@@ -166,12 +166,12 @@ class Importer:
os.symlink(base, dest_link)
except:
# this shouldn't happen but I've seen it ... debug ...
- print "- symlink creation failed: %s, %s" % (base, dest_link)
+ print _("- symlink creation failed: %(base)s, %(dest)s") % { "base" : base, "dest" : dest_link }
base = base.replace(self.settings.webdir,"")
meta = distro.ks_meta
meta["tree"] = "http://%s/cblr/links/%s" % (self.settings.server, distro.name)
- print "- tree: %s" % meta["tree"]
+ print _("- tree: %s") % meta["tree"]
distro.set_ksmeta(meta)
# ---------------------------------------------------------------------
@@ -183,7 +183,7 @@ class Importer:
if flavor == "redhat" or flavor == "centos":
if major >= 5:
return profile.set_kickstart("/etc/cobbler/kickstart_fc6.ks")
- print "- using default kickstart file choice"
+ print _("- using default kickstart file choice")
return profile.set_kickstart("/etc/cobbler/kickstart_fc5.ks")
# ---------------------------------------------------------------------
@@ -257,14 +257,14 @@ class Importer:
def repo_finder(self):
for distro in self.distros_added:
- print "- traversing distro %s" % distro.name
+ print _("- traversing distro %s") % distro.name
if distro.kernel.find("ks_mirror") != -1:
basepath = os.path.dirname(distro.kernel)
top = "/".join(basepath.split("/")[0:-2]) # up one level
- print "- descent into %s" % top
+ print _("- descent into %s") % top
os.path.walk(top, self.repo_scanner, distro)
else:
- print "- this distro isn't mirrored"
+ print _("- this distro isn't mirrored")
# ----------------------------------------------------------------------
@@ -287,18 +287,13 @@ class Importer:
# older distros...
masterdir = "base"
- print "- scanning: %s (distro: %s)" % (comps_path, distro.name)
-
- #repo_file = os.path.join(comps_path, masterdir, "repomd.xml")
- #if not os.path.exists(repo_file):
- # print "- no repomd found here: %s" % repo_file
- # return
+ print _("- scanning: %(path)s (distro: %(name)s)") % { "path" : comps_path, "name" : distro.name }
# figure out what our comps file is ...
- print "- looking for %s/%s/comps*.xml" % (comps_path, masterdir)
+ print _("- looking for %(p1)s/%(p2)s/comps*.xml") % { "p1" : comps_path, "p2" : masterdir }
files = glob.glob("%s/%s/comps*.xml" % (comps_path, masterdir))
if len(files) == 0:
- print "- no comps found here: %s" % os.path.join(comps_path, masterdir)
+ print _("- no comps found here: %s") % os.path.join(comps_path, masterdir)
return # no comps xml file found
# pull the filename from the longer part
@@ -330,7 +325,7 @@ class Importer:
distro.source_repos.append([repo_url,repo_url2])
- print "- url: %s" % repo_url
+ print _("- url: %s") % repo_url
config_file = open(fname, "w+")
config_file.write("[%s]\n" % "core-%s" % counter)
config_file.write("name=%s\n" % "core-%s " % counter)
@@ -345,18 +340,18 @@ class Importer:
utils.remove_yum_olddata(comps_path)
#cmd = "createrepo --basedir / --groupfile %s %s" % (os.path.join(comps_path, masterdir, comps_file), comps_path)
cmd = "createrepo --groupfile %s %s" % (os.path.join(comps_path, masterdir, comps_file), comps_path)
- print "- %s" % cmd
+ print _("- %s") % cmd
sub_process.call(cmd,shell=True)
self.processed_repos[comps_path] = 1
# for older distros, if we have a "base" dir parallel with "repodata", we need to copy comps.xml up one...
p1 = os.path.join(comps_path, "repodata", "comps.xml")
p2 = os.path.join(comps_path, "base", "comps.xml")
if os.path.exists(p1) and os.path.exists(p2):
- print "- cp %s %s" % (p1, p2)
+ print _("- cp %s %s") % (p1, p2)
shutil.copyfile(p1,p2)
except:
- print "- error launching createrepo, ignoring..."
+ print _("- error launching createrepo, ignoring...")
traceback.print_exc()
@@ -367,10 +362,10 @@ class Importer:
existing_distro = self.distros.find(name)
if existing_distro is not None:
- print "- modifying existing distro: %s" % name
+ print _("- modifying existing distro: %s") % name
distro = existing_distro
else:
- print "- creating new distro: %s" % name
+ print _("- creating new distro: %s") % name
distro = self.config.new_distro()
distro.set_name(name)
@@ -384,10 +379,10 @@ class Importer:
existing_profile = self.profiles.find(name)
if existing_profile is None:
- print "- creating new profile: %s" % name
+ print _("- creating new profile: %s") % name
profile = self.config.new_profile()
else:
- print "- modifying existing profile: %s" % name
+ print _("- modifying existing profile: %s") % name
profile = existing_profile
profile.set_name(name)
@@ -442,7 +437,7 @@ class Importer:
if not x.endswith("rpm"):
continue
if x.find("kernel-header") != -1:
- print "- kernel header found: %s" % x
+ print _("- kernel header found: %s") % x
if x.find("i386") != -1:
foo["result"] = "x86"
return
@@ -462,7 +457,7 @@ class Importer:
from differing import sources
"""
dirname2 = "/".join(dirname.split("/")[:-2]) # up two from images, then down as many as needed
- print "- scanning %s for architecture info" % dirname2
+ print _("- scanning %s for architecture info") % dirname2
result = { "result" : "x86" } # default, but possibly not correct ...
os.path.walk(dirname2, self.arch_walker, result)
return result["result"]
diff --git a/cobbler/action_litesync.py b/cobbler/action_litesync.py
index 51369ee..e3d63e6 100644
--- a/cobbler/action_litesync.py
+++ b/cobbler/action_litesync.py
@@ -24,11 +24,9 @@ import yaml # Howell-Clark version
import sub_process
import sys
-import cexceptions
import utils
import action_sync
-import cobbler_msg
-import cexceptions
+from cexceptions import *
import traceback
import errno
@@ -57,7 +55,7 @@ class BootLiteSync:
# get the distro record
distro = self.distros.find(name)
if distro is None:
- raise cexceptions.CobblerException("error in distro lookup: %s" % name)
+ raise CX(_("error in distro lookup: %s") % name)
# generate YAML file in distros/$name in webdir
self.sync.write_distro_file(distro)
# copy image files to images/$name in webdir & tftpboot:
@@ -77,7 +75,7 @@ class BootLiteSync:
# get the profile object:
profile = self.profiles.find(name)
if profile is None:
- raise cexceptions.CobblerException("error in profile lookup")
+ raise CX(_("error in profile lookup"))
# rebuild profile_list YAML file in webdir
self.sync.write_listings()
# add profiles/$name YAML file in webdir
@@ -97,7 +95,7 @@ class BootLiteSync:
# get the system object:
system = self.systems.find(name)
if system is None:
- raise cexceptions.CobblerException("error in system lookup")
+ raise CX(_("error in system lookup"))
# rebuild system_list file in webdir
self.sync.regen_ethers() # /etc/ethers, for dnsmasq & rarpd
self.sync.regen_hosts() # /var/lib/cobbler/cobbler_hosts, pretty much for dnsmasq
diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py
index f144498..0f6cfe2 100644
--- a/cobbler/action_reposync.py
+++ b/cobbler/action_reposync.py
@@ -21,8 +21,7 @@ import sub_process
import sys
import utils
-import cobbler_msg
-import cexceptions
+from cexceptions import *
import traceback
import errno
@@ -81,7 +80,7 @@ class RepoSync:
# RHEL4 and RHEL5U0 don't have it.
if not os.path.exists("/usr/bin/reposync"):
- raise cexceptions.CobblerException("no /usr/bin/reposync found, please install yum-utils")
+ raise CX(_("no /usr/bin/reposync found, please install yum-utils"))
cmds = [] # queues up commands to run
is_rhn = False # RHN repositories require extra black magic
@@ -98,7 +97,7 @@ class RepoSync:
# if so, don't update this one.
if not repo.keep_updated:
- print "- %s is set to not be updated" % repo.name
+ print _("- %s is set to not be updated") % repo.name
return True
# create yum config file for use by reposync
@@ -123,7 +122,7 @@ class RepoSync:
# if we have not requested only certain RPMs, use reposync
cmd = "/usr/bin/reposync --config=%s --repoid=%s --download_path=%s" % (temp_file, repo.name, store_path)
- print "- %s" % cmd
+ print _("- %s") % cmd
cmds.append(cmd)
else:
@@ -136,7 +135,7 @@ class RepoSync:
# FIXME: yumdownloader has a current bug where --resolve blows up
# removing --resolve until I get the email from bugzilla saying it's fixed.
cmd = "/usr/bin/yumdownloader -c %s --destdir=%s %s" %(temp_file, dest_path, " ".join(repo.rpm_list))
- print "- %s" % cmd
+ print _("- %s") % cmd
cmds.append(cmd)
else:
@@ -144,10 +143,10 @@ class RepoSync:
# NOTE: this requires that you have entitlements for the server and you give the mirror as rhn://$channelname
if has_rpm_list:
- print "- warning: --rpm-list is not supported for RHN content"
+ print _("- warning: --rpm-list is not supported for RHN content")
rest = repo.mirror[6:] # everything after rhn://
cmd = "/usr/bin/reposync -r %s --download_path=%s" % (rest, store_path)
- print "- %s" % cmd
+ print _("- %s") % cmd
cmds.append(cmd)
# downloads using -r use the value given for -r as part of the output dir,
@@ -157,7 +156,7 @@ class RepoSync:
if not os.path.exists(dest_path):
from1 = os.path.join(self.settings.webdir, "repo_mirror", rest)
- print "- symlink: %s -> %s" % (from1, dest_path)
+ print _("- symlink: %(from)s -> %(to)s") % { "from" : from1, "to" : dest_path }
os.symlink(from1, dest_path)
# now regardless of whether we're doing yumdownloader or reposync
@@ -167,7 +166,7 @@ class RepoSync:
for cmd in cmds:
rc = sub_process.call(cmd, shell=True)
if rc !=0:
- raise cexceptions.CobblerException("cobbler reposync failed")
+ raise CX(_("cobbler reposync failed"))
# some more special case handling for RHN.
# create the config file now, because the directory didn't exist earlier
@@ -194,10 +193,10 @@ class RepoSync:
"""
if not repo.keep_updated:
- print "- %s is set to not be updated" % repo.name
+ print _("- %s is set to not be updated") % repo.name
return True
if repo.rpm_list != "":
- print "- warning: --rpm-list is not supported for rsync'd repositories"
+ print _("- warning: --rpm-list is not supported for rsync'd repositories")
dest_path = os.path.join(self.settings.webdir, "repo_mirror", repo.name)
spacer = ""
if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
@@ -205,12 +204,12 @@ class RepoSync:
if not repo.mirror.endswith("/"):
repo.mirror = "%s/" % repo.mirror
cmd = "rsync -av %s --delete --delete-excluded --exclude-from=/etc/cobbler/rsync.exclude %s %s" % (spacer, repo.mirror, dest_path)
- print "- %s" % cmd
+ print _("- %s") % cmd
rc = sub_process.call(cmd, shell=True)
if rc !=0:
- raise cexceptions.CobblerException("cobbler reposync failed")
+ raise CX(_("cobbler reposync failed"))
arg = {}
- print "- walking: %s" % dest_path
+ print _("- walking: %s") % dest_path
os.path.walk(dest_path, self.createrepo_walker, arg)
self.create_local_file(repo, dest_path)
@@ -227,7 +226,7 @@ class RepoSync:
fname = os.path.join(dest_path,"config.repo")
else:
fname = os.path.join(dest_path, "%s.repo" % repo.name)
- print "- creating: %s" % fname
+ print _("- creating: %s") % fname
config_file = open(fname, "w+")
config_file.write("[%s]\n" % repo.name)
config_file.write("name=%s\n" % repo.name)
@@ -247,14 +246,14 @@ class RepoSync:
Used to run createrepo on a copied mirror.
"""
target_dir = os.path.dirname(dirname).split("/")[-1]
- print "- scanning: %s" % target_dir
+ print _("- scanning: %s") % target_dir
if target_dir.lower() in [ "i386", "x86_64", "ia64" ] or (arg is None):
utils.remove_yum_olddata(dirname)
try:
cmd = "createrepo %s" % dirname
- print cmd
+ print _("- %s") % cmd
sub_process.call(cmd, shell=True)
except:
- print "- createrepo failed. Is it installed?"
+ print _("- createrepo failed. Is it installed?")
fnames = [] # we're in the right place
diff --git a/cobbler/action_status.py b/cobbler/action_status.py
index 9571d93..69ba734 100644
--- a/cobbler/action_status.py
+++ b/cobbler/action_status.py
@@ -17,7 +17,6 @@ import os
import os.path
import glob
import time
-import cobbler_msg
from rhpl.translate import _, N_, textdomain, utf8
@@ -46,23 +45,18 @@ class BootStatusReport:
data = fh.readline()
while (data is not None and data != ""):
data = fh.readline()
- #print data
tokens = data.split(None)
if len(tokens) < 6:
continue
- #print "----"
ip = tokens[0]
stime = tokens[3].replace("[","")
req = tokens[6]
if req.find("/cblr") == -1:
continue
- #print "%s,%s,%s,%s" % (tokens,ip,time,req)
ttime = time.strptime(stime,"%d/%b/%Y:%H:%M:%S")
- #print ttime
itime = time.mktime(ttime)
if not results.has_key(ip):
results[ip] = {}
- #print "ip (%s) time (%s) req (%s)" % (ip,itime,req)
results[ip][itime] = req
return results
@@ -92,7 +86,6 @@ class BootStatusReport:
if not results.has_key(ip):
results[ip] = {}
- # print "results (%s) (%s) <- %s" % (ip, epoch, request)
results[ip][epoch] = request
return results
@@ -119,8 +112,15 @@ class BootStatusReport:
last_recorded_time = 0
time_collisions = 0
- header = ("Address", "State", "Started", "Last Request", "Seconds", "Log Entries")
- print "%-20s | %-15s | %-25s | %-25s | %-10s | %-6s" % header
+ #header = ("Address", "State", "Started", "Last Request", "Seconds", "Log Entries")
+ print _("%-20(address)s | %-15(state)s | %-25(started)s | %-25(lastreq)s | %-10(seconds)s | %-6(logentries)s") % {
+ "address" : _("Address"),
+ "state" : _("State"),
+ "lastreq" : _("Last Request"),
+ "started" : _("Started"),
+ "seconds" : _("Seconds"),
+ "logentries" : _("Log Entries"),
+ }
for ip in ips:
@@ -153,7 +153,6 @@ class BootStatusReport:
self.generate_report(entries,ip)
- # print entries
return True
@@ -176,7 +175,7 @@ class BootStatusReport:
fcount = 0
if len(rtimes) == 0:
- print "%s: ?" % ip
+ print _("%s: ?") % ip
return
# for each request time the machine has made
@@ -215,6 +214,13 @@ class BootStatusReport:
elapsed_time = "?"
# print the status line for this IP address
- print "%-20s | %-15s | %-25s | %-25s | %-10s | %-6s" % (ip, install_state, display_start, display_last, elapsed_time, fcount)
+ print "%-20(ip)s | %-15(state)s | %-25(start)s | %-25(last)s | %-10(elapsed)s | %-6(fcount)s" % {
+ "ip" : ip,
+ "state" : install_state,
+ "start" : display_start,
+ "last" : display_last,
+ "elapsed" : elapsed_time,
+ "fcount" : fcount
+ }
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 226f5c0..d828f11 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -23,8 +23,7 @@ import sys
import glob
import utils
-import cobbler_msg
-import cexceptions
+from cexceptions import *
import traceback
import errno
@@ -60,7 +59,7 @@ class BootSync:
Using the Check().run_ functions previously is recommended
"""
if not os.path.exists(self.settings.tftpboot):
- raise cexceptions.CobblerException("no_dir",self.settings.tftpboot)
+ raise CX(_("cannot find directory: %s") % self.settings.tftpboot)
# not having a /var/www/cobbler is ok, the app will create it since
# no other package has to own it.
self.clean_trees()
@@ -91,9 +90,9 @@ class BootSync:
service = "dnsmasq"
retcode = self.service(service, "restart")
if retcode != 0:
- print >>sys.stderr, "Warning: %s restart failed" % service
+ print _("Warning: %s restart failed") % service
except OSError, e:
- print >>sys.stderr, "Warning: %s restart failed: " % service, e
+ print _("Warning: %s restart failed: ") % service, e
def copy_koan(self):
"""
@@ -105,7 +104,7 @@ class BootSync:
if koan_path is None or koan_path == "":
return
if not os.path.isfile(koan_path):
- raise cexceptions.CobblerException("exc_koan_path")
+ raise CX(_("missing koan, check koan_path in /var/lib/cobbler/settings"))
base = os.path.basename(koan_path)
self.copyfile(koan_path, os.path.join(self.settings.webdir, base))
@@ -131,7 +130,6 @@ class BootSync:
settings_file = self.settings.dhcpd_conf
template_file = "/etc/cobbler/dhcp.template"
mode = self.settings.manage_dhcp_mode.lower()
- # print "my mode is: %s" % mode
if mode == "dnsmasq":
settings_file = self.settings.dnsmasq_conf
template_file = "/etc/cobbler/dnsmasq.template"
@@ -139,7 +137,7 @@ class BootSync:
try:
f2 = open(template_file,"r")
except:
- raise cexceptions.CobblerException("exc_no_template",template_file)
+ raise CX(_("error writing template to file: %s") % template_file)
template_data = ""
template_data = f2.read()
f2.close()
@@ -202,7 +200,6 @@ class BootSync:
"next_server" : self.settings.next_server,
"elilo" : elilo
}
- # print "writing to: %s" % settings_file
self.apply_template(template_data, metadata, settings_file)
def regen_ethers(self):
@@ -275,7 +272,7 @@ class BootSync:
"""
# copy is a 4-letter word but tftpboot runs chroot, thus it's required.
for d in self.distros:
- print "sync distro: %s" % d.name
+ print _("sync distro: %s") % d.name
self.copy_single_distro_files(d)
def copy_single_distro_files(self, d):
@@ -286,9 +283,9 @@ class BootSync:
kernel = utils.find_kernel(d.kernel) # full path
initrd = utils.find_initrd(d.initrd) # full path
if kernel is None or not os.path.isfile(kernel):
- raise cexceptions.CobblerException("sync_kernel", d.kernel, d.name)
+ raise CX(_("kernel not found: %s"), d.kernel, d.name)
if initrd is None or not os.path.isfile(initrd):
- raise cexceptions.CobblerException("sync_initrd", d.initrd, d.name)
+ raise CX(_("initrd not found: %s"), d.initrd, d.name)
b_kernel = os.path.basename(kernel)
b_initrd = os.path.basename(initrd)
self.copyfile(kernel, os.path.join(distro_dir, b_kernel))
@@ -321,13 +318,13 @@ class BootSync:
"""
for g in self.profiles:
- print "sync profile: %s" % g.name
+ print _("sync profile: %s") % g.name
self.validate_kickstart_for_specific_profile(g)
def validate_kickstart_for_specific_profile(self,g):
distro = self.distros.find(g.distro)
if distro is None:
- raise cexceptions.CobblerException("orphan_distro2", g.name, g.distro)
+ raise CX(_("profile %(profile)s references missing distro %(distro)s") % { "profile" : g.name, "distro" : g.distro })
kickstart_path = utils.find_kickstart(g.kickstart)
if kickstart_path is not None and os.path.exists(g.kickstart):
# the input is an *actual* file, hence we have to copy it
@@ -350,7 +347,7 @@ class BootSync:
except:
traceback.print_exc() # leave this in, for now...
msg = "err_kickstart2"
- raise cexceptions.CobblerException(msg,kickstart_path,dest)
+ raise CX(_("Error copying kickstart file %(src)s to %(dest)s") % { "src" : kickstart_path, "dest" : dest })
def generate_kickstart_signal(self, obj, is_system=False):
pattern = "wget http://%s/cblr/watcher.py?%s_%s=%s -b"
@@ -421,13 +418,13 @@ class BootSync:
"""
for s in self.systems:
- print "sync system: %s" % s.name
+ print _("sync system: %s") % s.name
self.validate_kickstart_for_specific_system(s)
def validate_kickstart_for_specific_system(self,s):
profile = self.profiles.find(s.profile)
if profile is None:
- raise cexceptions.CobblerException("orphan_profile2",s.name,s.profile)
+ raise CX(_("system %(system)s references missing profile %(profile)s") % { "system" : s.name, "profile" : s.profile })
distro = self.distros.find(profile.distro)
kickstart_path = utils.find_kickstart(profile.kickstart)
if kickstart_path and os.path.exists(kickstart_path):
@@ -451,8 +448,7 @@ class BootSync:
self.apply_template(kfile, meta, dest)
kfile.close()
except:
- msg = "err_kickstart2"
- raise cexceptions.CobblerException(msg,s.kickstart,dest)
+ raise CX(_("Error templating file %s to %s") % { "src" : s.kickstart, "dest" : dest })
def apply_template(self, data_input, metadata, out_path):
"""
@@ -510,10 +506,10 @@ class BootSync:
profile = self.profiles.find(system.profile)
if profile is None:
- raise cexceptions.CobblerException("orphan_profile2",system.name,system.profile)
+ raise CX(_("system %s references a missing profile %s") % { "system" : system.name, "profile" : system.profile})
distro = self.distros.find(profile.distro)
if distro is None:
- raise cexceptions.CobblerException("orphan_distro2",system.profile,profile.distro)
+ raise CX(_("profile %s references a missing distro %s") % { "profile" : system.profile, "distro" : profile.distro})
f1 = self.get_pxe_filename(system.name)
# tftp only
@@ -526,7 +522,7 @@ class BootSync:
# elilo expects files to be named "$name.conf" in the root
# and can not do files based on the MAC address
if system.pxe_address == "" or system.pxe_address is None or not utils.is_ip(system.pxe_address):
- raise cexceptions.CobblerException("exc_ia64_noip",system.name)
+ raise CX(_("Itanium system object names must be MAC addresses"))
filename = "%s.conf" % self.get_pxe_filename(system.pxe_address)
@@ -563,7 +559,7 @@ class BootSync:
elif utils.is_mac(name):
return "01-" + "-".join(name.split(":")).lower()
else:
- raise cexceptions.CobblerException("err_resolv", name)
+ raise CX(_("System name for %s is not an MAC, IP, or resolvable host") % name)
def make_pxe_menu(self):
# only do this if there is NOT a system named default.
@@ -656,7 +652,7 @@ class BootSync:
if not is_ia64:
append_line = "%s initrd=%s" % (append_line, initrd_path)
if len(append_line) >= 255 + len("append "):
- print "warning: kernel option length exceeds 255"
+ print _("warning: kernel option length exceeds 255")
# ---
# kickstart path rewriting (get URLs for local files)
@@ -794,8 +790,6 @@ class BootSync:
self.close_file(fd)
def tee(self,fd,text):
- #if self.verbose:
- # print text
fd.write(text)
def open_file(self,filename,mode):
@@ -806,11 +800,11 @@ class BootSync:
def copyfile(self,src,dst):
if self.verbose:
- print "%s -> %s" % (src,dst)
+ print _("copy: %(src)s -> %(dst)s") % { "src" : src, "dest" : dst }
try:
return shutil.copyfile(src,dst)
except IOError, ioe:
- raise cexceptions.CobblerException("need_perms2",src,dst)
+ raise CX(_("Error copying %(src) to %(dst)") % { "src" : src, "dst" : dst})
def rmfile(self,path):
try:
@@ -819,7 +813,7 @@ class BootSync:
except OSError, ioe:
if not ioe.errno == errno.ENOENT: # doesn't exist
traceback.print_exc()
- raise cexceptions.CobblerException("no_delete",path)
+ raise CX(_("Error deleting %s") % path)
return True
def rmtree_contents(self,path):
@@ -829,7 +823,7 @@ class BootSync:
def rmtree(self,path):
if self.verbose:
- print "del %s" % (path)
+ print _("del %s") % (path)
try:
if os.path.isfile(path):
return self.rmfile(path)
@@ -838,19 +832,19 @@ class BootSync:
except OSError, ioe:
traceback.print_exc()
if not ioe.errno == errno.ENOENT: # doesn't exist
- raise cexceptions.CobblerException("no_delete",path)
+ raise CX(_("Error deleting %s") % path)
return True
def mkdir(self,path,mode=0777):
if self.verbose:
- print "mkdir %s" % (path)
+ print _("mkdir %s") % (path)
try:
return os.makedirs(path,mode)
except OSError, oe:
if not oe.errno == 17: # already exists (no constant for 17?)
traceback.print_exc()
print oe.errno
- raise cexceptions.CobblerException("no_create", path)
+ raise CX(_("Error creating") % path)
def service(self, name, action):
"""
diff --git a/cobbler/api.py b/cobbler/api.py
index 212305a..fe35751 100644
--- a/cobbler/api.py
+++ b/cobbler/api.py
@@ -22,7 +22,6 @@ import action_enchant
import action_import
import action_reposync
import action_status
-import cexceptions
class BootAPI:
diff --git a/cobbler/cexceptions.py b/cobbler/cexceptions.py
index a6e03dc..bed420e 100644
--- a/cobbler/cexceptions.py
+++ b/cobbler/cexceptions.py
@@ -13,20 +13,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import exceptions
-import cobbler_msg
-
-from rhpl.translate import _, N_, textdomain, utf8
-
class CobblerException(exceptions.Exception):
def __init__(self, value, *args):
- """
- This is a translatable exception. value is an entry in cobbler_msg's
- lookup table, args will be used for string substitution, if provided
- """
- self.value = cobbler_msg.lookup(value) % args
+ self.value = value % args
def __str__(self):
return repr(self.value)
+class CX(CobblerException):
+ pass
+
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index 1264d23..fda1772 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -20,8 +20,7 @@ import os
import os.path
import traceback
-import cobbler_msg
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
I18N_DOMAIN = "cobbler"
@@ -29,6 +28,8 @@ I18N_DOMAIN = "cobbler"
LOCKING_ENABLED = True
LOCKFILE="/var/lib/cobbler/lock"
+USAGE = _("see 'man cobbler' for instructions")
+
class BootCLI:
@@ -117,7 +118,7 @@ class BootCLI:
"""
Print out abbreviated help if user gives bad syntax
"""
- print cobbler_msg.USAGE
+ print USAGE
###########################################################
@@ -165,7 +166,7 @@ class BootCLI:
self.system_report([])
match = True
if not match and a is not None and a != "":
- raise cexceptions.CobblerException("unknown_cmd",a)
+ raise CX(_("cobbler does not understand '%(command)s'") % { "command" : a })
match = False
#############################################
@@ -174,21 +175,26 @@ class BootCLI:
def list(self,args):
# FIXME: inefficient
for d in self.api.distros():
- print "distribution : %s" % d.name
+ str = _("distribution : %(distro)s") % { "distro" : d.name }
+ print str
for p in self.api.profiles():
if p.distro == d.name:
- print " profile : %s" % p.name
+ str = _(" profile : %(profile)s") % { "profile" : p.name }
+ print str
for s in self.api.systems():
if s.profile == p.name:
- print " system : %s" % s.name
+ str = _(" system : %(system)s") % { "system" : s.name }
+ print str
for r in self.api.repos():
- print "repo : %s" % r.name
+ str = _("repo : %(repo)s") % { "repo" : r.name }
+ print str
def __list_names(self, collection):
names = [ x.name for x in collection]
names.sort() # sorted() is 2.4 only
for name in names:
- print " %s" % name
+ str = _(" %(name)s") % { "name" : name }
+ print str
return True
def __list_names2(self, collection, args):
@@ -265,16 +271,16 @@ class BootCLI:
obj = collection_fn().find(self.find_arg(args,"--name"))
name2 = self.find_arg(args,"--newname")
if name2 is not None:
- raise cexceptions.CobblerException("no_rename")
+ raise CX("objects cannot be renamed with the edit command, use 'rename'")
if obj is None:
- raise cexceptions.CobblerException(exc_msg)
+ raise CX(exc_msg)
control_fn(args,obj)
def __generic_copy(self,args,collection_fn,control_fn,exc_msg):
obj = collection_fn().find(self.find_arg(args,"--name"))
obj2 = self.find_arg(args,"--newname")
if obj is None:
- raise cexceptions.CobblerException(exc_msg)
+ raise CX(exc_msg)
args = self.replace_names(args, obj2)
obj3 = obj.make_clone()
obj3.set_name(obj2)
@@ -283,10 +289,10 @@ class BootCLI:
def __generic_rename(self,args,collection_fn,control_fn,exc_msg):
objname = self.find_arg(args,"--name")
if objname is None:
- raise cexceptions.CobblerException("bad_param")
+ raise CX(_("at least one required parameter is missing. See 'man cobbler'."))
objname2 = self.find_arg(args,"--newname")
if objname2 is None:
- raise cexceptions.CobblerException("bad_param")
+ raise CX(_("at least one required parameter is missing. See 'man cobbler'."))
self.__generic_copy(args,collection_fn,control_fn,exc_msg)
if objname != objname2:
collection_fn().remove(objname, with_delete=self.api.sync_flag)
@@ -319,46 +325,58 @@ class BootCLI:
# COPY FUNCTIONS
def distro_copy(self,args):
- self.__generic_copy(args,self.api.distros,self.__distro_control,"no_distro")
+ exc = _("distribution does not exist")
+ self.__generic_copy(args,self.api.distros,self.__distro_control,exc)
def profile_copy(self,args):
- self.__generic_copy(args,self.api.profiles,self.__profile_control,"no_profile")
+ exc = _("profile does not exist")
+ self.__generic_copy(args,self.api.profiles,self.__profile_control,exc)
def system_copy(self,args):
- self.__generic_copy(args,self.api.systems,self.__system_control,"no_system")
+ exc = _("system does not exist")
+ self.__generic_copy(args,self.api.systems,self.__system_control,exc)
def repo_copy(self,args):
- self.__generic_copy(args,self.api.repos,self.__repo_control,"no_repo")
+ exc = _("repository does not exist")
+ self.__generic_copy(args,self.api.repos,self.__repo_control,exc)
#####################################################################
# RENAME FUNCTIONS
def distro_rename(self,args):
- self.__generic_rename(args,self.api.distros,self.__distro_control,"no_distro")
+ exc = _("distribution does not exist")
+ self.__generic_rename(args,self.api.distros,self.__distro_control,exc)
def profile_rename(self,args):
- self.__generic_rename(args,self.api.profiles,self.__profile_control,"no_profile")
+ exc = _("profile does not exist")
+ self.__generic_rename(args,self.api.profiles,self.__profile_control,exc)
def system_rename(self,args):
- self.__generic_rename(args,self.api.systems,self.__system_control,"no_system")
+ exc = _("system does not exist")
+ self.__generic_rename(args,self.api.systems,self.__system_control,exc)
def repo_rename(self,args):
- self.__generic_rename(args,self.api.repos,self.__repo_control,"no_repo")
+ exc = _("repository does not exist")
+ self.__generic_rename(args,self.api.repos,self.__repo_control,exc)
#####################################################################
# EDIT FUNCTIONS
def distro_edit(self,args):
- self.__generic_edit(args,self.api.distros,self.__distro_control,"no_distro")
+ exc = _("distribution does not exist")
+ self.__generic_edit(args,self.api.distros,self.__distro_control,exc)
def profile_edit(self,args):
- self.__generic_edit(args,self.api.profiles,self.__profile_control,"no_profile")
+ exc = _("profile does not exist")
+ self.__generic_edit(args,self.api.profiles,self.__profile_control,exc)
def system_edit(self,args):
- self.__generic_edit(args,self.api.systems,self.__system_control,"no_system")
+ exc = _("system does not exist")
+ self.__generic_edit(args,self.api.systems,self.__system_control,exc)
def repo_edit(self,args):
- self.__generic_edit(args,self.api.repos,self.__repo_control,"no_repo")
+ exc = _("repository does not exist")
+ self.__generic_edit(args,self.api.repos,self.__repo_control,exc)
#####################################################################
# ADD FUNCTIONS
@@ -472,17 +490,17 @@ class BootCLI:
that parse the arguments. See distro_edit for an example.
"""
if len(args) == 0:
- raise cexceptions.CobblerException("no_args")
+ raise CX(_("this command requires arguments"))
for x in args:
try:
key, value = x.split("=",1)
value = value.replace('"','').replace("'",'')
except:
- raise cexceptions.CobblerException("bad_arg",x)
+ raise CX(_("Cobbler was expecting an equal sign in argument '%(argument)s'") % { "argument" : x })
if input_routines.has_key(key):
input_routines[key](value)
else:
- raise cexceptions.CobblerException("weird_arg", key)
+ raise CX(_("this command doesn't take an option called '%(argument)s'") % { "argument" : key })
on_ok()
self.api.serialize()
@@ -492,12 +510,12 @@ class BootCLI:
feed it the remaining args[1:-1] as arguments.
"""
if args is None or len(args) == 0:
- print cobbler_msg.USAGE
+ print USAGE
return True
if args[0] in commands:
commands[args[0]](args[1:])
else:
- raise cexceptions.CobblerException("unknown_cmd", args[0])
+ raise CX(_("Cobbler does not understand '%(command)s'") % { "command" : args[0] })
return True
################################################
@@ -534,12 +552,15 @@ class BootCLI:
"""
status = self.api.check()
if len(status) == 0:
- print cobbler_msg.lookup("check_ok")
+ print _("No setup problems found")
+ print _("Manual review and editing of /var/lib/cobbler/settings is recommended to tailor cobbler to your particular configuration.")
+ print _("Good luck.")
+
return True
else:
- print cobbler_msg.lookup("need_to_fix")
+ print _("The following potential problems were detected:")
for i,x in enumerate(status):
- print "#%d: %s" % (i,x)
+ print _("#%(number)d: %(problem)s") % { "number" : i, "problem" : x }
return False
def status(self,args):
@@ -578,7 +599,7 @@ class BootCLI:
elif a.lower() in [ "1", "true", "yes", "y", "on" ]:
self.is_virt = True
else:
- raise cexceptions.CobblerException("reject_arg","virt")
+ raise CX("reject_arg","virt")
def set_profile(a):
self.temp_profile = a
def set_system(a):
@@ -660,18 +681,18 @@ def main():
if LOCKING_ENABLED:
if os.path.exists(LOCKFILE):
lock_hit = True
- raise cexceptions.CobblerException("lock")
+ raise CX(_("Locked. If cobbler is currently running, wait for termination, otherwise remove /var/lib/cobbler/lock"))
try:
lockfile = open(LOCKFILE,"w+")
except:
- raise cexceptions.CobblerException("no_create",LOCKFILE)
+ raise CX(_("Cobbler could not create the lockfile %(lockfile)s. Are you root?") % { "lockfile" : lockfile })
lockfile.close()
BootCLI(sys.argv).run()
- except cexceptions.CobblerException, exc:
+ except CobblerException, exc:
print str(exc)[1:-1] # remove framing air quotes
exitcode = 1
except KeyboardInterrupt:
- print "interrupted."
+ print _("interrupted.")
exitcode = 1
except Exception, other:
traceback.print_exc()
@@ -684,5 +705,4 @@ def main():
return exitcode
if __name__ == "__main__":
- print _("Testing")
sys.exit(main())
diff --git a/cobbler/cobbler_msg.py b/cobbler/cobbler_msg.py
deleted file mode 100644
index a98ca77..0000000
--- a/cobbler/cobbler_msg.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# -*- coding: iso-8859-15 -*-
-
-"""
-Messages used by cobbler.
-This module encapsulates strings so they can
-be reused and potentially translated.
-
-Copyright 2006, Red Hat, Inc
-Michael DeHaan <mdehaan@redhat.com>
-
-This software may be freely redistributed under the terms of the GNU
-general public license.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-"""
-
-from rhpl.translate import _, N_, textdomain, utf8
-
-
-USAGE = """cobbler provisioning tool
-basic usage guide / see "man cobbler" for more.
-
-cobbler check
-
-cobbler distro add --name=<string> --kernel=<path> --initrd=<path>
- [--kopts=<string>] [--ksmeta=<string>] [--arch=<x86|x86_64|ia64>]
-
-cobbler profile add --name=<string> --distro=<string>
- [--kick-start=<url>] [--kopts=<string>] [--ksmeta=<string>]
- [--virt-file-size=<gigabytes>]
- [--virt-ram=<megabytes>]
-
-cobbler system add --name=<ip│mac│hostname|default> --profile=<string>
- [--pxe-address=<string>]
- [--ksmeta=<string>]
-
-cobbler import --name=<string> --mirror=rsync://<address>
-cobbler import --name=<string> --mirror=user@address:/path
-cobbler import --name=<string> --mirror=<path>
-
-cobbler repo add --name=<string> --mirror=rsync://<address> [--local-file=name]
-cobbler repo add --name=<string> --mirror=user@address:/path [--local-file=name]
-cobbler reposync
-
-cobbler [distro|profile|system] remove --name=<name>
-
-cobbler list
-
-cobbler sync
-
-cobbler enchant --address=<ip|hostname> [--profile=<string>|--system=<string>]
-
-cobbler status
-"""
-
-_msg_table = {
- "system" : "System",
- "profile" : "Profile",
- "distribution" : "Distribution",
- "bad_server" : "The 'server' field in /var/lib/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it",
- "bad_next" : "For PXE to be functional, the 'next_server' field in /var/lib/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.",
- "parse_error" : "cobbler could not read %s, replacing...",
- "no_ssh" : "cobbler can't read ~/.ssh/id_dsa.pub",
- "exc_koan_path" : "koan_path in /var/lib/cobbler/settings is invalid",
- "no_rename" : "objects can not be renamed using the edit command",
- "no_create" : "cobbler could not create: %s",
- "no_delete" : "cobbler could not delete: %s",
- "no_args" : "this command requires arguments.",
- "missing_options" : "cannot perform this action, more arguments are required",
- "enchant_failed" : "enchant failed (%s)",
- "import_failed" : "import failed (%s)",
- "unknown_cmd" : "cobbler doesn't understand '%s'",
- "bad_arg" : "cobbler was expecting an equal sign in argument '%s'",
- "reject_arg" : "the value of parameter '%s' isn't valid",
- "weird_arg" : "this command doesn't take a parameter named '%s'",
- "bad_sys_name" : "system name must be a MAC, IP, or resolveable host",
- "bad_ip" : "argument must be an IP address",
- "need_to_fix" : "the following potential problems were detected:",
- "need_perms" : "cobbler could not access %s",
- "need_perms2" : "cobbler could not copy %s to %s",
- "no_dhcpd" : "cobbler couldn't find dhcpd, try 'yum install dhcp'",
- "no_dnsmasq" : "cobbler couldn't find dnsmasq, try 'yum install dnsmasq'",
- "dhcp_choice" : "manage_dhcp_mode in /var/lib/cobbler/settings should be 'isc' or 'dnsmasq'",
- "no_bootloader" : "missing 1 or more bootloader files listed in /var/lib/cobbler/settings",
- "no_tftpd" : "cobbler couldn't find tftpd, try 'yum install tftpd-server'",
- "no_dir" : "cobbler couldn't find %s, please create it",
- "no_mirror" : "mirror URL is not valid",
- "chg_attrib" : "need to change field '%s' value to '%s' in file '%s'",
- "no_exist" : "file %s does not exist",
- "no_exist2" : "path %s does not exist",
- "no_next_server" : "file '%s' should have a next-server line",
- "no_filename" : "file '%s' should have a filename line",
- "no_dir2" : "can't find %s for %s as referenced in /var/lib/cobbler/settings",
- "bad_param" : "at least one parameter is missing for this function",
- "empty_list" : "There are no configured %s records.",
- "err_resolv" : "The system name (%s) did not resolve",
- "err_kickstart" : "The kickstart (%s) for item (%s) is not valid",
- "err_kickstart2" : "Error while mirroring kickstart file (%s) to (%s)",
- "orphan_profile" : "Removing this system would break profile '%s'",
- "orphan_profile2" : "system (%s) references a non-existant profile (%s)",
- "orphan_distro2" : "profile (%s) references a non-existant distro (%s)",
- "orphan_system" : "Removing this profile would break system '%s'",
- "delete_nothing" : "can't delete something that doesn't exist",
- "no_distro" : "distro does not exist",
- "no_system" : "system does not exist",
- "no_repo" : "repository %s does not exist",
- "no_repos" : "one of the listed repositories is not defined in cobbler",
- "no_profile" : "profile does not exist",
- "no_kickstart" : "kickstart must be an absolute path, or an http://, ftp:// or nfs:// URL",
- "no_kernel" : "cannot find kernel file",
- "sync_kernel" : "the kernel (%s) for distro (%s) cannot be found and must be fixed",
- "sync_initrd" : "the initrd (%s) for distro (%s) cannot be found and must be fixed",
- "sync_mirror_ks" : "mirroring local kickstarts...",
- "sync_buildtree" : "building trees",
- "sync_processing" : "processing: %s",
- "writing" : "writing file: %s",
- "mkdir" : "creating: %s",
- "copying" : "copying file: %s to %s",
- "removing" : "removing: %s",
- "no_initrd" : "cannot find initrd",
- "exc_breed" : "invalid breed: try redhat or suse",
- "exc_virt_name" : "invalid name for virtual image",
- "exc_virt_file" : "invalid file size for virtual image",
- "exc_virt_ram" : "invalid RAM size for virtual image",
- "exc_virt_mac" : "invalid MAC address for virtual image",
- "exc_virt_para" : "invalid paravirtualization setting",
- "exc_profile" : "invalid profile name",
- "exc_profile2" : "profile name not set",
- "exc_pxe_arch" : "valid PXE architectures: standard or ia64",
- "exc_no_template" : "can't read template file (%s)",
- "exc_dhcp_nomac" : "when cobbler is managing dhcpd.conf, all system names must be MAC addresses. Aborting.",
- "exc_ia64_noip" : "due to an IA64 bootloader limitation, system (%s) must define a pxe-address value (which is an IP address)",
- "exc_kopts" : "Kernel options should be a space delimited list of values and key=value pairs",
- "lock" : "Locked. If cobbler is currently running, wait for termination, otherwise remove /var/lib/cobbler/lock",
- "check_ok" : """
-No setup problems found.
-
-Manual review and editing of /var/lib/cobbler/settings is recommended to tailor cobbler to your particular configuration.
-
-Good luck.
-"""
-}
-
-def lookup(key):
- """
- Return the lookup of a string key.
- """
- if _msg_table.has_key(key):
- return _msg_table[key]
- return key
diff --git a/cobbler/collection.py b/cobbler/collection.py
index e740c19..5e265fc 100644
--- a/cobbler/collection.py
+++ b/cobbler/collection.py
@@ -13,18 +13,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import exceptions
-import cexceptions
+from cexceptions import *
import serializable
import utils
import glob
import sub_process
-import cobbler_msg
import action_litesync
import item_system
import item_profile
import item_distro
+from rhpl.translate import _, N_, textdomain, utf8
+
class Collection(serializable.Serializable):
def __init__(self,config):
@@ -86,7 +87,7 @@ class Collection(serializable.Serializable):
won't be added to the collection).
"""
if ref is None or not ref.is_valid():
- raise cexceptions.CobblerException("bad_param")
+ raise CX(_("invalid parameter"))
self.listing[ref.name] = ref
# perform filesystem operations
@@ -99,7 +100,7 @@ class Collection(serializable.Serializable):
elif isinstance(ref, item_distro.Distro):
lite_sync.add_single_distro(ref.name)
else:
- print "AIEEE ??? %s " % type(ref)
+ print _("Internal error. Object type not recognized: %s") % type(ref)
# save the tree, so if neccessary, scripts can examine it.
self.config.api.serialize()
@@ -127,7 +128,7 @@ class Collection(serializable.Serializable):
if len(values) > 0:
return "\n\n".join(results)
else:
- return cobbler_msg.lookup("empty_list") % cobbler_msg.lookup(self.collection_type())
+ return _("No objects found")
def __iter__(self):
"""
diff --git a/cobbler/collection_distros.py b/cobbler/collection_distros.py
index dfcf8d4..3fe45ed 100644
--- a/cobbler/collection_distros.py
+++ b/cobbler/collection_distros.py
@@ -16,7 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import utils
import collection
import item_distro as distro
-import cexceptions
+from cexceptions import *
import action_litesync
from rhpl.translate import _, N_, textdomain, utf8
@@ -49,7 +49,7 @@ class Distros(collection.Collection):
# first see if any Groups use this distro
for v in self.config.profiles():
if v.distro == name:
- raise cexceptions.CobblerException("orphan_profile",v.name)
+ raise CX(_("removal would orphan profile: %s") % v.name)
if self.find(name):
if with_delete:
lite_sync = action_litesync.BootLiteSync(self.config)
@@ -57,5 +57,5 @@ class Distros(collection.Collection):
self._run_triggers(self.listing[name], "/var/lib/cobbler/triggers/delete/distro/*")
del self.listing[name]
return True
- raise cexceptions.CobblerException("delete_nothing")
+ raise CX(_("cannot delete object that does not exist"))
diff --git a/cobbler/collection_profiles.py b/cobbler/collection_profiles.py
index 8a43b0e..cd1d104 100644
--- a/cobbler/collection_profiles.py
+++ b/cobbler/collection_profiles.py
@@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import item_profile as profile
import utils
import collection
-import cexceptions
+from cexceptions import *
import action_litesync
from rhpl.translate import _, N_, textdomain, utf8
@@ -47,7 +47,7 @@ class Profiles(collection.Collection):
"""
for v in self.config.systems():
if v.profile == name:
- raise cexceptions.CobblerException("orphan_system",v.name)
+ raise CX(_("removal would orphan system: %s") % v.name)
if self.find(name):
if with_delete:
lite_sync = action_litesync.BootLiteSync(self.config)
@@ -55,5 +55,5 @@ class Profiles(collection.Collection):
self._run_triggers(self.listing[name], "/var/lib/cobbler/triggers/delete/profile/*")
del self.listing[name]
return True
- raise cexceptions.CobblerException("delete_nothing")
+ raise CX(_("cannot delete an object that does not exist"))
diff --git a/cobbler/collection_repos.py b/cobbler/collection_repos.py
index 6596a66..922a1ad 100644
--- a/cobbler/collection_repos.py
+++ b/cobbler/collection_repos.py
@@ -17,7 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import item_repo as repo
import utils
import collection
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
@@ -57,5 +57,5 @@ class Repos(collection.Collection):
self._run_triggers(self.listing[name], "/var/lib/cobbler/triggers/delete/repo/*")
del self.listing[name]
return True
- raise cexceptions.CobblerException("delete_nothing")
+ raise CX(_("cannot delete an object that does not exist"))
diff --git a/cobbler/collection_systems.py b/cobbler/collection_systems.py
index a336487..4eff2fb 100644
--- a/cobbler/collection_systems.py
+++ b/cobbler/collection_systems.py
@@ -16,11 +16,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import item_system as system
import utils
import collection
-import cexceptions
+from cexceptions import *
import action_litesync
from rhpl.translate import _, N_, textdomain, utf8
-
TESTMODE = False
#--------------------------------------------
@@ -56,6 +55,6 @@ class Systems(collection.Collection):
self._run_triggers(self.listing[name], "/var/lib/cobbler/triggers/delete/system/*")
del self.listing[name]
return True
- raise cexceptions.CobblerException("delete_nothing")
+ raise CX(_("cannot delete an object that does not exist"))
diff --git a/cobbler/item.py b/cobbler/item.py
index d4be1c7..d2981e0 100644
--- a/cobbler/item.py
+++ b/cobbler/item.py
@@ -15,6 +15,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import exceptions
import serializable
import utils
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
class Item(serializable.Serializable):
@@ -45,7 +46,7 @@ class Item(serializable.Serializable):
"""
(success, value) = utils.input_string_or_hash(options,None)
if not success:
- raise cexceptions.CobblerException("exc_kopts")
+ raise CX(_("invalid kernel options"))
else:
self.kernel_options = value
return True
diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py
index 40a8a7e..5051ff7 100644
--- a/cobbler/item_distro.py
+++ b/cobbler/item_distro.py
@@ -18,19 +18,12 @@ import utils
import item
import weakref
import os
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
class Distro(item.Item):
- #def __init__(self,config):
- # """
- # Constructor. Requires a back reference to the Config management object.
- # """
- # self.config = config
- # self.clear()
-
def clear(self):
"""
Reset this object.
@@ -81,13 +74,13 @@ class Distro(item.Item):
if utils.find_kernel(kernel):
self.kernel = kernel
return True
- raise cexceptions.CobblerException("no_kernel")
+ raise CX(_("kernel not found"))
def set_breed(self, breed):
if breed is not None and breed.lower() in [ "redhat", "suse" ]:
self.breed = breed.lower()
return True
- raise cexceptions.CobblerException("exc_breed")
+ raise CX(_("invalid value for --breed, see manpage"))
def set_initrd(self,initrd):
"""
@@ -97,7 +90,7 @@ class Distro(item.Item):
if utils.find_initrd(initrd):
self.initrd = initrd
return True
- raise cexceptions.CobblerException("no_initrd")
+ raise CX(_("initrd not found"))
def set_source_repos(self, repos):
"""
@@ -127,7 +120,7 @@ class Distro(item.Item):
if arch in [ "standard", "ia64", "x86", "x86_64" ]:
self.arch = arch
return True
- raise cexceptions.CobblerException("exc_pxe_arch")
+ raise CX(_("PXE arch choices include: x86, x86_64, and ia64"))
def is_valid(self):
"""
@@ -168,12 +161,12 @@ class Distro(item.Item):
# istr = "%s (NOT FOUND)" % self.initrd
#elif os.path.isdir(self.initrd):
# istr = "%s (FOUND BY SEARCH)" % istr
- buf = "distro : %s\n" % self.name
- buf = buf + "kernel : %s\n" % kstr
- buf = buf + "initrd : %s\n" % istr
- buf = buf + "kernel options : %s\n" % self.kernel_options
- buf = buf + "architecture : %s\n" % self.arch
- buf = buf + "ks metadata : %s\n" % self.ks_meta
- buf = buf + "breed : %s\n" % self.breed
+ buf = _("distro : %s\n") % self.name
+ buf = buf + _("kernel : %s\n") % kstr
+ buf = buf + _("initrd : %s\n") % istr
+ buf = buf + _("kernel options : %s\n") % self.kernel_options
+ buf = buf + _("architecture : %s\n") % self.arch
+ buf = buf + _("ks metadata : %s\n") % self.ks_meta
+ buf = buf + _("breed : %s\n") % self.breed
return buf
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 9e5f23d..4ad53fc 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -14,19 +14,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import utils
import item
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
class Profile(item.Item):
- #def __init__(self,config):
- # """
- # Constructor. Requires a backreference to Config.
- # """
- # self.config = config
- # self.settings = self.config.settings()
-
def make_clone(self):
ds = self.to_datastruct()
cloned = Profile(self.config)
@@ -44,7 +37,6 @@ class Profile(item.Item):
self.ks_meta = {}
self.virt_file_size = 5 # GB. 5 = Decent _minimum_ default for FC5.
self.virt_ram = 512 # MB. Install with 256 not likely to pass
- self.virt_paravirt = True # hvm support is *NOT* in Koan (now)
self.repos = "" # names of cobbler repo definitions
def from_datastruct(self,seed_data):
@@ -66,7 +58,6 @@ class Profile(item.Item):
# virt specific
self.virt_ram = self.load_item(seed_data,'virt_ram')
self.virt_file_size = self.load_item(seed_data,'virt_file_size')
- self.virt_paravirt = self.load_item(seed_data,'virt_paravirt')
# backwards compatibility -- convert string entries to dicts for storage
if type(self.kernel_options) != dict:
@@ -84,7 +75,7 @@ class Profile(item.Item):
if self.config.distros().find(distro_name):
self.distro = distro_name
return True
- raise cexceptions.CobblerException("no_distro")
+ raise CX(_("distribution not found"))
def set_repos(self,repos):
if type(repos) != list:
@@ -104,7 +95,7 @@ class Profile(item.Item):
if ok:
self.repos = repolist
else:
- raise cexceptions.CobblerException("no_repos")
+ raise CX(_("repository not found"))
def set_kickstart(self,kickstart):
"""
@@ -114,7 +105,7 @@ class Profile(item.Item):
if utils.find_kickstart(kickstart):
self.kickstart = kickstart
return True
- raise cexceptions.CobblerException("no_kickstart")
+ raise CX(_("kickstart not found"))
def set_virt_file_size(self,num):
"""
@@ -129,13 +120,13 @@ class Profile(item.Item):
try:
inum = int(num)
if inum != float(num):
- return cexceptions.CobblerException("exc_virt_file")
+ return CX(_("invalid virt file size"))
if inum >= 0:
self.virt_file_size = inum
return True
- return cexceptions.CobblerException("exc_virt_file")
+ raise CX(_("invalid virt file size"))
except:
- return cexceptions.CobblerException("exc_virt_file")
+ raise CX(_("invalid virt file size"))
def set_virt_ram(self,num):
"""
@@ -147,34 +138,13 @@ class Profile(item.Item):
try:
inum = int(num)
if inum != float(num):
- return cexceptions.CobblerException("exc_virt_ram")
+ return CX(_("invalid virt ram size"))
if inum >= 0:
self.virt_ram = inum
return True
- return cexceptions.CobblerException("exc_virt_ram")
- except:
- return cexceptions.CobblerException("exc_virt_ram")
-
- def set_virt_paravirt(self,truthiness):
- """
- For Virt only.
- Specifies whether the system is a paravirtualized system or not.
- For ordinary computers, you want to pick 'true'. Method accepts string
- 'true'/'false' in all cases, or Python True/False.
- """
- # truthiness needs to be True or False, or (lcased) string equivalents
- # yes, we *do* want to explicitly test against True/False
- # the string "foosball" is True, and that is not a valid argument for this function
- try:
- if (not truthiness or truthiness.lower() == 'false'):
- self.virt_paravirt = False
- elif (truthiness or truthiness.lower() == 'true'):
- self.virt_paravirt = True
- else:
- return cexceptions.CobblerException("exc_virt_para")
+ return CX(_("invalid virt ram size"))
except:
- return cexceptions.CobblerException("exc_virt_para")
- return True
+ return CX(_("invalid virt ram size"))
def is_valid(self):
"""
@@ -198,7 +168,6 @@ class Profile(item.Item):
'kernel_options' : self.kernel_options,
'virt_file_size' : self.virt_file_size,
'virt_ram' : self.virt_ram,
- 'virt_paravirt' : self.virt_paravirt,
'ks_meta' : self.ks_meta,
'repos' : self.repos
}
@@ -207,14 +176,13 @@ class Profile(item.Item):
"""
A human readable representaton
"""
- buf = "profile : %s\n" % self.name
- buf = buf + "distro : %s\n" % self.distro
- buf = buf + "kickstart : %s\n" % self.kickstart
- buf = buf + "kernel options : %s\n" % self.kernel_options
- buf = buf + "ks metadata : %s\n" % self.ks_meta
- buf = buf + "virt file size : %s\n" % self.virt_file_size
- buf = buf + "virt ram : %s\n" % self.virt_ram
- buf = buf + "virt paravirt : %s\n" % self.virt_paravirt
- buf = buf + "repos : %s\n" % self.repos
+ buf = _("profile : %s\n") % self.name
+ buf = buf + _("distro : %s\n") % self.distro
+ buf = buf + _("kickstart : %s\n") % self.kickstart
+ buf = buf + _("kernel options : %s\n") % self.kernel_options
+ buf = buf + _("ks metadata : %s\n") % self.ks_meta
+ buf = buf + _("virt file size : %s\n") % self.virt_file_size
+ buf = buf + _("virt ram : %s\n") % self.virt_ram
+ buf = buf + _("repos : %s\n") % self.repos
return buf
diff --git a/cobbler/item_repo.py b/cobbler/item_repo.py
index 9592ad2..be2ffa4 100644
--- a/cobbler/item_repo.py
+++ b/cobbler/item_repo.py
@@ -14,12 +14,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import utils
import item
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
-# TODO: if distribution is detected FC6 or greater, auto-add the mirror stanza
-# to the kickstart.
-
class Repo(item.Item):
def make_clone(self):
@@ -121,10 +118,10 @@ class Repo(item.Item):
}
def printable(self):
- buf = "repo : %s\n" % self.name
- buf = buf + "mirror : %s\n" % self.mirror
- buf = buf + "keep updated : %s\n" % self.keep_updated
- buf = buf + "local filename : %s\n" % self.local_filename
- buf = buf + "rpm list : %s\n" % self.rpm_list
+ buf = _("repo : %s\n") % self.name
+ buf = buf + _("mirror : %s\n") % self.mirror
+ buf = buf + _("keep updated : %s\n") % self.keep_updated
+ buf = buf + _("local filename : %s\n") % self.local_filename
+ buf = buf + _("rpm list : %s\n") % self.rpm_list
return buf
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index 10a9593..cb6b5c8 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -14,16 +14,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import utils
import item
-import cexceptions
+from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
class System(item.Item):
- #def __init__(self,config):
- # self.config = config
- # self.clear()
-
def make_clone(self):
ds = self.to_datastruct()
cloned = System(self.config)
@@ -67,7 +63,7 @@ class System(item.Item):
return True
new_name = utils.find_system_identifier(name)
if not new_name:
- raise cexceptions.CobblerException("bad_sys_name")
+ raise CX(_("system name must be an MAC address, IP, or resolvable host"))
self.name = name # we check it add time, but store the original value.
return True
@@ -100,7 +96,7 @@ class System(item.Item):
if self.config.profiles().find(profile_name):
self.profile = profile_name
return True
- raise cexceptions.CobblerException("exc_profile")
+ raise CX(_("invalid profile name"))
def set_netboot_enabled(self,netboot_enabled):
"""
@@ -145,11 +141,11 @@ class System(item.Item):
}
def printable(self):
- buf = "system : %s\n" % self.name
- buf = buf + "profile : %s\n" % self.profile
- buf = buf + "kernel options : %s\n" % self.kernel_options
- buf = buf + "ks metadata : %s\n" % self.ks_meta
- buf = buf + "ip address : %s\n" % self.pxe_address
- buf = buf + "hostname : %s\n" % self.hostname
+ buf = _("system : %s\n") % self.name
+ buf = buf + _("profile : %s\n") % self.profile
+ buf = buf + _("kernel options : %s\n") % self.kernel_options
+ buf = buf + _("ks metadata : %s\n") % self.ks_meta
+ buf = buf + _("ip address : %s\n") % self.pxe_address
+ buf = buf + _("hostname : %s\n") % self.hostname
return buf
diff --git a/cobbler/serializer.py b/cobbler/serializer.py
index b74d6aa..a8a3e73 100644
--- a/cobbler/serializer.py
+++ b/cobbler/serializer.py
@@ -16,7 +16,7 @@ import yaml # Howell-Clark version
import errno
import os
-import cexceptions
+from cexceptions import *
import utils
from rhpl.translate import _, N_, textdomain, utf8
@@ -38,11 +38,11 @@ def serialize(obj):
os.makedirs(dirname)
# evidentally this doesn't throw exceptions.
except OSError, ose:
- raise cexceptions.CobblerException("need_perms", os.path.dirname(dirname))
+ raise CX(_("Need permissions to write to %s") % os.path.dirname(dirname))
try:
fd = open(filename,"w+")
except IOError, ioe3:
- raise cexceptions.CobblerException("need_perms", filename)
+ raise CX(_("Need permissions to write to %s") % filename)
return False
datastruct = obj.to_datastruct()
encoded = yaml.dump(datastruct)
@@ -66,12 +66,9 @@ def deserialize(obj):
if not os.path.exists(filename):
return True
else:
- raise cexceptions.CobblerException("need_perms",obj.filename())
+ raise CX(_("Need permissions to read %s") % obj.filename())
data = fd.read()
datastruct = yaml.load(data).next() # first record
- # leftover from PySyck choke detection. Not relevant?
- # if type(datastruct) == str:
- # raise CobblerException("parse_error",filename)
fd.close()
obj.from_datastruct(datastruct)
return True
diff --git a/cobbler/settings.py b/cobbler/settings.py
index 406da12..6919fe8 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -75,8 +75,8 @@ class Settings(serializable.Serializable):
def printable(self):
buf = ""
- buf = buf + "defaults\n"
- buf = buf + "kernel options : %s\n" % self._attributes['kernel_options']
+ buf = buf + _("defaults\n")
+ buf = buf + _("kernel options : %s\n") % self._attributes['kernel_options']
return buf
def to_datastruct(self):
@@ -90,7 +90,7 @@ class Settings(serializable.Serializable):
Modify this object to load values in datastruct.
"""
if datastruct is None:
- print "warning: not loading empty structure for %s" % self.filename()
+ print _("warning: not loading empty structure for %s") % self.filename()
return
self._attributes = datastruct
return self
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 3acf4c6..9868975 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -162,7 +162,7 @@ def remove_yum_olddata(path):
for pathseg in trythese:
olddata = os.path.join(path, pathseg)
if os.path.exists(olddata):
- print "- removing: %s" % olddata
+ print _("- removing: %s") % olddata
shutil.rmtree(olddata, ignore_errors=False, onerror=None)
def find_initrd(path):
diff --git a/tests/tests.py b/tests/tests.py
index 93bb5b2..e2b41e1 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -191,9 +191,6 @@ class Additions(BootTest):
# temporarily commenting out failing test
# self.failUnlessRaises(CobblerException, profile.set_virt_file_size, "huge")
# self.failUnlessRaises(CobblerException, profile.set_virt_file_size, "54321.23")
- # paravirt must be 'true' or 'false'
- self.assertTrue(profile.set_virt_paravirt(False))
- self.assertTrue(profile.set_virt_paravirt(True))
self.assertTrue(self.api.profiles().add(profile))
def test_invalid_system_bad_name_host(self):