diff options
-rw-r--r-- | CHANGELOG | 4 | ||||
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | cobbler.pod | 5 | ||||
-rw-r--r-- | cobbler.spec | 6 | ||||
-rw-r--r-- | cobbler/action_enchant.py | 36 | ||||
-rw-r--r-- | cobbler/api.py | 10 | ||||
-rwxr-xr-x | cobbler/cobbler.py | 63 | ||||
-rw-r--r-- | cobbler/cobbler_msg.py | 2 | ||||
-rw-r--r-- | setup.py | 2 |
9 files changed, 85 insertions, 59 deletions
@@ -1,6 +1,10 @@ Cobbler CHANGELOG (all entries mdehaan@redhat.com unless noted otherwise) +* Tue Oct 17 2006 - 0.2.7-1 +- Removed pexpect to enhance support for other distros +- enchant syntax changed (see NEWS) + * Tue Oct 17 2006 - 0.2.6-1 - Removing Cheetah and replacing w/ simpler templating system - Don't delete localmirror on sync @@ -1,6 +1,22 @@ Cobbler NEWS (all entries mdehaan@redhat.com unless noted otherwise) +====================================================== +0.2.7 -- pexpect no longer required, "enchant" changes +====================================================== + +In order to make Cobbler work on more platforms, the dependancy on +pexpect (a python module) has been removed. SSH is now invoked directly. +This means Cobbler now builds very easily on RHEL 4. + +As a result, this means that to run "enchant" a remote system, that +system needs to have the cobbler server in the /root/.ssh/authorized_keys +file. Removing password functionality is more secure and should be +considered goodness. + +In addition, the arguments to "enchant" have changed. See the manpage +for details. + =================================== 0.2.6 -- Cheetah no longer required =================================== diff --git a/cobbler.pod b/cobbler.pod index b17d2bc..4111f90 100644 --- a/cobbler.pod +++ b/cobbler.pod @@ -266,11 +266,12 @@ The dhcpd.conf file will be updated each time "cobbler sync" is run. While the normal provisioning procedure is either to PXE bare-metal, or use koan to do something else (kickstart an existing system or deploy Xen), cobbler contains yet another option, called "enchant". -Enchant takes a system configuration that has already been defined (be sure to run "cobbler sync" before using "cobbler enchant") and applies it to a remote system that may not have koan installed. This is all done from the cobbler server using SSH. The remote system will reboot prior to configuring the bootloader to kickstart. +Enchant takes a configuration that has already been defined (be sure to run "cobbler sync" before using "cobbler enchant") and applies it to a remote system that may not have koan installed. Running "enchant" will replace the operating system of the target machine, so use it with caution. -Usage: B<cobbler system enchant --name=<ip|hostname> [--password=<string>]> +Usage: B<cobbler enchant --address=<ip|hostname> --profile=<string>> +Usage: B<cobbler enchant --address=<ip|hostname> --system=<string>> =head2 IMPORTING TREES diff --git a/cobbler.spec b/cobbler.spec index 1c604a5..ba5e57e 100644 --- a/cobbler.spec +++ b/cobbler.spec @@ -2,7 +2,7 @@ Summary: Boot server configurator Name: cobbler -Version: 0.2.6 +Version: 0.2.7 Release: 1%{?dist} Source0: %{name}-%{version}.tar.gz License: GPL @@ -10,7 +10,6 @@ Group: Applications/System Requires: python >= 2.3 Requires: httpd Requires: tftp-server -Requires: pexpect BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildArch: noarch ExcludeArch: ppc @@ -55,6 +54,9 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT %changelog +* Tue Oct 17 2006 Michael DeHaan <mdehaan@redhat.com> - 0.2.7-1 +- Upstream changes (see CHANGELOG), includes removing pexpect as a require + * Tue Oct 17 2006 Michael DeHaan <mdehaan@redhat.com> - 0.2.6-1 - Upstream changes (see CHANGELOG), includes removing Cheetah as a require diff --git a/cobbler/action_enchant.py b/cobbler/action_enchant.py index c3d71b3..8e9835e 100644 --- a/cobbler/action_enchant.py +++ b/cobbler/action_enchant.py @@ -17,14 +17,19 @@ import cexceptions import os import os.path import pexpect -import pxssh +# GOING AWAY +# import pxssh +import sub_process import traceback class Enchant: - def __init__(self,config,sysname,password=''): + def __init__(self,config,sysname,profile): """ - Constructor. If password is None it should rely on SSH key auth. + 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() @@ -33,15 +38,12 @@ class Enchant: if sysname is None: raise cexceptions.CobblerException("enchant_failed","no system name specified") self.profile = '' - self.password = password - def call(self,cmd): + def ssh_exec(self,cmd): """ - Invoke something over SSH. + Invoke an SSH command. """ - print "ssh -> %s" % cmd - self.ssh.sendline(cmd) - self.ssh.prompt() + sub_process.call("ssh root:%s %s" % (self.sysname,cmd),shell=True) def run(self): """ @@ -60,17 +62,11 @@ class Enchant: raise cexceptions.CobblerException("enchant_failed","koan is missing") try: - ssh = self.ssh = pxssh.pxssh() - if not ssh.login(self.sysname, self.username, self.password): - raise cexceptions.CobblerException("enchant_failed","SSH login denied") - else: - self.call("wget http://%s/cobbler/%s" % (self.settings.server, koan)) - # nodeps allows installation on older pythons - # koan will move to /usr/share/koan shortly - self.call("rpm -Uvh %s --force --nodeps" % koan) - self.call("koan --replace-self --profile=%s --server=%s" % (self.profile, self.settings.server)) - #self.call("/sbin/reboot") - return True + self.ssh_exec(self.sysname, "wget http://%s/cobbler/%s" % (self.settings.server, koan)) + self.ssh_exec(self.sysname, "rpm -Uvh %s --force --nodeps" % koan)) + self.ssh_exec(self.sysname, "koan --replace-self --profile=%s --server=%s" % (self.profile, self.settings.server)) + # self.ssh_exec(self.sysname, "/sbin/reboot") + return True except: traceback.print_exc() raise cexceptions.CobblerException("enchant_failed","exception") diff --git a/cobbler/api.py b/cobbler/api.py index bc95a29..0282c43 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -108,12 +108,14 @@ class BootAPI: sync = action_sync.BootSync(self._config) return sync.run(dryrun=dryrun) - def enchant(self,sysname,password): + def enchant(self,address,profile,systemdef): """ - Apply a system profile to a running remote system, replacing - the current OS. + 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. """ - enchant = action_enchant.Enchant(self._config,sysname,password) + enchant = action_enchant.Enchant(self._config,address,profile,systemdef) return enchant.run() def import_tree(self,tree_path,mirror_url,mirror_name): diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index 8d23dbc..7ff3fcd 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -48,27 +48,27 @@ class BootCLI: 'remove' : self.profile_remove, } self.commands['system'] = { - 'add' : self.system_edit, - 'edit' : self.system_edit, - 'delete' : self.system_remove, - 'remove' : self.system_remove, - 'enchant' : self.system_enchant, - 'transmogrify' : self.system_enchant + 'add' : self.system_edit, + 'edit' : self.system_edit, + 'delete' : self.system_remove, + 'remove' : self.system_remove, } self.commands['toplevel'] = { - 'check' : self.check, - 'list' : self.list, - 'distros' : self.distro, - 'distro' : self.distro, - 'profiles' : self.profile, - 'profile' : self.profile, - 'systems' : self.system, - 'system' : self.system, - 'sync' : self.sync, - 'import' : self.import_tree, - 'help' : self.usage, - '--help' : self.usage, - '/?' : self.usage + 'check' : self.check, + 'list' : self.list, + 'distros' : self.distro, + 'distro' : self.distro, + 'profiles' : self.profile, + 'profile' : self.profile, + 'systems' : self.system, + 'system' : self.system, + 'sync' : self.sync, + 'import' : self.import_tree, + 'enchant' : self.enchant, + 'transmogrify' : self.enchant, + 'help' : self.usage, + '--help' : self.usage, + '/?' : self.usage } def run(self): @@ -125,24 +125,29 @@ class BootCLI: return self.apply_args(args,commands,on_ok) - def system_enchant(self,args): + def enchant(self,args): """ Reinstall a system: 'cobbler system enchant --name='foo' [--password='foo'] """ - self.temp_password = '' - self.temp_name = '' - def set_password(a): - self.temp_password = a + self.temp_profile = None + self.temp_system = None + self.temp_address = None + def set_profile(a): + self.temp_profile = a return True - def set_name(a): - self.temp_name = a + def set_system(a): + self.temp_system = a + return True + def set_address(a): + self.temp_address = a return True def go_enchant(): - return self.api.enchant(self.temp_name,self.temp_password) + return self.api.enchant(self.temp_address,self.temp_profile,self.temp_system) commands = { - '--name' : lambda(a): set_name(a), - '--password' : lambda(a): set_password(a), + '--address' : lambda(a): set_address(a), + '--profile' : lambda(a): set_profile(a), + '--system' : lambda(a): set_system(a) } on_ok = lambda: go_enchant() return self.apply_args(args,commands,on_ok) diff --git a/cobbler/cobbler_msg.py b/cobbler/cobbler_msg.py index d9d904d..a77e537 100644 --- a/cobbler/cobbler_msg.py +++ b/cobbler/cobbler_msg.py @@ -42,7 +42,7 @@ cobbler list cobbler sync -cobbler system enchant --name=<string> [--password=<string>] +cobbler enchant --address=<ip|hostname> [--profile=<string>|--system=<string>] """ _msg_table = { @@ -4,7 +4,7 @@ import sys from distutils.core import setup, Extension import string -VERSION = "0.2.6" +VERSION = "0.2.7" SHORT_DESC = "Boot server configurator" LONG_DESC = """ Cobbler is a command line tool for simplified configuration of boot/provisioning servers. It is also accessible as a Python library. Cobbler supports PXE, Xen, and re-provisioning an existing Linux system via auto-kickstart. The last two modes require 'koan' to be run on the remote system. |