summaryrefslogtreecommitdiffstats
path: root/cobbler/action_enchant.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-10-17 17:12:04 -0400
committerJim Meyering <jim@meyering.net>2006-10-17 17:12:04 -0400
commit77dbf67da82126d7aa8edbdb187a14914f4ee0ee (patch)
tree024b4a6341d709c45e097e435528e988651a5563 /cobbler/action_enchant.py
parent85502c7f1df16b3500a9b1acb866ad77e0bf7545 (diff)
downloadthird_party-cobbler-77dbf67da82126d7aa8edbdb187a14914f4ee0ee.tar.gz
third_party-cobbler-77dbf67da82126d7aa8edbdb187a14914f4ee0ee.tar.xz
third_party-cobbler-77dbf67da82126d7aa8edbdb187a14914f4ee0ee.zip
Working on removing the dependancy on pexpect
Diffstat (limited to 'cobbler/action_enchant.py')
-rw-r--r--cobbler/action_enchant.py36
1 files changed, 16 insertions, 20 deletions
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")