def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument( "ShifterRole: Name of the shifter role, e.g. DataManager") Script.registerArgument( "UserName: A user name, as registered in Registry section") Script.registerArgument( "DIRACGroup: DIRAC Group, e.g. diracAdmin (the user has to have this role)" ) Script.parseCommandLine(ignoreErrors=True) csAPI = CSAPI() shifterRole, userName, diracGroup = Script.getPositionalArgs(group=True) res = csAPI.addShifter( {shifterRole: { "User": userName, "Group": diracGroup }}) if not res["OK"]: gLogger.error("Could not add shifter", ": " + res["Message"]) DIRACExit(1) res = csAPI.commit() if not res["OK"]: gLogger.error("Could not add shifter", ": " + res["Message"]) DIRACExit(1) gLogger.notice("Added shifter %s as user %s with group %s" % (shifterRole, userName, diracGroup))
def main(): Script.parseCommandLine(ignoreErrors=True) args = Script.getPositionalArgs() csAPI = CSAPI() if len(args) < 3: Script.showHelp(exitCode=1) shifterRole = args[0] userName = args[1] diracGroup = args[2] res = csAPI.addShifter( {shifterRole: { 'User': userName, 'Group': diracGroup }}) if not res['OK']: gLogger.error("Could not add shifter", ": " + res['Message']) DIRACExit(1) res = csAPI.commit() if not res['OK']: gLogger.error("Could not add shifter", ": " + res['Message']) DIRACExit(1) gLogger.notice("Added shifter %s as user %s with group %s" % (shifterRole, userName, diracGroup))
' UserName: A user name, as registered in Registry section', ' DIRACGroup: DIRAC Group, e.g. diracAdmin (the user has to have this role)' ])) Script.parseCommandLine(ignoreErrors=True) args = Script.getPositionalArgs() csAPI = CSAPI() if len(args) < 3: Script.showHelp() DIRACExit(-1) shifterRole = args[0] userName = args[1] diracGroup = args[2] res = csAPI.addShifter( {shifterRole: { 'User': userName, 'Group': diracGroup }}) if not res['OK']: gLogger.error("Could not add shifter", ": " + res['Message']) DIRACExit(1) res = csAPI.commit() if not res['OK']: gLogger.error("Could not add shifter", ": " + res['Message']) DIRACExit(1) gLogger.notice("Added shifter %s as user %s with group %s" % (shifterRole, userName, diracGroup))
Script.setUsageMessage( '\n'.join( [__doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ... ShifterRole UserName DIRACGroup ...' % Script.scriptName, 'Arguments:', ' ShifterRole: Name of the shifter role, e.g. DataManager', ' UserName: A user name, as registered in Registry section', ' DIRACGroup: DIRAC Group, e.g. diracAdmin (the user has to have this role)'] ) ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs( ) csAPI = CSAPI( ) if len( args ) < 3: Script.showHelp( ) DIRACExit( -1 ) shifterRole = args[0] userName = args[1] diracGroup = args[2] res = csAPI.addShifter( {shifterRole: {'User': userName, 'Group': diracGroup}} ) if not res['OK']: gLogger.error( "Could not add shifter", ": " + res['Message'] ) DIRACExit( 1 ) res = csAPI.commit() if not res['OK']: gLogger.error( "Could not add shifter", ": " + res['Message'] ) DIRACExit( 1 ) gLogger.notice( "Added shifter %s as user %s with group %s" % (shifterRole, userName, diracGroup) )