]> xenbits.xensource.com Git - xen.git/commitdiff
[Xend/ACM] Provide explicit initialization function for bootloader class
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 1 May 2008 08:55:45 +0000 (09:55 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 1 May 2008 08:55:45 +0000 (09:55 +0100)
This patch refactors the initialization code for the bootloader class
and puts it into an explicit initialization function that is called
from another class.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
tools/python/xen/util/bootloader.py
tools/python/xen/xend/XendXSPolicyAdmin.py

index 58c904f0702d12d00df1ce6103fa886c95cd2ee7..d3b2de7fccf5af566e7aec7c3b333bc9261cf667 100644 (file)
@@ -26,8 +26,6 @@ from xen.xend.XendLogging import log
 from xen.util import mkdir
 import xen.util.xsm.xsm as security
 
-__bootloader = None
-
 #
 # Functions for modifying entries in the bootloader, i.e. adding
 # a module to boot the system with a policy.
@@ -513,8 +511,11 @@ class LatePolicyLoader(Bootloader):
         Bootloader.__init__(self)
 
     def probe(self):
-        _dir=os.path.dirname(self.FILENAME)
-        mkdir.parents(_dir, stat.S_IRWXU)
+        try:
+            _dir=os.path.dirname(self.FILENAME)
+            mkdir.parents(_dir, stat.S_IRWXU)
+        except:
+            return False
         return True
 
     def get_default_title(self):
@@ -614,10 +615,12 @@ class LatePolicyLoader(Bootloader):
 
 __bootloader = Bootloader()
 
-grub = Grub()
-if grub.probe() == True:
-    __bootloader = grub
-else:
-    late = LatePolicyLoader()
-    if late.probe() == True:
-        __bootloader = late
+def init():
+    global __bootloader
+    grub = Grub()
+    if grub.probe() == True:
+        __bootloader = grub
+    else:
+        late = LatePolicyLoader()
+        if late.probe() == True:
+            __bootloader = late
index 633c62b228eed826b7edcd5a1512513be5126d6a..e6b536e62401d71274648294ccaab36528306d32 100644 (file)
@@ -46,6 +46,7 @@ class XSPolicyAdmin:
         self.maxpolicies = maxpolicies
         self.policies = {}
         self.xsobjs = {}
+        bootloader.init()
 
         act_pol_name = self.get_hv_loaded_policy_name()
         initialize()