def handleHeader(self, lineno, args):
kssections.Section.handleHeader(self, lineno, args)
+def apply_wrapper(func):
+ def wrapper(*kargs, **kwargs):
+ try:
+ func(*kargs, **kwargs)
+ except (OSError, IOError, errors.KsError), err:
+ cfgcls = kargs[0].__class__.__name__
+ if msger.ask("Failed to apply %s, skip and continue?" % cfgcls):
+ msger.warning("%s" % err)
+ pass
+ else:
+ # just throw out the exception
+ raise
+ return wrapper
+
def read_kickstart(path):
"""Parse a kickstart file and return a KickstartParser instance.
def call(self, args):
if not os.path.exists("%s/%s" %(self.instroot, args[0])):
- msger.warning("%s/%s" %(self.instroot, args[0]))
- raise errors.KsError("Unable to run %s!" %(args))
+ raise errors.KsError("Can't find %s in chroot" % args[0])
subprocess.call(args, preexec_fn = self.chroot)
def apply(self):
class LanguageConfig(KickstartConfig):
"""A class to apply a kickstart language configuration to a system."""
+ @apply_wrapper
def apply(self, kslang):
self._check_sysconfig()
if kslang.lang:
class KeyboardConfig(KickstartConfig):
"""A class to apply a kickstart keyboard configuration to a system."""
+ @apply_wrapper
def apply(self, kskeyboard):
#
# FIXME:
class TimezoneConfig(KickstartConfig):
"""A class to apply a kickstart timezone configuration to a system."""
+ @apply_wrapper
def apply(self, kstimezone):
self._check_sysconfig()
tz = kstimezone.timezone or "America/New_York"
class AuthConfig(KickstartConfig):
"""A class to apply a kickstart authconfig configuration to a system."""
+ @apply_wrapper
def apply(self, ksauthconfig):
auth = ksauthconfig.authconfig or "--useshadow --enablemd5"
args = ["/usr/share/authconfig/authconfig.py", "--update", "--nostart"]
class FirewallConfig(KickstartConfig):
"""A class to apply a kickstart firewall configuration to a system."""
+ @apply_wrapper
def apply(self, ksfirewall):
#
# FIXME: should handle the rest of the options
preexec_fn = self.chroot)
p2.communicate()
+ @apply_wrapper
def apply(self, ksrootpw):
if ksrootpw.isCrypted:
self.set_encrypted(ksrootpw.password)
raise errors.KsError("Invalid kickstart command: %s" \
% userconfig.__str__())
+ @apply_wrapper
def apply(self, user):
for userconfig in user.userList:
try:
class ServicesConfig(KickstartConfig):
"""A class to apply a kickstart services configuration to a system."""
+ @apply_wrapper
def apply(self, ksservices):
if not os.path.exists(self.path("/sbin/chkconfig")):
return
class XConfig(KickstartConfig):
"""A class to apply a kickstart X configuration to a system."""
+ @apply_wrapper
def apply(self, ksxconfig):
if ksxconfig.startX and os.path.exists(self.path("/etc/inittab")):
f = open(self.path("/etc/inittab"), "rw+")
class DesktopConfig(KickstartConfig):
"""A class to apply a kickstart desktop configuration to a system."""
+ @apply_wrapper
def apply(self, ksdesktop):
if ksdesktop.defaultdesktop:
self._check_sysconfig()
self.__create_repo_section(repo, "source", f)
f.close()
+ @apply_wrapper
def apply(self, ksrepo, repodata):
for repo in ksrepo.repoList:
if repo.save:
class RPMMacroConfig(KickstartConfig):
"""A class to apply the specified rpm macros to the filesystem"""
+ @apply_wrapper
def apply(self, ks):
if not ks:
return
f.close()
+ @apply_wrapper
def apply(self, ksnet):
fs.makedirs(self.path("/etc/sysconfig/network-scripts"))