Loading .gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ image-build: stage: build variables: RUCIO_TAG: 1.29.8 PROTOCOLS_VERSION: 0.1.0 PROTOCOLS_VERSION: 0.2.0 script: - > docker build Loading rucio_protocols/posix.py 0 → 100644 +59 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # Copyright European Organization for Nuclear Research (CERN) since 2012 # # Licensed under the Apache License, Version 2.0 (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 # # 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. import logging import os import os.path from rucio.common import exception from rucio.rse.protocols.posix import Default class Symlink(Default): """ Implementing access to RSEs using the local filesystem, creating a symlink on a get """ def get(self, pfn, dest, transfer_timeout=None): """ Provides access to files stored inside connected the RSE. A download/get will create a symlink on the local file system pointing to the underlying file. Other operations act directly on the remote file. :param pfn: Physical file name of requested file :param dest: Name and path of the files when stored at the client :param transfer_timeout Transfer timeout (in seconds) - dummy :raises DestinationNotAccessible: if the destination storage was not accessible. :raises ServiceUnavailable: if some generic error occured in the library. :raises SourceNotFound: if the source file was not found on the referred storage. """ path = self.pfn2path(pfn) os.symlink(path, dest) self.logger(logging.DEBUG, 'Symlink {} created for {} from {}' .format(dest, path, pfn)) if not os.lstat(dest): # problem in creating the symlink self.logger(logging.ERROR, 'Symlink {} could not be created'.format(dest)) raise exception.DestinationNotAccessible() if not self.attributes.get['ignore_broken_link', False] and not os.path.exists(dest): # could not find the file following the symlink self.logger(logging.ERROR, 'Symlink {} appears to be a broken link to {}' .format(dest, path)) if os.lstat(dest) and os.path.islink(dest): os.unlink(dest) raise exception.SourceNotFound() def pfn2path(self, pfn): # obtain path and sanitise from multiple slashes, etc path = os.path.normpath(super().pfn2path(pfn)) self.logger(logging.DEBUG, 'Extracted path: {} from: {}'.format(path, pfn)) return path Loading
.gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ image-build: stage: build variables: RUCIO_TAG: 1.29.8 PROTOCOLS_VERSION: 0.1.0 PROTOCOLS_VERSION: 0.2.0 script: - > docker build Loading
rucio_protocols/posix.py 0 → 100644 +59 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- # Copyright European Organization for Nuclear Research (CERN) since 2012 # # Licensed under the Apache License, Version 2.0 (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 # # 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. import logging import os import os.path from rucio.common import exception from rucio.rse.protocols.posix import Default class Symlink(Default): """ Implementing access to RSEs using the local filesystem, creating a symlink on a get """ def get(self, pfn, dest, transfer_timeout=None): """ Provides access to files stored inside connected the RSE. A download/get will create a symlink on the local file system pointing to the underlying file. Other operations act directly on the remote file. :param pfn: Physical file name of requested file :param dest: Name and path of the files when stored at the client :param transfer_timeout Transfer timeout (in seconds) - dummy :raises DestinationNotAccessible: if the destination storage was not accessible. :raises ServiceUnavailable: if some generic error occured in the library. :raises SourceNotFound: if the source file was not found on the referred storage. """ path = self.pfn2path(pfn) os.symlink(path, dest) self.logger(logging.DEBUG, 'Symlink {} created for {} from {}' .format(dest, path, pfn)) if not os.lstat(dest): # problem in creating the symlink self.logger(logging.ERROR, 'Symlink {} could not be created'.format(dest)) raise exception.DestinationNotAccessible() if not self.attributes.get['ignore_broken_link', False] and not os.path.exists(dest): # could not find the file following the symlink self.logger(logging.ERROR, 'Symlink {} appears to be a broken link to {}' .format(dest, path)) if os.lstat(dest) and os.path.islink(dest): os.unlink(dest) raise exception.SourceNotFound() def pfn2path(self, pfn): # obtain path and sanitise from multiple slashes, etc path = os.path.normpath(super().pfn2path(pfn)) self.logger(logging.DEBUG, 'Extracted path: {} from: {}'.format(path, pfn)) return path