Package Ganga :: Package Lib :: Package LCG :: Module LCGRequirements
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.LCG.LCGRequirements

 1  from Ganga.GPIDev.Base import GangaObject 
 2  from Ganga.GPIDev.Schema import * 
 3  from Ganga.Utility.Config import getConfig 
 4   
5 -class LCGRequirements(GangaObject):
6 '''Helper class to group LCG requirements. 7 8 See also: JDL Attributes Specification at http://cern.ch/glite/documentation 9 ''' 10 11 _schema = Schema(Version(1,1), { 12 'software' : SimpleItem(defvalue=[], typelist=['str'],sequence=1,doc='Software Installations'), 13 'nodenumber' : SimpleItem(defvalue=1,doc='Number of Nodes for MPICH jobs'), 14 'memory' : SimpleItem(defvalue=0,doc='Mininum available memory (MB)'), 15 'cputime' : SimpleItem(defvalue=0,doc='Minimum available CPU time (min)'), 16 'walltime' : SimpleItem(defvalue=0,doc='Mimimum available total time (min)'), 17 'ipconnectivity' : SimpleItem(defvalue=False,doc='External connectivity'), 18 'other' : SimpleItem(defvalue=[],typelist=['str'],sequence=1,doc='Other Requirements') 19 }) 20 21 _category = 'LCGRequirements' 22 _name = 'LCGRequirements' 23 24 _GUIPrefs = [ { 'attribute' : 'software', 'widget' : 'String_List' }, 25 { 'attribute' : 'nodenumber', 'widget' : 'Int' }, 26 { 'attribute' : 'memory', 'widget' : 'Int' }, 27 { 'attribute' : 'cputime', 'widget' : 'Int' }, 28 { 'attribute' : 'walltime', 'widget' : 'Int' }, 29 { 'attribute' : 'ipconnectivity', 'widget' : 'Bool' }, 30 { 'attribute' : 'other', 'widget' : 'String_List' } ] 31
32 - def __init__(self):
33 34 super(LCGRequirements,self).__init__()
35
36 - def merge(self,other):
37 '''Merge requirements objects''' 38 39 if not other: return self 40 41 merged = LCGRequirements() 42 for name in [ 'software', 'nodenumber', 'memory', 'cputime', 'walltime', 'ipconnectivity', 'other' ]: 43 attr = getattr(other,name) 44 if not attr: attr = getattr(self,name) 45 setattr(merged,name,attr) 46 47 return merged
48
49 - def convert(self):
50 '''Convert the condition in a JDL specification''' 51 52 import re 53 54 requirements = [ 'Member("%s",other.GlueHostApplicationSoftwareRunTimeEnvironment)' % sw for sw in self.software ] 55 if self.memory: requirements += [ 'other.GlueHostMainMemoryVirtualSize >= %s' % str(self.memory) ] 56 if self.cputime: requirements += [ '(other.GlueCEPolicyMaxCPUTime >= %s || other.GlueCEPolicyMaxCPUTime == 0)' % str(self.cputime) ] 57 if self.walltime: requirements += [ '(other.GlueCEPolicyMaxWallClockTime >= %s || other.GlueCEPolicyMaxWallClockTime == 0)' % str(self.walltime) ] 58 if self.ipconnectivity: requirements += [ 'other.GlueHostNetworkAdapterOutboundIP==true' ] 59 requirements += self.other 60 61 config = getConfig('LCG') 62 63 if config['AllowedCEs']: 64 allowed_ces = re.split('\s+',config['AllowedCEs']) 65 requirements += [ '( %s )' % ' || '.join([ 'RegExp("%s",other.GlueCEUniqueID)' % ce for ce in allowed_ces])] 66 67 if config['ExcludedCEs']: 68 excluded_ces = re.split('\s+',config['ExcludedCEs']) 69 requirements += [ '(!RegExp("%s",other.GlueCEUniqueID))' % ce for ce in excluded_ces ] 70 71 return requirements
72