ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
(Generate patch)

Comparing COMP/CRAB/python/SchedulerEdg.py (file contents):
Revision 1.49 by spiga, Fri Apr 7 12:58:38 2006 UTC vs.
Revision 1.52 by fanzago, Wed Apr 19 12:38:20 2006 UTC

# Line 2 | Line 2 | from Scheduler import Scheduler
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 + from EdgConfig import *
6   import common
7  
8   import os, sys, time
# Line 30 | Line 31 | class SchedulerEdg(Scheduler):
31              self.edg_config = ''
32              self.edg_config_vo = ''
33  
34 +        try:
35 +            self.proxyServer = cfg_params["EDG.proxy_server"]
36 +        except KeyError:
37 +            self.proxyServer = 'myproxy.cern.ch'
38 +        common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
39  
40          try: self.LCG_version = cfg_params["EDG.lcg_version"]
41          except KeyError: self.LCG_version = '2'
# Line 755 | Line 761 | class SchedulerEdg(Scheduler):
761              jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
762              pass
763  
764 +        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
765 +
766          jdl.close()
767          return
768  
# Line 764 | Line 772 | class SchedulerEdg(Scheduler):
772          """
773          if (self.proxyValid): return
774          timeleft = -999
775 <        minTimeLeft=10 # in hours
776 <        cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
777 <        # SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found
778 <        cmd_out = os.system(cmd)
779 <        if (cmd_out>0):
775 >        minTimeLeft=10*3600 # in seconds
776 >
777 >        minTimeLeftServer = 100 # in hours
778 >
779 >        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
780 >        #cmd = 'voms-proxy-info -timeleft'
781 >        mustRenew = 0
782 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft')
783 >        timeLeftServer = -999
784 >        if not timeLeftLocal or not isInt(timeLeftLocal):
785 >            mustRenew = 1
786 >        else:
787 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1')
788 >            if not timeLeftServer or not isInt(timeLeftServer):
789 >                mustRenew = 1
790 >            elif timeLeftServer<minTimeLeft or timeLeftServer<minTimeLeft:
791 >                mustRenew = 1
792 >            pass
793 >        pass
794 >
795 >        if mustRenew:
796              common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 24h\n")
797 <            cmd = 'voms-proxy-init -voms cms -valid 100:00'
797 >            cmd = 'voms-proxy-init -voms cms -valid 24:00'
798              try:
799                  # SL as above: damn it!
800                  out = os.system(cmd)
# Line 781 | Line 805 | class SchedulerEdg(Scheduler):
805              # cmd = 'grid-proxy-info -timeleft'
806              # cmd_out = runCommand(cmd,0,20)
807              pass
808 +
809 +        ## now I do have a voms proxy valid, and I check the myproxy server
810 +        renewProxy = 0
811 +        cmd = 'myproxy-info -d -s '+self.proxyServer
812 +        cmd_out = runCommand(cmd,0,20)
813 +        if not cmd_out:
814 +            common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
815 +            renewProxy = 1
816 +        else:
817 +            # if myproxy exist but not long enough, renew
818 +            reTime = re.compile( r'timeleft: (\d+)' )
819 +            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
820 +            if reTime.match( cmd_out ):
821 +                time = reTime.search( line ).group(1)
822 +                if time < minTimeLeftServer:
823 +                    renewProxy = 1
824 +                    common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
825 +                pass
826 +            pass
827 +        
828 +        # if not, create one.
829 +        if renewProxy:
830 +            cmd = 'myproxy-init -d -n -s '+self.proxyServer
831 +            out = os.system(cmd)
832 +            if (out>0):
833 +                raise CrabException("Unable to dellegate the proxy to myproxyserver "+self.proxyServer+" !\n")
834 +            pass
835 +
836 +        # cache proxy validity
837          self.proxyValid=1
838          return
839  
840      def configOpt_(self):
841          edg_ui_cfg_opt = ' '
842          if self.edg_config:
843 <          edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
843 >            edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
844          if self.edg_config_vo:
845 <          edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
845 >            edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
846          return edg_ui_cfg_opt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines