3939from rucio import version
4040from rucio .common import exception
4141from rucio .common .config import config_get , config_get_bool , config_get_int , config_has_section
42+ from rucio .common .config_settings import Config
4243from rucio .common .constants import DEFAULT_VO , HTTPMethod
4344from rucio .common .exception import CannotAuthenticate , ClientProtocolNotFound , ClientProtocolNotSupported , ConfigNotFound , MissingClientParameter , MissingModuleException , NoAuthInformation , ServerConnectionException
4445from rucio .common .extra import import_extras
@@ -141,15 +142,15 @@ def __init__(self,
141142 if rucio_host is not None :
142143 self .host = rucio_host
143144 else :
144- self .host = config_get ( ' client' , ' rucio_host' )
145+ self .host = Config . client . rucio_host ( )
145146 except (NoOptionError , NoSectionError ) as error :
146147 raise MissingClientParameter ('Section client and Option \' %s\' cannot be found in config file' % error .args [0 ])
147148
148149 try :
149150 if auth_host is not None :
150151 self .auth_host = auth_host
151152 else :
152- self .auth_host = config_get ( ' client' , ' auth_host' )
153+ self .auth_host = Config . client . auth_host ( )
153154 except (NoOptionError , NoSectionError ) as error :
154155 raise MissingClientParameter ('Section client and Option \' %s\' cannot be found in config file' % error .args [0 ])
155156
@@ -197,7 +198,7 @@ def __init__(self,
197198 if self .ca_cert is None :
198199 self .logger .debug ('HTTPS is required, but no ca_cert was passed and X509_CERT_DIR is not defined. Trying to get it from the config file.' )
199200 try :
200- self .ca_cert = _expand_path (config_get ( ' client' , ' ca_cert' ))
201+ self .ca_cert = _expand_path (Config . client . ca_cert ( ))
201202 except (NoOptionError , NoSectionError ):
202203 self .logger .debug ('No ca_cert found in configuration. Falling back to Mozilla default CA bundle (certifi).' )
203204 self .ca_cert = True
@@ -211,7 +212,7 @@ def __init__(self,
211212 self .account = environ ['RUCIO_ACCOUNT' ]
212213 except KeyError :
213214 try :
214- self .account = config_get ( ' client' , ' account' )
215+ self .account = Config . client . account ( )
215216 except (NoOptionError , NoSectionError ):
216217 pass
217218
@@ -224,7 +225,7 @@ def __init__(self,
224225 except KeyError :
225226 self .logger .debug ('No VO found. Trying to get it from the config file.' )
226227 try :
227- self .vo = config_get ( ' client' , 'vo' )
228+ self .vo = Config . client . vo ( )
228229 except (NoOptionError , NoSectionError ):
229230 self .logger .debug ('No VO found. Using default VO.' )
230231 self .vo = DEFAULT_VO
@@ -244,7 +245,7 @@ def __init__(self,
244245
245246 def _get_auth_tokens (self ) -> tuple [Optional [str ], str , str , str ]:
246247 # if token file path is defined in the rucio.cfg file, use that file. Currently this prevents authenticating as another user or VO.
247- auth_token_file_path = config_get ( ' client' , ' auth_token_file_path' , False , None )
248+ auth_token_file_path = Config . client . auth_token_file_path ( raise_exception = False )
248249 token_filename_suffix = "for_default_account" if self .account is None else "for_account_" + self .account
249250
250251 if auth_token_file_path :
@@ -270,7 +271,7 @@ def _get_auth_type(self, auth_type: Optional[str]) -> str:
270271 auth_type = environ ['RUCIO_AUTH_TYPE' ]
271272 else :
272273 try :
273- auth_type = config_get ( ' client' , ' auth_type' )
274+ auth_type = Config . client . auth_type ( )
274275 except (NoOptionError , NoSectionError ) as error :
275276 raise MissingClientParameter ('Option \' %s\' cannot be found in config file' % error .args [0 ])
276277 return auth_type
@@ -288,7 +289,7 @@ def _get_creds(self, creds: Optional[dict[str, Any]]) -> dict[str, Any]:
288289 if 'oidc_issuer' not in creds or creds ['oidc_issuer' ] is None :
289290 creds ['oidc_issuer' ] = config_get ('client' , 'oidc_issuer' , False , None )
290291 if 'oidc_audience' not in creds or creds ['oidc_audience' ] is None :
291- creds ['oidc_audience' ] = config_get ( ' client' , ' oidc_audience' , False , None )
292+ creds ['oidc_audience' ] = Config . client . oidc_audience ( raise_exception = False )
292293 if 'oidc_auto' not in creds or creds ['oidc_auto' ] is False :
293294 creds ['oidc_auto' ] = config_get_bool ('client' , 'oidc_auto' , False , False )
294295 if creds ['oidc_auto' ]:
@@ -297,22 +298,22 @@ def _get_creds(self, creds: Optional[dict[str, Any]]) -> dict[str, Any]:
297298 if 'oidc_password' not in creds or creds ['oidc_password' ] is None :
298299 creds ['oidc_password' ] = config_get ('client' , 'oidc_password' , False , None )
299300 if 'oidc_scope' not in creds or creds ['oidc_scope' ] == 'openid profile' :
300- creds ['oidc_scope' ] = config_get ( ' client' , ' oidc_scope' , False , 'openid profile' )
301+ creds ['oidc_scope' ] = Config . client . oidc_scope ( )
301302 if 'oidc_polling' not in creds or creds ['oidc_polling' ] is False :
302303 creds ['oidc_polling' ] = config_get_bool ('client' , 'oidc_polling' , False , False )
303304
304305 elif self .auth_type in ['userpass' , 'saml' ]:
305306 if 'username' not in creds or creds ['username' ] is None :
306- creds ['username' ] = config_get ( ' client' , ' username' )
307+ creds ['username' ] = Config . client . username ( )
307308 if 'password' not in creds or creds ['password' ] is None :
308- creds ['password' ] = config_get ( ' client' , ' password' )
309+ creds ['password' ] = Config . client . password ( )
309310
310311 elif self .auth_type == 'x509' :
311312 if 'client_cert' not in creds or creds ['client_cert' ] is None :
312313 if "RUCIO_CLIENT_CERT" in environ :
313314 creds ['client_cert' ] = environ ["RUCIO_CLIENT_CERT" ]
314315 else :
315- creds ['client_cert' ] = config_get ( ' client' , ' client_cert' )
316+ creds ['client_cert' ] = Config . client . client_cert ( )
316317
317318 creds ['client_cert' ] = _expand_path (creds ['client_cert' ])
318319
@@ -323,7 +324,7 @@ def _get_creds(self, creds: Optional[dict[str, Any]]) -> dict[str, Any]:
323324 if "RUCIO_CLIENT_KEY" in environ :
324325 creds ['client_key' ] = environ ["RUCIO_CLIENT_KEY" ]
325326 else :
326- creds ['client_key' ] = config_get ( ' client' , ' client_key' )
327+ creds ['client_key' ] = Config . client . client_key ( )
327328
328329 creds ['client_key' ] = _expand_path (creds ['client_key' ])
329330 if not os .path .exists (creds ['client_key' ]):
@@ -346,8 +347,8 @@ def _get_creds(self, creds: Optional[dict[str, Any]]) -> dict[str, Any]:
346347 if 'client_proxy' not in creds or creds ['client_proxy' ] is None :
347348 if 'RUCIO_CLIENT_PROXY' in environ :
348349 creds ['client_proxy' ] = environ ['RUCIO_CLIENT_PROXY' ]
349- elif config_has_section ('client' ) and config_get ( ' client' , ' client_x509_proxy' , default = '' ) != '' :
350- creds ['client_proxy' ] = config_get ( ' client' , ' client_x509_proxy' )
350+ elif config_has_section ('client' ) and Config . client . client_x509_proxy ( default = '' ) != '' :
351+ creds ['client_proxy' ] = Config . client . client_x509_proxy ( )
351352 elif 'X509_USER_PROXY' in environ :
352353 creds ['client_proxy' ] = environ ['X509_USER_PROXY' ]
353354 elif os .path .isfile (gsi_proxy_path ):
@@ -363,7 +364,7 @@ def _get_creds(self, creds: Optional[dict[str, Any]]) -> dict[str, Any]:
363364
364365 elif self .auth_type == 'ssh' :
365366 if 'ssh_private_key' not in creds or creds ['ssh_private_key' ] is None :
366- creds ['ssh_private_key' ] = config_get ( ' client' , ' ssh_private_key' )
367+ creds ['ssh_private_key' ] = Config . client . ssh_private_key ( )
367368
368369 creds ['ssh_private_key' ] = _expand_path (creds ['ssh_private_key' ])
369370 if not os .path .isfile (creds ["ssh_private_key" ]):
0 commit comments