text
stringlengths
81
112k
Returns all acquistion eras in dbs def listAcquisitionEras_CI(self, acq=''): """ Returns all acquistion eras in dbs """ try: acq = str(acq) except: dbsExceptionHandler('dbsException-invalid-input', 'aquistion_era_name given is not valid : %s'%acq) ...
Input dictionary has to have the following keys: acquisition_era_name, creation_date, create_by, start_date, end_date. it builds the correct dictionary for dao input and executes the dao def insertAcquisitionEra(self, businput): """ Input dictionary has to have the following keys: ...
Input dictionary has to have the following keys: acquisition_era_name, end_date. def UpdateAcqEraEndDate(self, acquisition_era_name ="", end_date=0): """ Input dictionary has to have the following keys: acquisition_era_name, end_date. """ if acquisition_era_name =="" or ...
returns id for a given application def execute(self, conn, app="", release_version="", pset_hash="", output_label="", global_tag='', transaction = False): """ returns id for a given application """ sql = self.sql binds = {} setAnd=False if not app == "": sql += " A...
Prepare the ordered lists of blocks based on input DATASET (note Block is different) 1. Get list of blocks from source 2. Check and see if these blocks are already at DST 3. Check if dataset has parents 4. Check if parent blocks are already at DST def prepareDatasetMigra...
Utility function, that comapares blocks of a dataset at source and dst and returns an ordered list of blocks not already at dst for migration def processDatasetBlocks(self, url, conn, inputdataset, order_counter): """ Utility function, that comapares blocks of a dataset at source and dst ...
check if input dataset has parents, check if any of the blocks are already at dst, prepare the ordered list and return it. url : source DBS url dataset : to be migrated dataset order_counter: the order in which migration happends. def getParentDatasetsOrderedList(self, url, conn...
Prepare the ordered lists of blocks based on input BLOCK 1. see if block already exists at dst (no need to migrate), raise "ALREADY EXISTS" 2. see if block exists at src & make sure the block's open_for_writing=0 3. see if block has parents 4. see if parent...
Method to remove pending or failed migration request from the queue. def removeMigrationRequest(self, migration_rqst): """ Method to remove pending or failed migration request from the queue. """ conn = self.dbi.connection() try: tran = conn.begin() self...
Method to insert use requests to MIGRATION_REQUESTS table. request keys: migration_url, migration_input def insertMigrationRequest(self, request): """ Method to insert use requests to MIGRATION_REQUESTS table. request keys: migration_url, migration_input """ conn = self....
get the status of the migration migratee : can be dataset or block_name def listMigrationRequests(self, migration_request_id="", block_name="", dataset="", user="", oldest=False): """ get the status of the migration migratee : can be dataset or block_name ...
get eveything of block that is has status = 0 and migration_request_id as specified. def listMigrationBlocks(self, migration_request_id=""): """ get eveything of block that is has status = 0 and migration_request_id as specified. """ conn = self.dbi.connection() try: ...
migration_status: 0=PENDING 1=IN PROGRESS 2=COMPLETED 3=FAILED (will be retried) 9=Terminally FAILED status change: 0 -> 1 1 -> 2 1 -> 3 1 -> 9 are only allowed changes for working through migration. 3 -> 1 is allowed for r...
migration_status: 0=PENDING 1=IN PROGRESS 2=COMPLETED 3=FAILED (will be retried) 9=Terminally FAILED status change: 0 -> 1 1 -> 2 1 -> 3 1 -> 9 are only allowed changes for working through migration. 3 -> 1 allowed for retry...
List block at src DBS def getSrcDatasetParents(self, url, dataset): """ List block at src DBS """ #resturl = "%s/datasetparents?dataset=%s" % (url, dataset) params={'dataset':dataset} return cjson.decode(self.callDBSService(url, 'datasetparents', params, {}))
List block at src DBS def getSrcBlockParents(self, url, block): """ List block at src DBS """ #blockname = block.replace("#", urllib.quote_plus('#')) #resturl = "%s/blockparents?block_name=%s" % (url, blockname) params={'block_name':block} return cjson.decode(sel...
Need to list all blocks of the dataset and its parents starting from the top For now just list the blocks from this dataset. Client type call... def getSrcBlocks(self, url, dataset="", block=""): """ Need to list all blocks of the dataset and its parents starting from the top Fo...
build dynamic sql based on daoinput def executeSingle( self, conn, daoinput, tablename, transaction = False): """build dynamic sql based on daoinput""" sql1 = " insert into %s%s( " %(self.owner, tablename) sql2 =" values(" "Now loop over all the input keys. We need to check if all the keys are valid !!!" ...
Helper to convert config values to boolean as ConfigParser do. def _cast_boolean(self, value): """ Helper to convert config values to boolean as ConfigParser do. """ if value.lower() not in self._BOOLEANS: raise ValueError('Not a boolean: %s' % value) return self._B...
Return the value for option or default if defined. def get(self, option, default=undefined, cast=undefined): """ Return the value for option or default if defined. """ if option in self.repository: value = self.repository.get(option) else: value = default...
Create a list for the 'install_requires' component of the setup function by parsing a requirements file def parse_requirements(requirements_file): """ Create a list for the 'install_requires' component of the setup function by parsing a requirements file """ if os.path.exists(requirement...
dataset: /a/b/c block: /a/b/c#d def execute(self, conn, dataset="", block_name="", data_tier_name="", origin_site_name="", logical_file_name="", run_num=-1, min_cdate=0, max_cdate=0, min_ldate=0, max_ldate=0, cdate=0, ldate=0, open_for_writing=-1, transaction = False): "...
Lists all primary dataset types if no user input is provided. def execute(self, conn, dsType = "", dataset="", transaction = False): """ Lists all primary dataset types if no user input is provided. """ sql = self.sql binds={} if not dsType and not dataset: ...
returns id for a given application def execute(self, conn, dataset="", logical_file_name="", app="", release_version="", pset_hash="", output_label ="", block_id=0, global_tag='', transaction = False): """ returns id for a given application """ #sql=self.sql binds = ...
block: /a/b/c#d def execute(self, conn, block_name="", transaction = False): """ block: /a/b/c#d """ if not conn: msg='Oracle/BlockParent/List. No DB connection found' dbsExceptionHandler('dbsException-failed-connect2host', msg, self.logger.exception) s...
optional parameter: logical_file_name, block_name, validFileOnly returns: logical_file_name, file_lumi_id, run_num, lumi_section_num def listFileLumis(self, logical_file_name="", block_name="", run_num=-1, validFileOnly=0, input_body=-1): """ optional parameter: logical_file_name, block_name, v...
required parameter: full block_name or dataset name. No wildcards allowed. run_num is optional. def listFileSummary(self, block_name="", dataset="", run_num=-1, validFileOnly=0, sumOverLumi=0): """ required parameter: full block_name or dataset name. No wildcards allowed. run_num is optional. "...
required parameter: logical_file_name or block_name returns: this_logical_file_name, parent_logical_file_name, parent_file_id def listFileParents(self, logical_file_name="", block_id=0, block_name=""): """ required parameter: logical_file_name or block_name returns: this_logical_file_na...
required parameter: block_name returns: [{child_parent_id_list: [(cid1, pid1), (cid2, pid2), ... (cidn, pidn)]}] def listFileParentsByLumi(self, block_name='', logical_file_name=[]): """ required parameter: block_name returns: [{child_parent_id_list: [(cid1, pid1), (cid2, pid2), ... (...
required parameter: logical_file_name or block_name or block_id returns: logical_file_name, child_logical_file_name, parent_file_id def listFileChildren(self, logical_file_name='', block_name='', block_id=0): """ required parameter: logical_file_name or block_name or block_id returns: l...
Used to toggle the status of a file from is_file_valid=1 (valid) to is_file_valid=0 (invalid) def updateStatus(self, logical_file_name, is_file_valid, lost, dataset): """ Used to toggle the status of a file from is_file_valid=1 (valid) to is_file_valid=0 (invalid) """ conn = self.dbi.c...
One of below parameter groups must be present: non-patterned dataset, non-patterned block, non-patterned dataset with lfn, non-patterned block with lfn, non-patterned lfn non-patterned lfn list def listFiles(self, dataset="", block_name="", logical_file_name="", release_version="", ...
This method supports bulk insert of files performing other operations such as setting Block and Dataset parentages, setting mapping between OutputConfigModules and File(s) etc. :param qInserts: True means that inserts will be queued instead of done immediately. INSERT QUEUE Manager will perform...
This is a special function for WMAgent only. input block_name: is a child block name. input chils_parent_id_list: is a list of file id of child, parent pair: [[cid1, pid1],[cid2,pid2],[cid3,pid3],...] The requirment for this API is 1. All the child files belong to the block. ...
increments the sequence `seqName` by default `Incremented by` and returns its value incCount: is UNUSED variable in Oracle implementation def increment(self, conn, seqName, transaction = False, incCount=1): """ increments the sequence `seqName` by default `Incremented by` and re...
List release versions def listReleaseVersions(self, release_version="", dataset='', logical_file_name=''): """ List release versions """ if dataset and ('%' in dataset or '*' in dataset): dbsExceptionHandler('dbsException-invalid-input', " DBSReleaseVersion/l...
Get CA Path to check the validity of the server host certificate on the client side def __search_ca_path(self): """ Get CA Path to check the validity of the server host certificate on the client side """ if "X509_CERT_DIR" in os.environ: self._ca_path = os.environ['X509_CERT...
Get the user credentials if they exist, otherwise throw an exception. This code was modified from DBSAPI/dbsHttpService.py and WMCore/Services/Requests.py def __search_cert_key(self): """ Get the user credentials if they exist, otherwise throw an exception. This code was modified from D...
Authorization function for general insert def authInsert(user, role, group, site): """ Authorization function for general insert """ if not role: return True for k, v in user['roles'].iteritems(): for g in v['group']: if k in role.get(g, '').split(':'): return ...
Interface for submitting a migration request. Required input keys: MIGRATION_URL: The source DBS url for migration. MIGRATION_INPUT: The block or dataset names to be migrated. def submit(self): """ Interface for submitting a migration request. Required input keys: ...
Interface to query status of a migration request In this preference order of input parameters : migration_rqst_id, block, dataset, user (if multi parameters are provided, only the precedence order is followed) def status(self, migration_rqst_id="", block_name="", dataset="", user=""): ...
Interface to remove a migration request from the queue. Only Permanent FAILED/9 and PENDING/0 requests can be removed (running and sucessed requests cannot be removed) def remove(self): """ Interface to remove a migration request from the queue. Only Permanent FAILED/9 and PENDI...
return {} if condition is not provided. def execute(self, conn, logical_file_name='', block_id=0, block_name='', transaction=False): """ return {} if condition is not provided. """ sql = '' binds = {} if logical_file_name: if isinstance(logical_file_name, ba...
takes required dataset parameter returns only parent dataset name def listDatasetParents(self, dataset=""): """ takes required dataset parameter returns only parent dataset name """ if( dataset == "" ): dbsExceptionHandler("dbsException-invalid-input", "DBSDa...
takes required dataset parameter returns only children dataset name def listDatasetChildren(self, dataset): """ takes required dataset parameter returns only children dataset name """ if( dataset == "" ): dbsExceptionHandler("dbsException-invalid-input", "DBS...
Used to toggle the status of a dataset is_dataset_valid=0/1 (invalid/valid) def updateStatus(self, dataset, is_dataset_valid): """ Used to toggle the status of a dataset is_dataset_valid=0/1 (invalid/valid) """ if( dataset == "" ): dbsExceptionHandler("dbsException-invalid...
Used to change the status of a dataset type (production/etc.) def updateType(self, dataset, dataset_access_type): """ Used to change the status of a dataset type (production/etc.) """ if( dataset == "" ): dbsExceptionHandler("dbsException-invalid-input", "DBSDataset/updateTy...
lists all datasets if dataset parameter is not given. The parameter can include % character. all other parameters are not wild card ones. def listDatasets(self, dataset="", parent_dataset="", is_dataset_valid=1, release_version="", pset_hash="", app_name="", o...
input dictionary must have the following keys: dataset, primary_ds_name(name), processed_ds(name), data_tier(name), acquisition_era(name), processing_version It may have following keys: physics_group(name), xtcrosssection, creation_date, create_by, last_modification_date, last_m...
Update origin_site_name for a given block_name def execute(self, conn, block_name, origin_site_name, transaction=False): """ Update origin_site_name for a given block_name """ if not conn: dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/Block/UpdateStatus. \ ...
increments the sequence `seqName` by default `Incremented by one` and returns its value def increment(self, conn, seqName, transaction = False, incCount=1): """ increments the sequence `seqName` by default `Incremented by one` and returns its value """ try: seqTable = "%sS...
List run known to DBS. def listRuns(self, run_num=-1, logical_file_name="", block_name="", dataset=""): """ List run known to DBS. """ if( '%' in logical_file_name or '%' in block_name or '%' in dataset ): dbsExceptionHandler('dbsException-invalid-input', ...
API to insert A primary dataset in DBS :param primaryDSObj: primary dataset object :type primaryDSObj: dict :key primary_ds_type: TYPE (out of valid types in DBS, MC, DATA) (Required) :key primary_ds_name: Name of the primary dataset (Required) def insertPrimaryDataset(self): "...
API to update the end_date of an acquisition era :param acquisition_era_name: acquisition_era_name to update (Required) :type acquisition_era_name: str :param end_date: end_date not zero (Required) :type end_date: int def updateAcqEraEndDate(self, acquisition_era_name ="", end_date=0):...
API to insert a bulk block :param blockDump: Output of the block dump command :type blockDump: dict def insertBulkBlock(self): """ API to insert a bulk block :param blockDump: Output of the block dump command :type blockDump: dict """ try: ...
API to insert a block into DBS :param blockObj: Block object :type blockObj: dict :key open_for_writing: Open For Writing (1/0) (Optional, default 1) :key block_size: Block Size (Optional, default 0) :key file_count: File Count (Optional, default 0) :key block_name: Bloc...
API to insert a list of file into DBS in DBS. Up to 10 files can be inserted in one request. :param qInserts: True means that inserts will be queued instead of done immediately. INSERT QUEUE Manager will perform the inserts, within few minutes. :type qInserts: bool :param filesList: List of dic...
API to update file status :param logical_file_name: logical_file_name to update (optional), but must have either a fln or a dataset :type logical_file_name: str :param is_file_valid: valid=1, invalid=0 (Required) :type is_file_valid: bool :param lost: default lost=0 (op...
Converts a CIDR like 192.168.0.0/24 into 2 parts: start: 3232235520 stop: 3232235775 def create_from_string(cls, cidr, label=None, whitelist=False): """ Converts a CIDR like 192.168.0.0/24 into 2 parts: start: 3232235520 stop: 3232235775 """ ...
Returns a queryset with matching IPNetwork objects for the given IP. def qs_for_ip(cls, ip_str): """ Returns a queryset with matching IPNetwork objects for the given IP. """ ip = int(netaddr.IPAddress(ip_str)) # ignore IPv6 addresses for now (4294967295 is 0xffffffff, aka the ...
Return True if provided IP exists in the blacklist and doesn't exist in the whitelist. Otherwise, return False. def matches_ip(cls, ip_str, read_preference=None): """ Return True if provided IP exists in the blacklist and doesn't exist in the whitelist. Otherwise, return False. ...
This utility function handles all dbs exceptions. It will log , raise exception based on input condition. It loggs the traceback on the server log. Send HTTPError 400 for invalid client input and HTTPError 404 for NOT FOUND required pre-existing condition. def dbsExceptionHandler(eCode='', message='', logger=...
simple execute def execute(self, conn, block_id="", transaction=False): """ simple execute """ if not conn: dbsExceptionHandler("dbsException-db-conn-failed", "Oracle/FileBuffer/List. Expects db connection from upper layer.") sql = self.sql binds = { "block_id" : block_id...
Lists all primary datasets if pattern is not provided. def execute(self, conn, primary_ds_name="", primary_ds_type="", transaction=False): """ Lists all primary datasets if pattern is not provided. """ sql = self.sql binds = {} #import pdb #pdb.set_trace() ...
configure pycurl proxy settings def configure_proxy(self, curl_object): """configure pycurl proxy settings""" curl_object.setopt(curl_object.PROXY, self._proxy_hostname) curl_object.setopt(curl_object.PROXYPORT, self._proxy_port) curl_object.setopt(curl_object.PROXYTYPE, curl_object.PRO...
daoinput must be validated to have the following keys: child_parent_id__list[[cid, pid],...], block_name def execute( self, conn, daoinput, transaction = False ): """ daoinput must be validated to have the following keys: child_parent_id__list[[cid, pid],...], block_name """ ...
for a given block_id def execute(self, conn, acquisition_era_name,end_date, transaction = False): """ for a given block_id """ if not conn: dbsExceptionHandler("dbsException-failed-connect2host", "dbs/dao/Oracle/AcquisitionEra/updateEndDate expects db connection from upper layer.", self....
daoinput keys: migration_status, migration_block_id, migration_request_id def execute(self, conn, daoinput, transaction = False): """ daoinput keys: migration_status, migration_block_id, migration_request_id """ #print daoinput['migration_block_id'] if not conn: dbsE...
file_id_list : file_id_list def execute(self, conn, file_id_list, transaction=False): """ file_id_list : file_id_list """ sql=self.sql binds={} if file_id_list: count=0 for an_id in file_id_list: if count > 0: sql += ", " sql += ":file_id_%s" %count binds.update({"file_id_%s" %count : an_id}) ...
returns id for a given application This always requires all four variables to be set, because you better have them in blockInsert def execute(self, conn, app, release_version, pset_hash, output_label, global_tag, transaction = False): """ returns id for a given application Thi...
This method is used at source server and gets the information on a single block that is being migrated. Try to return in a format to be ready for insert calls def dumpBlock(self, block_name): """ This method is used at source server and gets the information on a single blo...
Used to toggle the status of a block open_for_writing=1, open for writing, open_for_writing=0, closed def updateStatus(self, block_name="", open_for_writing=0): """ Used to toggle the status of a block open_for_writing=1, open for writing, open_for_writing=0, closed """ if open_for_writ...
Update the origin_site_name for a given block name def updateSiteName(self, block_name, origin_site_name): """ Update the origin_site_name for a given block name """ if not origin_site_name: dbsExceptionHandler('dbsException-invalid-input', "D...
list parents of a block def listBlockParents(self, block_name=""): """ list parents of a block """ if not block_name: msg = " DBSBlock/listBlockParents. Block_name must be provided as a string or a list. \ No wildcards allowed in block_name/s." db...
list parents of a block def listBlockChildren(self, block_name=""): """ list parents of a block """ if (not block_name) or re.search("['%','*']", block_name): dbsExceptionHandler("dbsException-invalid-input", "DBSBlock/listBlockChildren. Block_name must be provided." ) ...
dataset, block_name, data_tier_name or logical_file_name must be passed. def listBlocks(self, dataset="", block_name="", data_tier_name="", origin_site_name="", logical_file_name="", run_num=-1, min_cdate=0, max_cdate=0, min_ldate=0, max_ldate=0, cdate=0, ldate=0, open_for_writin...
This is the API to list all the blocks/datasets first generated in the site called origin_site_name, if origin_site_name is provided w/ no wildcards allow. If a fully spelled dataset is provided, then it will only list the blocks first generated from origin_site_name under the given dataset. def listBl...
Input dictionary has to have the following keys: blockname It may have: open_for_writing, origin_site(name), block_size, file_count, creation_date, create_by, last_modification_date, last_modified_by it builds the correct dictionary for dao input and executes th...
List data tier(s) def listDataTiers(self, data_tier_name=""): """ List data tier(s) """ if not isinstance(data_tier_name, basestring) : dbsExceptionHandler('dbsException-invalid-input', 'data_tier_name given is not valid : %s' % data_tier_name...
Lists all sites types if site_name is not provided. def execute(self, conn, site_name= "", transaction = False): """ Lists all sites types if site_name is not provided. """ sql = self.sql if site_name == "": result = self.dbi.processData(sql, conn=conn, transaction=t...
simple execute def execute(self, conn, logical_file_name={}, transaction=False): """ simple execute """ if not conn: dbsExceptionHandler("dbsException-db-conn-failed", "Oracle/FileBuffer/DeleteFiles. Expects db connection from upper layer.") self.dbi.processData(self.sql, logical...
List data-type/primary-ds-type def listDataType(self, dataType="", dataset=""): """ List data-type/primary-ds-type """ conn = self.dbi.connection() try: if dataset and dataType: dbsExceptionHandler('dbsException-invalid-input', "D...
Get the blocks that need to be migrated def getBlocks(self): """ Get the blocks that need to be migrated """ try: conn = self.dbi.connection() result = self.buflistblks.execute(conn) return result finally: if conn: ...
Get some files from the insert buffer def getBufferedFiles(self, block_id): """ Get some files from the insert buffer """ try: conn = self.dbi.connection() result = self.buflist.execute(conn, block_id) return result finally: ...
returns id for a given datatier name def execute(self, conn, data_tier_name='', transaction = False, cache=None): """ returns id for a given datatier name """ if cache: ret=cache.get("DATA_TIERS") if not ret==None: return ret sql = self.sql bind...
Lists the oldest request queued def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", transaction=False): """ Lists the oldest request queued """ binds = {} result = self.dbi.processData(self.sql, binds, conn, transaction) result ...
Returns all processing eras in dbs def listProcessingEras(self, processing_version=''): """ Returns all processing eras in dbs """ conn = self.dbi.connection() try: result = self.pelst.execute(conn, processing_version) return result finally: ...
Input dictionary has to have the following keys: processing_version, creation_date, create_by, description it builds the correct dictionary for dao input and executes the dao def insertProcessingEra(self, businput): """ Input dictionary has to have the following keys: processin...
Returns all physics groups if physics group names are not passed. def listPhysicsGroups(self, physics_group_name=""): """ Returns all physics groups if physics group names are not passed. """ if not isinstance(physics_group_name, basestring): dbsExceptionHandler('dbsExceptio...
SQL Generator to select from list of values in Oracle def create_token_generator(input_list): """SQL Generator to select from list of values in Oracle""" ###Generator trick from http://betteratoracle.com/posts/20-how-do-i-bind-a-variable-in-list ###The maximum length of the comma separated list is 4000 cha...
Simple method that returs list of all know DBS instances, instances known to this registry def getServices(self): """ Simple method that returs list of all know DBS instances, instances known to this registry """ try: conn = self.dbi.connection() result = self.se...
Add a service to service registry def addService(self): """ Add a service to service registry """ conn = self.dbi.connection() tran = conn.begin() try: body = request.body.read() service = cjson.decode(body) addthis = {} ...
required keys: migration_status, migration_request_id def execute(self, conn, daoinput, transaction = False): """ required keys: migration_status, migration_request_id """ if not conn: dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/MigrationRequests/UpdateR...
Lists all requests if pattern is not provided. def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", oldest= False, transaction=False): """ Lists all requests if pattern is not provided. """ sql = self.sql binds = {} if migration_r...
simple execute def execute(self, conn, logical_file_name, transaction=False): """ simple execute """ if not conn: dbsExceptionHandler("dbsException-db-conn-failed", "Oracle/FileBuffer/DeleteDupicates. Expects db connection from upper layer.") print(self.sql) self.dbi.processData(self....
block: /a/b/c#d def execute(self, conn, block_name="", transaction = False): """ block: /a/b/c#d """ if not conn: dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/BlockParent/List. Expects db connection from upper layer.", self.logger.exception) sql = self.s...
origin_site_name: T1_US_FNAL_Buffer dataset: /a/b/c block_name: /a/b/c#d def execute(self, conn, origin_site_name="", dataset="", block_name="", transaction = False): """ origin_site_name: T1_US_FNAL_Buffer dataset: /a/b/c block_name: /a/b/c#d """ if not...
Returns all primary dataset if primary_ds_name or primary_ds_type are not passed. def listPrimaryDatasets(self, primary_ds_name="", primary_ds_type=""): """ Returns all primary dataset if primary_ds_name or primary_ds_type are not passed. """ conn = self.dbi.connection() try: ...
Returns all primary dataset types if dataset or primary_ds_type are not passed. def listPrimaryDSTypes(self, primary_ds_type="", dataset=""): """ Returns all primary dataset types if dataset or primary_ds_type are not passed. """ conn = self.dbi.connection() try: res...
Input dictionary has to have the following keys: primary_ds_name, primary_ds_type, creation_date, create_by. it builds the correct dictionary for dao input and executes the dao def insertPrimaryDataset(self, businput): """ Input dictionary has to have the following keys: primary...