Skip to content

Commit

Permalink
validate proxy VOMS extension. Fix #5131 (#5132)
Browse files Browse the repository at this point in the history
* validate proxy VOMS extension. Fix #5131

* add from __future__ import division in various files
  • Loading branch information
belforte authored Dec 10, 2021
1 parent f479373 commit b610228
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/crab.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- exit with the proper exit codes
"""
from __future__ import print_function
from __future__ import division
import sys
if sys.version_info < (2, 6):
print('\nError: using a version of python < 2.6. Exiting...\n')
Expand Down
2 changes: 2 additions & 0 deletions src/python/CRABClient/CredentialInteractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def createNewVomsProxy(self, timeLeftThreshold=0, proxyCreatedByCRAB=False, prox
proxyTimeLeft = 0
else:
self.logger.debug("Found proxy file %s" % (proxyFileName))
self.logger.debug("Making sure it has proper VOMS extension")
proxy.validateVO()
self.logger.debug("Getting proxy life time left")
proxyTimeLeft = proxy.getTimeLeft()
hours, minutes, seconds = int(proxyTimeLeft/3600), int((proxyTimeLeft%3600)/60), int((proxyTimeLeft%3600)%60)
Expand Down
13 changes: 13 additions & 0 deletions src/python/CRABClient/ProxyInteractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ def setVOGroupVORole(self, group, role):
def getFilename(self):
return self.proxyFile

def validateVO(self):
# make sure that proxy has a VOMS extension for CMS VirtualOrganization
cmd = 'voms-proxy-info --vo --file %s' % self.proxyFile
stdout, stderr, rc = execute_command(cmd, logger=self.logger)
if rc != 0 or 'cms' not in stdout:
msg = "\n".join(['Error executing %s:' % cmd, stdout, stderr])
self.logger.error(msg)
msg = 'proxy %s is not a valid proxy file or has no valid VOMS extension.\n' % self.proxyFile
stdout, stderr, rc = execute_command('voms-proxy-info -all', logger=self.logger)
msg += 'output of voms-proxy-info -all is\n%s' % (stdout+'\n'+stderr)
msg += '\n**** Make sure you do voms-proxy-init -voms cms ****\n'
raise ProxyCreationException(msg)

def getTimeLeft(self):
cmd = 'voms-proxy-info --actimeleft --timeleft --file %s' % self.proxyFile
stdout, stderr, rc = execute_command(cmd, logger=self.logger)
Expand Down
1 change: 1 addition & 0 deletions src/python/CRABClient/WMCoreConfigWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
dependencies which are not available in CMSSW_8 or earlier, e.g. "future"
"""

from __future__ import division
from CRABClient.Configuration import Configuration as Config
from CRABClient.ClientUtilities import colors

Expand Down
1 change: 1 addition & 0 deletions src/python/CRABClient/WMCoreConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Module dealing with Configuration file in python format
"""

from __future__ import division
import imp
import os
import sys
Expand Down

0 comments on commit b610228

Please sign in to comment.