def post(self): """ Resurrect DIDs. .. :quickref: Resurrect; Resurrect DID. HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error """ dids = json_list() try: resurrect(dids=dids, issuer=request.environ.get('issuer'), vo=request.environ.get('vo')) except DataIdentifierNotFound as error: return generate_http_error_flask(404, error) except (DuplicateContent, DataIdentifierAlreadyExists, UnsupportedOperation) as error: return generate_http_error_flask(409, error) except AccessDenied as error: return generate_http_error_flask(401, error) return 'Created', 201
def post(self): """ Resurrect DIDs. .. :quickref: Resurrect; Resurrect DID. HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error """ json_data = request.data try: dids = loads(json_data) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: resurrect(dids=dids, issuer=request.environ.get('issuer')) except DataIdentifierNotFound, error: return generate_http_error_flask(404, 'DataIdentifierNotFound', error.args[0][0])
def POST(self): """ Resurrect DIDs. HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error """ json_data = data() try: dids = loads(json_data) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: resurrect(dids=dids, issuer=ctx.env.get('issuer')) except DataIdentifierNotFound, error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0][0])
def post(self): """ Resurrect DIDs. .. :quickref: Resurrect; Resurrect DID. HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error """ json_data = request.data try: dids = loads(json_data) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list') try: resurrect(dids=dids, issuer=request.environ.get('issuer')) except DataIdentifierNotFound as error: return generate_http_error_flask(404, 'DataIdentifierNotFound', error.args[0]) except DuplicateContent as error: return generate_http_error_flask(409, 'DuplicateContent', error.args[0]) except DataIdentifierAlreadyExists as error: return generate_http_error_flask(409, 'DataIdentifierAlreadyExists', error.args[0]) except AccessDenied as error: return generate_http_error_flask(401, 'AccessDenied', error.args[0]) except UnsupportedOperation as error: return generate_http_error_flask(409, 'UnsupportedOperation', error.args[0]) except DatabaseException as error: return generate_http_error_flask(500, 'DatabaseException', error.args[0]) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: print format_exc() return error, 500 return "Created", 201
def add_missing_replicas(self, missing): """ :param missing: possible missing lfns :return: """ with monitor.record_timer_block('cms_sync.time_add_replica'): if missing and self.dry_run: logging.info('Dry run: Adding replicas %s to rse %s.', str(missing), self.rse) elif missing: logging.info('Adding %s replicas to rse %s.', len(missing), self.rse) replicas_to_add = [self.replicas[lfn] for lfn in missing] files = replica_file_list(replicas=replicas_to_add, scope=self.scope) for rucio_file in files: try: update_file = copy.deepcopy(rucio_file) update_file.update({'scope': InternalScope(self.scope), "rse_id": self.rse_id, "state": "A"}) update_replicas_states(replicas=[update_file], add_tombstone=False) except ReplicaNotFound: resurrect_file = copy.deepcopy(rucio_file) resurrect_file.update({'scope': 'cms', 'type': 'FILE'}) try: add_replicas(rse=self.rse, files=[resurrect_file], issuer=self.account, ignore_availability=True) except RucioException: logging.critical('Could not add %s to %s. Constraint violated?', resurrect_file, self.rse) resurrect_file.update({'scope': 'cms', 'type': 'FILE'}) # Reset to Internal scope by call resurrect([resurrect_file], issuer=self.account) resurrect_file.update({'scope': 'cms', 'type': 'FILE'}) # Reset to Internal scope by call add_replicas(rse=self.rse, files=[resurrect_file], issuer=self.account, ignore_availability=True) logging.critical('Resurrected %s at %s', resurrect_file, self.rse) # add_replicas(rse=self.rse, files=files, issuer=self.account) lfns = [item['name'] for item in list_files(scope=self.scope, name=self.block_name, long=False)] missing_lfns = list(set(missing) - set(lfns)) if missing_lfns: logging.debug('Attaching %s lfns to %s at %s', len(missing_lfns), self.block_name, self.rse) dids = [{'scope': self.scope, 'name': lfn} for lfn in missing_lfns] try: attach_dids(scope=self.scope, name=self.block_name, attachment={'dids': dids}, issuer=self.account) except FileAlreadyExists: logging.warning('Trying to attach already existing files to %s', self.block_name) except DataIdentifierNotFound: logging.critical('Could not attach to %s at %s. Constraint violated?', self.block_name, self.rse) return len(missing_lfns)
def POST(self): """ Resurrect DIDs. HTTP Success: 201 Created HTTP Error: 401 Unauthorized 404 Not Found 409 Conflict 500 Internal Error """ json_data = data() try: dids = loads(json_data) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') try: resurrect(dids=dids, issuer=ctx.env.get('issuer'), vo=ctx.env.get('vo')) except DataIdentifierNotFound as error: raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0]) except DuplicateContent as error: raise generate_http_error(409, 'DuplicateContent', error.args[0]) except DataIdentifierAlreadyExists as error: raise generate_http_error(409, 'DataIdentifierAlreadyExists', error.args[0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except UnsupportedOperation as error: raise generate_http_error(409, 'UnsupportedOperation', error.args[0]) except DatabaseException as error: raise generate_http_error(500, 'DatabaseException', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) raise Created()