Skip to content

Commit

Permalink
set rest clients in queue
Browse files Browse the repository at this point in the history
  • Loading branch information
dsschult committed Jun 10, 2024
1 parent 4484140 commit e2f5ac3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions iceprod/server/data/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "string",
"default": "condor"
},
"site": {
"description": "Site name",
"type": "string"
},
"description": {
"type": "string",
"default": "generic grid plugin"
Expand Down Expand Up @@ -152,6 +156,14 @@
"description": "OAuth provider url",
"type": "string",
"default": "https://keycloak.icecube.wisc.edu/auth/realms/IceCube"
},
"oauth_client_id": {
"description": "OAuth client id",
"type": "string"
},
"oauth_client_secret": {
"description": "OAuth client secret",
"type": "string"
}
},
"additionalProperties": true
Expand Down
22 changes: 22 additions & 0 deletions iceprod/server/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ def get_grid_plugin(self):
'rest_client': None,
'cred_client': None,
}

if ('rest_api' in self.cfg and 'url' in self.cfg['rest_api']
and 'oauth_url' in self.cfg['rest_api']
and 'oauth_client_id' in self.cfg['rest_api']
and 'oauth_client_secret' in self.cfg['rest_api']):
try:
kwargs['rest_client'] = ClientCredentialsAuth(
address=self.cfg['rest_api']['url'],
token_url=self.cfg['rest_api']['oauth_url'],
client_id=self.cfg['rest_api']['oauth_client_id'],
client_secret=self.cfg['rest_api']['oauth_client_secret'],
)
kwargs['cred_client']= ClientCredentialsAuth(
address=self.cfg['rest_api']['cred_url'],
token_url=self.cfg['rest_api']['oauth_url'],
client_id=self.cfg['rest_api']['oauth_client_id'],
client_secret=self.cfg['rest_api']['oauth_client_secret'],
)
except Exception:
logger.warning('failed to connect to rest api: %r',
self.cfg['rest_api'].get('url',''), exc_info=True)

try:
return getattr(plugin_module, 'Grid')(**kwargs)
except Exception:
Expand Down

0 comments on commit e2f5ac3

Please sign in to comment.