~ubuntu-branches/ubuntu/natty/cobbler/natty

« back to all changes in this revision

Viewing changes to debian/patches/32_fix_koan_import_yum.patch

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-03-11 16:02:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110311160248-o881mf0wys4j8rk1
Tags: 2.1.0~bzr2005-0ubuntu2
* debian/patches/31_add_ubuntu_koan_utils_support.patch: Add support for
  ubuntu distro in koan utils.py.
* debian/patches/32_fix_koan_import_yum.patch: Fix import error of yum
  python module; adds flexibility for other package managers. (LP: #731620)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Do not fail when yum python module is not present.
 
2
 Since ubuntu does not use yum, this fixes the failure of importing
 
3
 the yum python module and adding support to be able to use other
 
4
 package managers in the future
 
5
Author: Andres Rodriguez <andreserl@ubuntu.com>
 
6
Bug: https://bugs.launchpad.net/ubuntu/+source/cobbler/+bug/731620
 
7
Index: ubuntu/koan/configurator.py
 
8
===================================================================
 
9
--- ubuntu.orig/koan/configurator.py    2011-03-11 16:03:32.531630478 -0500
 
10
+++ ubuntu/koan/configurator.py 2011-03-11 16:03:27.321622833 -0500
 
11
@@ -31,13 +31,16 @@
 
12
 import os.path
 
13
 import sys
 
14
 import time
 
15
-import yum
 
16
 import pwd
 
17
 import grp
 
18
 import simplejson as json
 
19
-sys.path.append('/usr/share/yum-cli')
 
20
-import cli
 
21
-
 
22
+try:
 
23
+    import yum
 
24
+    sys.path.append('/usr/share/yum-cli')
 
25
+    import cli
 
26
+    yum_available = True
 
27
+except:
 
28
+    yum_available = False
 
29
 
 
30
 class KoanConfigure:
 
31
     """
 
32
@@ -49,10 +52,16 @@
 
33
         """Constructor. Requires json config object."""
 
34
         self.config = json.JSONDecoder().decode(config)
 
35
         self.stats = {}
 
36
+        self.dist = utils.check_dist()
 
37
         
 
38
     #----------------------------------------------------------------------
 
39
 
 
40
     def configure_repos(self):
 
41
+        # Enables the possibility to use different types of repos
 
42
+        if yum_available and self.dist == "redhat":
 
43
+            self.configure_yum_repos()
 
44
+
 
45
+    def configure_yum_repos(self):
 
46
         """Configure YUM repositories."""
 
47
         print "- Configuring Repos"  
 
48
         old_repo = '/etc/yum.repos.d/config.repo'
 
49
@@ -108,6 +117,11 @@
 
50
     #----------------------------------------------------------------------
 
51
     
 
52
     def configure_packages(self):
 
53
+        # Enables the possibility to use different types of package configurators
 
54
+        if yum_available and self.dist == "redhat":
 
55
+            self.configure_yum_packages()
 
56
+
 
57
+    def configure_yum_packages(self):
 
58
         """Configure package resources."""
 
59
         print "- Configuring Packages"
 
60
         runtime_start = time.time()