ia64/xen-unstable

changeset 17538:2cf9a8736bab

[Xend/ACM] Provide explicit initialization function for bootloader class

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>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 01 09:55:45 2008 +0100 (2008-05-01)
parents 931932f5fc6d
children 5e5bc5b2bb6d
files tools/python/xen/util/bootloader.py tools/python/xen/xend/XendXSPolicyAdmin.py
line diff
     1.1 --- a/tools/python/xen/util/bootloader.py	Thu May 01 09:55:06 2008 +0100
     1.2 +++ b/tools/python/xen/util/bootloader.py	Thu May 01 09:55:45 2008 +0100
     1.3 @@ -26,8 +26,6 @@ from xen.xend.XendLogging import log
     1.4  from xen.util import mkdir
     1.5  import xen.util.xsm.xsm as security
     1.6  
     1.7 -__bootloader = None
     1.8 -
     1.9  #
    1.10  # Functions for modifying entries in the bootloader, i.e. adding
    1.11  # a module to boot the system with a policy.
    1.12 @@ -513,8 +511,11 @@ class LatePolicyLoader(Bootloader):
    1.13          Bootloader.__init__(self)
    1.14  
    1.15      def probe(self):
    1.16 -        _dir=os.path.dirname(self.FILENAME)
    1.17 -        mkdir.parents(_dir, stat.S_IRWXU)
    1.18 +        try:
    1.19 +            _dir=os.path.dirname(self.FILENAME)
    1.20 +            mkdir.parents(_dir, stat.S_IRWXU)
    1.21 +        except:
    1.22 +            return False
    1.23          return True
    1.24  
    1.25      def get_default_title(self):
    1.26 @@ -614,10 +615,12 @@ class LatePolicyLoader(Bootloader):
    1.27  
    1.28  __bootloader = Bootloader()
    1.29  
    1.30 -grub = Grub()
    1.31 -if grub.probe() == True:
    1.32 -    __bootloader = grub
    1.33 -else:
    1.34 -    late = LatePolicyLoader()
    1.35 -    if late.probe() == True:
    1.36 -        __bootloader = late
    1.37 +def init():
    1.38 +    global __bootloader
    1.39 +    grub = Grub()
    1.40 +    if grub.probe() == True:
    1.41 +        __bootloader = grub
    1.42 +    else:
    1.43 +        late = LatePolicyLoader()
    1.44 +        if late.probe() == True:
    1.45 +            __bootloader = late
     2.1 --- a/tools/python/xen/xend/XendXSPolicyAdmin.py	Thu May 01 09:55:06 2008 +0100
     2.2 +++ b/tools/python/xen/xend/XendXSPolicyAdmin.py	Thu May 01 09:55:45 2008 +0100
     2.3 @@ -46,6 +46,7 @@ class XSPolicyAdmin:
     2.4          self.maxpolicies = maxpolicies
     2.5          self.policies = {}
     2.6          self.xsobjs = {}
     2.7 +        bootloader.init()
     2.8  
     2.9          act_pol_name = self.get_hv_loaded_policy_name()
    2.10          initialize()