Repository: rucio/rucio

Issue:
Correct storm path resolve for list_replicas
Motivation
----------

The fake storm:// protocol needs to be included in the list_replicas reply.


Crash on __list_transfer_requests_and_source_replicas
Motivation
----------

```
2019-06-19 14:17:43,558 32683   CRITICAL        Thread [1/31] : Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/rucio/daemons/conveyor/submitter.py", line 162, in submitter
    retry_other_fts=retry_other_fts)
  File "/usr/lib/python2.7/site-packages/rucio/daemons/conveyor/submitter.py", line 286, in __get_transfers
    failover_schemes=failover_schemes)
  File "/usr/lib/python2.7/site-packages/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/usr/lib/python2.7/site-packages/retrying.py", line 206, in call
    return attempt.get(self._wrap_exception)
  File "/usr/lib/python2.7/site-packages/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/usr/lib/python2.7/site-packages/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/usr/lib/python2.7/site-packages/rucio/db/sqla/session.py", line 281, in new_funct
    raise DatabaseException(str(error))
DatabaseException: Database exception.
Details: (cx_Oracle.DatabaseError) ORA-00918: column ambiguously defined
```





Discussion:

Resolving patch:
diff --git a/lib/rucio/rse/protocols/storm.py b/lib/rucio/rse/protocols/storm.py
--- a/lib/rucio/rse/protocols/storm.py
+++ b/lib/rucio/rse/protocols/storm.py
@@ -1,13 +1,20 @@
-# Copyright European Organization for Nuclear Research (CERN)
+# Copyright 2014-2019 CERN for the benefit of the ATLAS collaboration.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
-# You may not use this file except in compliance with the License.
+# you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# http://www.apache.org/licenses/LICENSE-2.0
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 #
 # Authors:
-# - Tomas Javor Javurek, <tomas.javurek@cern.ch>, 2019
-
+# - Tomas Javor Javurek <tomas.javurek@cern.ch>, 2019
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2019
 
 import os
 
@@ -31,35 +38,27 @@ def __init__(self, protocol_attr, rse_settings):
         self.attributes.pop('determinism_type', None)
         self.files = []
 
-    def _get_path(self, scope, name):
-        """ Transforms the physical file name into the local URI in the referred RSE.
-            Suitable for sites implementoing the RUCIO naming convention.
-
-            :param name: filename
-            :param scope: scope
-
-            :returns: RSE specific URI of the physical file
-        """
-        return '%s/%s' % (scope, name)
-
     def lfns2pfns(self, lfns):
-        """ In this case, just returns back lfn with external scope. """
-        if type(lfns) == dict:
-            val = lfns.copy()
-            if 'scope' in val and val['scope'] is not None:
-                val['scope'] = val['scope'].external
-
-        elif type(lfns) == list:
-            val = []
-            for l in lfns:
-                v = l.copy()
-                if 'scope' in v and v['scope'] is not None:
-                    v['scope'] = v['scope'].external
-                val.append(v)
-
-        else:
-            val = lfns
-        return val
+        """ Create fake storm:// path. Will be resolved at the get() stage later. """
+        pfns = {}
+
+        hostname = self.attributes['hostname']
+        if '://' in hostname:
+            hostname = hostname.split("://")[1]
+
+        prefix = self.attributes['prefix']
+        if not prefix.startswith('/'):
+            prefix = ''.join(['/', prefix])
+        if not prefix.endswith('/'):
+            prefix = ''.join([prefix, '/'])
+
+        lfns = [lfns] if isinstance(lfns, dict) else lfns
+        for lfn in lfns:
+            path = lfn['path'] if 'path' in lfn and lfn['path'] else self._get_path(scope=lfn['scope'].external,
+                                                                                    name=lfn['name'])
+            pfns['%s:%s' % (lfn['scope'], lfn['name'])] = ''.join(['storm://', hostname, ':', str(self.attributes['port']), prefix, path])
+
+        return pfns
 
     def path2pfn(self, path):
         """


Test patch: