Changeset 3579

Show
Ignore:
Timestamp:
10/26/2009 02:01:23 PM (1 month ago)
Author:
brian
Message:

Fixed bootstrapping of new PBS/SGE batch systems.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gip/trunk/gip/lib/python/gip/batch_systems/batch_system.py

    r3541 r3579  
    107107        """ 
    108108 
     109    def bootstrap(self): 
     110        """ 
     111        This function is called before any others; this is the proper time to 
     112        do any environment or batch system initialization. 
     113        """ 
     114 
  • gip/trunk/gip/lib/python/gip/batch_systems/pbs.py

    r3543 r3579  
    99import gip_sets as sets 
    1010 
    11 from gip_common import HMSToMin, getLogger, VoMapper, voList, parseRvf 
     11from gip_common import HMSToMin, getLogger, VoMapper, voList, parseRvf, \ 
     12    addToPath 
    1213from gip_testing import runCommand 
    1314from gip.batch_systems.batch_system import BatchSystem 
     
    418419        return vos 
    419420 
     421    def bootstrap(self): 
     422        try: 
     423            pbs_path = cp_get(self.cp, "pbs", "pbs_path", ".") 
     424            addToPath(pbs_path) 
     425            # adding pbs_path/bin to the path as well, since pbs/torque home  
     426            # points to /usr/local and the binaries exist in /usr/local/bin 
     427            addToPath(pbs_path + "/bin") 
     428        except Exception, e: 
     429            log.exception(e) 
     430 
     431 
  • gip/trunk/gip/lib/python/gip/batch_systems/sge.py

    r3571 r3579  
    430430        return results 
    431431 
     432    def bootstrap(self): 
     433        """ 
     434        If it exists, source 
     435        $SGE_ROOT/$SGE_CELL/common/settings.sh 
     436        """ 
     437        sge_root = cp_get(cp, "sge", "sge_root", "") 
     438        if not sge_root: 
     439            log.warning("Could not locate sge_root in config file!  Not " \ 
     440                "bootstrapping SGE environment.") 
     441            return 
     442        sge_cell = cp_get(cp, "sge", "sge_cell", "") 
     443        if not sge_cell: 
     444            log.warning("Could not locate sge_cell in config file!  Not " \ 
     445                "bootstrapping SGE environment.") 
     446            return 
     447        settings = os.path.join(sge_root, sge_cell, "common/settings.sh") 
     448        if not os.path.exists(settings): 
     449            log.warning("Could not find the SGE settings file; looked in %s" % \ 
     450                settings) 
     451            return 
     452        cmd = "/bin/sh -c 'source %s; /usr/bin/env'" % settings 
     453        fd = os.popen(cmd) 
     454        results = fd.read() 
     455        if fd.close(): 
     456            log.warning("Unable to source the SGE settings file; tried %s." % \ 
     457                settings) 
     458        for line in results.splitlines(): 
     459            line = line.strip() 
     460            info = line.split('=', 2) 
     461            if len(info) != 2: 
     462                continue 
     463            os.environ[info[0]] = info[1] 
     464 
  • gip/trunk/gip/lib/python/gip/providers/generic_batch_system.py

    r3561 r3579  
    191191            log.error("Unknown job manager: %s" % impl) 
    192192            sys.exit(1) 
     193        batch.bootstrap() 
    193194        queueInfo, totalCpu, freeCpu, queueCpus = print_CE(batch) 
    194195        print_VOViewLocal(queueInfo, batch)