Repository: rucio/rucio

Issue:
Crash when enabling multihop mode
Motivation
----------
The submitter crash when enabling multihop mode








Discussion:

Resolving patch:
diff --git a/lib/rucio/client/uploadclient.py b/lib/rucio/client/uploadclient.py
--- a/lib/rucio/client/uploadclient.py
+++ b/lib/rucio/client/uploadclient.py
@@ -37,7 +37,7 @@
 from rucio.common.exception import (RucioException, RSEBlacklisted, DataIdentifierAlreadyExists,
                                     DataIdentifierNotFound, NoFilesUploaded, NotAllFilesUploaded,
                                     ResourceTemporaryUnavailable, ServiceUnavailable, InputValidationError)
-from rucio.common.utils import adler32, execute, generate_uuid, md5, send_trace, GLOBALLY_SUPPORTED_CHECKSUMS
+from rucio.common.utils import adler32, detect_client_location, execute, generate_uuid, md5, send_trace, GLOBALLY_SUPPORTED_CHECKSUMS
 from rucio.rse import rsemanager as rsemgr
 from rucio import version
 
@@ -57,6 +57,7 @@ def __init__(self, _client=None, logger=None, tracing=True):
 
         self.logger = logger
         self.client = _client if _client else Client()
+        self.client_location = detect_client_location()
         self.tracing = tracing
         if not self.tracing:
             logger.debug('Tracing is turned off.')
@@ -196,7 +197,20 @@ def upload(self, items, summary_file_path=None, traces_copy_out=None):
                     logger.info('File already exists on RSE. Skipping upload')
                     trace['stateReason'] = 'File already exists'
                     continue
-            protocols = rsemgr.get_protocols_ordered(rse_settings=rse_settings, operation='write', scheme=force_scheme)
+
+            # resolving local area networks
+            domain = 'wan'
+            rse_attributes = {}
+            try:
+                rse_attributes = self.client.list_rse_attributes(rse)
+            except:
+                logger.warning('Attributes of the RSE: %s not available.' % rse)
+            if (self.client_location and 'lan' in rse_settings['domain'] and 'site' in rse_attributes):
+                if self.client_location['site'] == rse_attributes['site']:
+                    domain = 'lan'
+
+            # protocol handling and upload
+            protocols = rsemgr.get_protocols_ordered(rse_settings=rse_settings, operation='write', scheme=force_scheme, domain=domain)
             protocols.reverse()
             success = False
             state_reason = ''
diff --git a/lib/rucio/web/rest/webpy/v1/authentication.py b/lib/rucio/web/rest/webpy/v1/authentication.py
--- a/lib/rucio/web/rest/webpy/v1/authentication.py
+++ b/lib/rucio/web/rest/webpy/v1/authentication.py
@@ -31,6 +31,7 @@
 
 from re import search
 from traceback import format_exc
+import imp
 
 from web import application, ctx, OK, BadRequest, header, InternalError, input as param_input
 
@@ -46,7 +47,18 @@
 from rucio.web.rest.common import RucioController, check_accept_header_wrapper
 
 from rucio.common.config import config_get
-if config_get('client', 'auth_type') == 'saml':
+
+# Extra modules: Only imported if available
+EXTRA_MODULES = {'onelogin': False}
+
+for extra_module in EXTRA_MODULES:
+    try:
+        imp.find_module(extra_module)
+        EXTRA_MODULES[extra_module] = True
+    except ImportError:
+        EXTRA_MODULES[extra_module] = False
+
+if EXTRA_MODULES['onelogin']:
     from onelogin.saml2.auth import OneLogin_Saml2_Auth
     from rucio.web.ui.common.utils import prepare_webpy_request
     from web import cookies, setcookie


Test patch: