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' |
593 |
|
|
594 |
|
# Determine the output directory name |
595 |
|
dir = common.work_space.resDir() |
596 |
< |
dir += os.getlogin() |
596 |
> |
dir += os.environ['USER'] |
597 |
|
dir += '_' + os.path.basename(id) |
598 |
|
return dir |
599 |
|
|
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 |
|
|
773 |
|
if (self.proxyValid): return |
774 |
|
timeleft = -999 |
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): |
784 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
785 |
|
mustRenew = 1 |
786 |
|
else: |
787 |
< |
timeLeftServer = runCommand('voms-proxy-info -actimeleft') |
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: |
790 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
791 |
|
mustRenew = 1 |
792 |
|
pass |
793 |
|
pass |
794 |
|
|
795 |
< |
if (mustRenew): |
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) |
802 |
|
except: |
803 |
|
msg = "Unable to create a valid proxy!\n" |
804 |
|
raise CrabException(msg) |
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 delegate 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 |