From 26263db30e0ad51f0cabfcc6f7dde92d04cdcfbb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 5 Sep 2007 14:54:48 -0400 Subject: removed deprecated enchant function/module (just use SSH!), config file cleanup. --- cobbler/action_enchant.py | 112 ---------------------------------------------- cobbler/action_sync.py | 15 ------- cobbler/api.py | 12 ----- cobbler/cobbler.py | 36 --------------- cobbler/settings.py | 58 +++++++++++++----------- 5 files changed, 31 insertions(+), 202 deletions(-) delete mode 100644 cobbler/action_enchant.py (limited to 'cobbler') diff --git a/cobbler/action_enchant.py b/cobbler/action_enchant.py deleted file mode 100644 index 4a54ebe..0000000 --- a/cobbler/action_enchant.py +++ /dev/null @@ -1,112 +0,0 @@ -""" -Enables the "cobbler enchant" command to apply profiles -to remote systems, whether or not they are running koan. - -Copyright 2006, Red Hat, Inc -Michael DeHaan - -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 cexceptions import * -import os -import os.path -import sub_process -import traceback -from rhpl.translate import _, N_, textdomain, utf8 - - -class Enchant: - - def __init__(self,config,address,profile,system,is_virt): - """ - Constructor. - config: a configuration reference (see api module) - sysname: address of system to enchant (not necc. defined in cobbler) - profile: profile to make the system become - """ - self.config = config - self.settings = self.config.settings() - self.address = address - self.profile = profile - self.system = system - self.is_virt = is_virt - if address is None: - raise CX(_("enchant failed. no address specified")) - if system is None and profile is None: - raise CX(_("enchant failed. no profile specified")) - if system is not None and self.config.systems().find(name=system) is None: - raise CX(_("enchant failed. system not found")) - if profile is not None and self.config.profiles().find(name=profile) is None: - raise CX(_("enchant failed. profile name not found")) - - - def ssh_exec(self,cmd,catch_fail=True): - """ - Invoke an SSH command. - -o 'HostKeyAlias NoHostKeyStorage' - """ - cmd2 = "ssh -o 'StrictHostKeyChecking=no' -o 'HostKeyAlias nocobblerhostkey' root@%s %s" % (self.address,cmd) - print "running: %s" % cmd2 - rc = sub_process.call(cmd2,shell=True) - print "returns: %d" % rc - if catch_fail and rc != 0: - raise CX(_("enchant failed. SSH error.")) - - def run(self): - """ - Replace the OS of a remote system. - """ - - # clean out known hosts file to eliminate conflicts - known_hosts = open("/root/.ssh/known_hosts","r") - data = known_hosts.read() - known_hosts.close() - known_hosts = open("/root/.ssh/known_hosts","w+") - for line in data.split("\n"): - if not line.startswith("nocobblerhostkey"): - known_hosts.write(line) - known_hosts.write("\n") - known_hosts.close() - - # make sure the koan rpm is present, if it's not there, user didn't run sync first - # or it's not configured in /var/lib/cobbler/settings - 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 CX(_("koan_path is not correct in /var/lib/cobbler/settings, or need to run 'cobbler sync'.")) - - try: - self.ssh_exec("wget http://%s/cobbler/%s" % (self.settings.server, koan)) - # koan doesn't require libvirt-python, but uses it for koan --virt options if available - # so, if --virt is requested, we have to make sure it's installed. It's probably - # reasonable to just assume it /IS/ installed though as Xen kernel usage is required. - extra_virt_packages = "" - if self.is_virt: - extra_virt_packages = " libvirt-python libvirt" - # package installation without knowing whether the target is yum-based or not - self.ssh_exec("up2date install syslinux%s" % (extra_virt_packages), catch_fail=False) - self.ssh_exec("yum -y install syslinux%s" % (extra_virt_packages), catch_fail=False) - self.ssh_exec("rpm -Uvh %s --force --nodeps" % koan) - # choose SSH command line based on whether this command was given --virt or not - operation = "--replace-self" - if self.is_virt: - operation = "--virt" - if self.system: - self.ssh_exec("koan %s --system=%s --server=%s" % (operation, self.system, self.settings.server)) - else: - self.ssh_exec("koan %s --profile=%s --server=%s" % (operation, self.profile, self.settings.server)) - # don't have to reboot for virt installs - if not self.is_virt: - self.ssh_exec("/sbin/reboot") - return True - except: - traceback.print_exc() - raise CX(_("enchant failed. an exception occurred.")) - return False # shouldn't be here - diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index c5621c6..12be718 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -62,7 +62,6 @@ class BootSync: if not os.path.exists(self.settings.tftpboot): raise CX(_("cannot find directory: %s") % self.settings.tftpboot) self.clean_trees() - self.copy_koan() self.copy_bootloaders() self.copy_distros() self.validate_kickstarts() @@ -93,20 +92,6 @@ class BootSync: except OSError, e: print _("Warning: %s restart failed: ") % service, e - def copy_koan(self): - """ - This is just for the "enchant" feature which a lot of folks - probably don't use... enchant automates an SSH into a remote - system, including koan installation if need be. - """ - koan_path = self.settings.koan_path - if koan_path is None or koan_path == "": - return - if not os.path.isfile(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)) - def copy_bootloaders(self): """ Copy bootloaders to the configured tftpboot directory diff --git a/cobbler/api.py b/cobbler/api.py index 6b22d30..f5d3322 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -18,7 +18,6 @@ import config import utils import action_sync import action_check -import action_enchant import action_import import action_reposync import action_status @@ -41,7 +40,6 @@ class BootAPI: self._config = config.Config(self) self.deserialize() self.__settings = self._config.settings() - self.sync_flag = self.__settings.minimize_syncs def version(self): """ @@ -198,16 +196,6 @@ class BootAPI: reposync = action_reposync.RepoSync(self._config) return reposync.run() - def enchant(self,address,profile,systemdef,is_virt): - """ - Re-kickstart a running system. - Either profile or systemdef should be a name of a - profile or system definition, the other should be None. address is an - address reachable by SSH. - """ - enchanter = action_enchant.Enchant(self._config,address,profile,systemdef,is_virt) - return enchanter.run() - def status(self,mode): statusifier = action_status.BootStatusReport(self._config, mode) return statusifier.run() diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index 4436a43..7ecb2d6 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -101,9 +101,6 @@ class BootCLI: 'sync' : self.sync, 'reposync' : self.reposync, 'import' : self.import_tree, - 'enchant' : self.enchant, - 'clobber' : self.enchant, - 'transmogrify' : self.enchant, 'status' : self.status, 'reserialize' : self.reserialize, 'help' : self.usage, @@ -635,39 +632,6 @@ class BootCLI: return self.api.status(self.mode) return self.apply_args(args, commands, go_status) - def enchant(self,args): - """ - Reinstall a system: - 'cobbler system enchant --name='foo' [--password='foo'] - """ - self.temp_profile = None - self.temp_system = None - self.temp_address = None - self.is_virt = False - def set_is_virt(a): - if a.lower() in [ "0", "false", "no", "n", "off" ]: - self.is_virt = False - elif a.lower() in [ "1", "true", "yes", "y", "on" ]: - self.is_virt = True - else: - raise CX("reject_arg","virt") - def set_profile(a): - self.temp_profile = a - def set_system(a): - self.temp_system = a - def set_address(a): - self.temp_address = a - def go_enchant(): - return self.api.enchant(self.temp_address,self.temp_profile,self.temp_system,self.is_virt) - commands = { - '--address' : lambda(a): set_address(a), - '--profile' : lambda(a): set_profile(a), - '--system' : lambda(a): set_system(a), - '--virt' : lambda(a): set_is_virt(a) - } - on_ok = lambda: go_enchant() - return self.apply_args(args,commands,on_ok) - def import_tree(self,args): """ Import a directory tree and auto-create distros & profiles. diff --git a/cobbler/settings.py b/cobbler/settings.py index d2e4b39..f8b32e6 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -19,37 +19,41 @@ from rhpl.translate import _, N_, textdomain, utf8 TESTMODE = False DEFAULTS = { - "httpd_bin" : "/usr/sbin/httpd", - "dhcpd_conf" : "/etc/dhcpd.conf", - "dnsmasq_conf" : "/etc/dnsmasq.conf", - "tftpd_bin" : "/usr/sbin/in.tftpd", - "server" : "127.0.0.1", - "next_server" : "127.0.0.1", - "dhcpd_bin" : "/usr/sbin/dhcpd", - "dnsmasq_bin" : "/usr/sbin/dnsmasq", - "kernel_options" : { - "lang" : " ", - "text" : None, - "ksdevice" : "eth0", + "bootloaders" : { + "standard" : "/usr/lib/syslinux/pxelinux.0", + "ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi" }, - "tftpd_conf" : "/etc/xinetd.d/tftp", - "tftpboot" : "/tftpboot", - "webdir" : "/var/www/cobbler", - "snippetsdir" : "/var/lib/cobbler/snippets", - "default_kickstart" : "/etc/cobbler/default.ks", - "manage_dhcp" : 0, - "manage_dhcp_mode" : "isc", - "koan_path" : "", - "bootloaders" : { - "standard" : "/usr/lib/syslinux/pxelinux.0", - "ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi" + "default_kickstart" : "/etc/cobbler/default.ks", + "default_virt_type" : "auto", + "dhcpd_conf" : "/etc/dhcpd.conf", + "dhcpd_bin" : "/usr/sbin/dhcpd", + "dnsmasq_bin" : "/usr/sbin/dnsmasq", + "dnsmasq_conf" : "/etc/dnsmasq.conf", + "httpd_bin" : "/usr/sbin/httpd", + "kernel_options" : { + "lang" : " ", + "text" : None, + "ksdevice" : "eth0", + }, + "manage_dhcp" : 0, + "manage_dhcp_mode" : "isc", + "next_server" : "127.0.0.1", + "pxe_just_once" : 0, + "server" : "127.0.0.1", + "snippetsdir" : "/var/lib/cobbler/snippets", + "storage_modules" : { + "distros" : [ 'yaml' ], + "profiles" : [ 'yaml' ], + "systems" : [ 'yaml' ], + "repos" : [ 'yaml' ], }, "syslog_port" : 25150, + "tftpboot" : "/tftpboot", + "tftpd_bin" : "/usr/sbin/in.tftpd", + "tftpd_conf" : "/etc/xinetd.d/tftp", + "webdir" : "/var/www/cobbler", "xmlrpc_port" : 25151, - "minimize_syncs" : 1, - "yum_core_mirror_from_server" : 0, - "default_virt_type" : "auto", - "pxe_just_once" : 0 + "yum_core_mirror_from_server" : 0 } -- cgit