This patch is for Ubuntu/Debian distros for which do not use yum.
This fixes the failure when trying to import yum python module
while adding support to be able to use other package managers in
the future.
---
koan/configurator.py | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/koan/configurator.py b/koan/configurator.py
index 5fb3231..de351fc 100644
--- a/koan/configurator.py
+++ b/koan/configurator.py
@@ -31,13 +31,16 @@ import stat
import os.path
import sys
import time
-import yum
import pwd
import grp
import simplejson as json
-sys.path.append('/usr/share/yum-cli')
-import cli
-
+try:
+ import yum
+ sys.path.append('/usr/share/yum-cli')
+ import cli
+ yum_available = True
+except:
+ yum_available = False
class KoanConfigure:
"""
@@ -49,10 +52,16 @@ class KoanConfigure:
"""Constructor. Requires json config object."""
self.config = json.JSONDecoder().decode(config)
self.stats = {}
+ self.dist = utils.check_dist()
#----------------------------------------------------------------------
def configure_repos(self):
+ # Enables the possibility to use different types of repos
+ if yum_available and self.dist == "redhat":
+ self.configure_yum_repos()
+
+ def configure_yum_repos(self):
"""Configure YUM repositories."""
print "- Configuring Repos"
old_repo = '/etc/yum.repos.d/config.repo'
@@ -108,6 +117,11 @@ class KoanConfigure:
#----------------------------------------------------------------------
def configure_packages(self):
+ # Enables the possibility to use different types of package configurators
+ if yum_available and self.dist == "redhat":
+ self.configure_yum_packages()
+
+ def configure_yum_packages(self):
"""Configure package resources."""
print "- Configuring Packages"
runtime_start = time.time()
--
1.7.4.1
Show replies by date