getProxyinfo to get group properties #7661
-
I wrote a script with
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Sorry for the late answer, but
|
Beta Was this translation helpful? Give feedback.
-
The script is like the following: from DIRAC import S_OK, S_ERROR, gLogger, exit
from DIRAC.Core.Base.Script import Script
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
#@Script()
def main():
Script.parseCommandLine(ignoreErrors=False)
proxy_info = getProxyInfo(disableVOMS=False)
gLogger.debug(f"the proxy_info used now: {proxy_info}")
if not proxy_info['OK']:
gLogger.error("ERROR: No Proxy present")
return False
proxy_values = proxy_info.get('Value', {})
group = proxy_values.get('group', '')
print("******************", group)
group_properties = proxy_values.get('groupProperties', [])
gLogger.debug(f"the {group_properties} used now: {group_properties}")
gLogger.debug(f"the {group} used now: {group}")
if group_properties:
if 'ProductionManagement' not in group_properties:
gLogger.error("ERROR: Not allowed to create production, you need a ProductionManagement proxy.")
return False
else:
gLogger.error("ERROR: Could not determine Proxy properties, you do not have the right proxy.")
return False
return True
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
-
The script is working with adding "Script.parseCommandLine(ignoreErrors=False)" before "getProxyInfo". But the same part in the JUNO production script is still not working in CNAF. The only difference between two is "@script" in the JUNO production script. |
Beta Was this translation helpful? Give feedback.
-
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
from DIRAC import S_OK, S_ERROR, gLogger, exit
from DIRAC.Core.Base.Script import Script
def _checkProxy():
"""checks if the proxy has the ProductionManagement property and belongs to a VO"""
proxyInfo = getProxyInfo()
gLogger.debug("DEBUG: the proxyInfo used now: %s\n", proxyInfo)
if not proxyInfo['OK']:
gLogger.error("ERROR: No Proxy present")
return False
proxyValues = proxyInfo.get('Value', {})
group = proxyValues.get('group', '')
groupProperties = proxyValues.get('groupProperties', [])
if groupProperties:
if 'ProductionManagement' not in groupProperties:
gLogger.error("ERROR: Not allowed to create production, you need a ProductionManagement proxy.")
return False
else:
gLogger.error("ERROR: Could not determine Proxy properties, you do not have the right proxy.")
return False
return True
.........
@Script()
def main():
Script.registerSwitch('i:', 'ini=', 'Ini file, default to "prod.ini"')
Script.registerSwitch(
'r', 'dryrun', 'Only parse the configuration, do not submit transformation')
Script.registerSwitch('e', 'example', 'Display prod.ini example')
Script.parseCommandLine(ignoreErrors=False)
args = Script.getPositionalArgs()
switches = Script.getUnprocessedSwitches()
configFile = 'prod.ini'
paramCmd = {}
displayExample = False
for k, v in switches:
if k == 'i' or k == 'ini':
configFile = v
if k == 'r' or k == 'dryrun':
paramCmd['dryrun'] = 'true'
if k == 'e' or k == 'example':
displayExample = True
if displayExample:
sys.stdout.write(PROD_EXAMPLE)
return 0
if args:
paramCmd['process'] = args[0]
if not _checkProxy():
gLogger.error('ERROR: You don\'t have proper proxy to use prodSys!')
return 1
par = Param(configFile, paramCmd)
chain = ProdChain(par.param)
chain.createAllTransformations()
return 0
if __name__ == '__main__':
try:
exit(main())
except Exception as e:
if DEBUG:
raise
gLogger.error('{0}'.format(e))
exit(1) |
Beta Was this translation helpful? Give feedback.
The script pasted above wasn't the full script. The full script in fact had a large number of additional import statements, including (from memory)
at the top level before parseCommandLine is called. This caused an early invocation of proxyInfo which scrubbed the group and voms information at CNAF and IN2P3. Moving the import statements into their functions fixed the use of the script at CNAF and IN2P3.
It is not clear why this script worked out of the box at IHEP, but maybe the box was different at IHEP.