summaryrefslogtreecommitdiffstats
path: root/cobbler/action_enchant.py
diff options
context:
space:
mode:
Diffstat (limited to 'cobbler/action_enchant.py')
-rw-r--r--cobbler/action_enchant.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/cobbler/action_enchant.py b/cobbler/action_enchant.py
index b77eabf..3007c5d 100644
--- a/cobbler/action_enchant.py
+++ b/cobbler/action_enchant.py
@@ -21,7 +21,7 @@ import traceback
class Enchant:
- def __init__(self,config,address,profile,system):
+ def __init__(self,config,address,profile,system,is_virt):
"""
Constructor.
config: a configuration reference (see api module)
@@ -33,6 +33,7 @@ class Enchant:
self.address = address
self.profile = profile
self.system = system
+ self.is_virt = is_virt
if address is None:
raise cexceptions.CobblerException("enchant_failed","no address specified")
if system is None and profile is None:
@@ -71,6 +72,8 @@ class Enchant:
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):
@@ -78,14 +81,26 @@ class Enchant:
try:
self.ssh_exec("wget http://%s/cobbler/%s" % (self.settings.server, koan))
- self.ssh_exec("up2date install syslinux",catch_fail=False)
- self.ssh_exec("yum -y install syslinux",catch_fail=False)
+ # koan doesn't require libvirt, but uses it for koan --virt options if available
+ # so, if --virt is requested, we have to make sure it's installed.
+ extra_virt_packages = ""
+ if self.is_virt:
+ extra_virt_packages = " libvirt-python libvirt xen"
+ # 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 --replace-self --system=%s --server=%s" % (self.system, self.settings.server))
+ self.ssh_exec("koan %s --system=%s --server=%s" % (operation, self.system, self.settings.server))
else:
- self.ssh_exec("koan --replace-self --profile=%s --server=%s" % (self.profile, self.settings.server))
- self.ssh_exec("/sbin/reboot")
+ 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()