summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-09-29 12:49:17 -0400
committerJim Meyering <jim@meyering.net>2006-09-29 12:49:17 -0400
commit1d9b0343abaf2b23e177e3c56f19f182f2299182 (patch)
tree2d1320a4e4fcb8ce00cb0ed6d94c47af253badd7 /cobbler
parent810c7e39285c17803cfdad2909b4bec79762055c (diff)
downloadthird_party-cobbler-1d9b0343abaf2b23e177e3c56f19f182f2299182.tar.gz
third_party-cobbler-1d9b0343abaf2b23e177e3c56f19f182f2299182.tar.xz
third_party-cobbler-1d9b0343abaf2b23e177e3c56f19f182f2299182.zip
Commiting the (working) enchant feature and associated changes to enable
it. Some error handling is needed but it's functional. See NEWS and manpage for documentation on enchant.
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_enchant.py16
-rw-r--r--cobbler/action_sync.py6
-rw-r--r--cobbler/api.py5
-rwxr-xr-xcobbler/cobbler.py11
-rw-r--r--cobbler/cobbler_msg.py2
5 files changed, 15 insertions, 25 deletions
diff --git a/cobbler/action_enchant.py b/cobbler/action_enchant.py
index a71e04a..dcf583d 100644
--- a/cobbler/action_enchant.py
+++ b/cobbler/action_enchant.py
@@ -23,7 +23,7 @@ import traceback
class Enchant:
- def __init__(self,config,sysname,profile,system,password):
+ def __init__(self,config,sysname,profile,password):
"""
Constructor. All arguments required.
"""
@@ -32,7 +32,6 @@ class Enchant:
self.username = "root"
self.sysname = sysname
self.profile = profile
- self.system = system
self.password = password
def call(self,cmd):
@@ -47,19 +46,16 @@ class Enchant:
"""
Replace the OS of a remote system.
"""
+ koan = os.path.basename(self.settings.koan_path)
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/koan.rpm -o /koan.rpm" % self.settings.server)
- self.call("rpm -Uvh koan.rpm --force")
- if self.profile is not None:
- self.call("koan --replace-self --profile=%s --server=%s" % (self.profile, self.settings.server))
- return True
- if self.system is not None:
- self.call("koan --replace-self --system=%s --server=%s" % (self.system, self.settings.server))
- return True
+ self.call("wget http://%s/cobbler/%s" % (self.settings.server, koan))
+ self.call("rpm -Uvh %s --force" % koan)
+ self.call("koan --replace-self --profile=%s --server=%s" % (self.profile, self.settings.server))
+ return True
except:
traceback.print_exc()
return False
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index d7cd1a1..2b3e23a 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -59,12 +59,12 @@ class BootSync:
self.verbose = verbose
self.dryrun = dryrun
self.clean_trees()
+ self.copy_koan()
self.copy_bootloaders()
self.copy_distros()
self.validate_kickstarts()
self.configure_httpd()
self.build_trees()
- self.copy_koan()
if self.settings.manage_dhcp:
self.write_dhcp_file()
try:
@@ -77,11 +77,13 @@ class BootSync:
def copy_koan(self):
koan_path = self.settings.koan_path
+ print "koan path = %s" % koan_path
if koan_path is None:
return
if not os.path.isfile(koan_path):
raise cexceptions.CobblerException("exc_koan_path")
- self.copyfile(koan_path, os.path.join(self.settings.webdir, "koan.rpm"))
+ base = os.path.basename(koan_path)
+ self.copyfile(koan_path, os.path.join(self.settings.webdir, base))
def copy_bootloaders(self):
"""
diff --git a/cobbler/api.py b/cobbler/api.py
index ffb25ba..8208a80 100644
--- a/cobbler/api.py
+++ b/cobbler/api.py
@@ -107,11 +107,10 @@ class BootAPI:
sync = action_sync.BootSync(self._config)
return sync.run(dryrun=dryrun)
- def enchant(self,sysname,profile,system,password):
+ def enchant(self,sysname,profile,password):
"""
Apply a system profile to a running remote system, replacing
- the current OS. Either profile or system should be None, other
- arguments required.
+ the current OS.
"""
enchant = action_enchant.Enchant(self._config,sysname,profile,password)
return enchant.run()
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index cf599bf..d06a731 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -140,7 +140,6 @@ class BootCLI:
"""
sysname = None
profile = None
- system = None
password = None
first = None
last = None
@@ -161,17 +160,11 @@ class BootCLI:
if first == "--password":
password = last
continue
- if first == "--system":
- system = last
- continue
else:
raise cexceptions.CobblerException("weird_arg",args)
- if sysname is None or (profile is None and system is None) or password is None or ((not profile is None) and (not system is None)):
+ if sysname is None or profile is None or password is None:
raise cexceptions.CobblerException("enchant_args")
- if system is not None:
- return self.api.enchant(sysname,None,system,password)
- else:
- return self.api.enchant(sysname,profile,None,password)
+ return self.api.enchant(sysname,profile,password)
def profile_edit(self,args):
"""
diff --git a/cobbler/cobbler_msg.py b/cobbler/cobbler_msg.py
index c642bf0..da0ebdf 100644
--- a/cobbler/cobbler_msg.py
+++ b/cobbler/cobbler_msg.py
@@ -26,7 +26,7 @@ _msg_table = {
"no_delete" : "cobbler could not delete: %s",
"no_args" : "this command requires arguments.",
"missing_options" : "cannot perform this action, more arguments are required",
- "enchant_args" : "usage: cobbler enchant --name=<string> --profile=<string> --password=<string>\nOR:\ncobbler enchant --name=<string> --system=<string> --password=<string>",
+ "enchant_args" : "usage: cobbler enchant --name=<string> --profile=<string> --password=<string>\n",
"enchant_failed" : "enchant failed (%s)",
"unknown_cmd" : "cobbler doesn't understand '%s'",
"bad_arg" : "cobbler was expecting an equal sign in argument '%s'",