Beispiel #1
0
 def db_get_all_TCcommands(self):
     """ function return:
      dict {tcdaemonName:StartCommand } and
      list ['command','params','processName',"Type",'psu_string']
      dict {Type: [processName1 ,processName2] }
      dict {'daemonName' : 'psu_string'}        
      dicy {daemonName' :"pass String"}"""
     data = subproc_popen(sqlplus_query(self.GetTCDaemonsCMDsQuery,db))#Run DataBase query to get TC commands
     type_to_names ={}
     name_to_psuString ={} 
     name_to_logFormat={}
     name_to_logLocation={}
     TCDaemons={} 
     name_to_passStr={}
     DaemonData =[]
       
     DaemonData=str(data[0]).rstrip('\n')#Remove last enter in the response and copy tuple to the list        
     DaemonData=str(DaemonData).split('\n')# split the list by '\n' will create list of lists .list per daemon
     i=0
     for daemon in DaemonData:
         DaemonData[i] =daemon.split('#') #go over list of lists and for each one of lists split using predefined '#' sign in query
         DaemonData[i].extend([DaemonData[i][2].rstrip(string.digits)])
         DaemonData[i].extend([self.get_psu_string(DaemonData[i][3],DaemonData[i][2])])
         TCDaemons.update({DaemonData[i][2]: DaemonData[i][0] +'"' + DaemonData[i][1]+ ' "' })#insert daemon name and its command to dictionary
         name_to_psuString.update({ DaemonData[i][2] : DaemonData[i][4] })
         name_to_passStr.update({ DaemonData[i][2] :self.LOG_PASS_STR})
         name_to_logLocation.update({ DaemonData[i][2] : self.get_log_path() })
         name_to_logFormat.update({ DaemonData[i][2] : '*'+DaemonData[i][2]+'*.log*'  })
         if DaemonData[i][3] in type_to_names:
            type_to_names[DaemonData[i][3]].extend( [DaemonData[i][2]] ) 
         else:
            type_to_names.update({  DaemonData[i][3] : [DaemonData[i][2]]}) 
         i=i+1
     return TCDaemons ,DaemonData,type_to_names,name_to_psuString,name_to_passStr,name_to_logLocation,name_to_logFormat
Beispiel #2
0
def wait_db_update(query, db, timeout=120):
    isDbUpdated = False
    timer = 0
    count = 0
    while isDbUpdated == False and timer <= timeout:
        data = subproc_popen(sqlplus_query(query, db))
        count = int(str(data[0]).rstrip('\n'))
        if count > 0:
            isDbUpdated = True
        elif count == 0:
            time.sleep(1)
            timer += 1
    return count
Beispiel #3
0
 def clean_trb(self):
     logger.info("Cleaning TRB tables... ")
     TRB_QRY = '''delete from TRB1_AMC_HISTORY;
    delete from TRB1_AUDIT_INTERVAL;
    delete from TRB1_ENG_CNTRL;
    delete from TRB1_ERR_DEPENDENT;
    delete from TRB1_IMP_PERIOD;
    delete from TRB1_MEMBER_ADMIN;
    delete from TRB1_MONITOR_INFO;
    delete from TRB1_QUE_CNTRL;
    delete from TRB1_RECV_DATA;
    delete from TRB1_SUB_APPL_CNTRL;
    delete from TRB1_THR_CNTRL;
    delete from TRB1_USER_CONFIG;
    delete from TRB1_SUB_APPL_CNTRL;
    delete from TRB1_ERR_DEPENDENT;
    commit;'''
     data = subproc_popen(sqlplus_query(TRB_QRY, db, set_echo='On'))
     print_data(data)
Beispiel #4
0
 def update_ar1_control(self, proc_name='AR1BILINTER'):
     AR1_CNTRL_QRY = '''update ar1_control shutdown_flag='Y' where  CONTROL_APPLICATION_ID ='AR1BILINTER';commit;'''
     data = subproc_popen(sqlplus_query(AR1_CNTRL_QRY, db, set_echo='On'))
     print_data(data)
Beispiel #5
0
def run_sql(sql_cmd, db):
    data = subproc_popen(sqlplus_query(sql_cmd, db))
    return data
Beispiel #6
0
    def run_cycle_maint(self,date=None,CleanInd="Y"):
        """ running cycle maintanence , when indicator is Y will clean existing Cycle instances from tables
        when date is None will set LD to be sytemDate"""
        ClnTRB="""delete from trb1_pub_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_mst_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_sub_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%' 
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_sub_errs where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%' 
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  commit;"""
                  
        ClnCycleInstData="""delete ADJ1_CYCLE_STATE;
                            delete BL1_CYCLE_CONTROL;
                            delete CM1_CYCLE_INSTANCE;
                            delete  RPL1_CYCLE_INSTANCE;
                            commit;"""
                            
        InstanceCount="""select trim(count(*)) from bl1_cycle_control where cycle_code=(select CYCLE_CODE 
                          from bl1_cycle_code where FREQUENCY='M' and rownum <=1)  and trunc(END_DATE) >= 
                           (select distinct(logical_date) from logical_date 
                            where LOGICAL_DATE_TYPE='B' and EXPIRATION_DATE is null);"""   
        CheckTRBErrs ='''select count(*) from TRB1_SUB_ERRS where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
          or GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';'''
        GetTRBErrs ='''select ERROR_TEXT1  from TRB1_SUB_ERRS where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
          or GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';'''
        CheckCM="""Select count(*) from CM1_CYCLE_INSTANCE"""
        CheckADJ="""Select count(*) from ADJ1_CYCLE_STATE"""
                            
        ValBTLSOR =""""""              
                  

        self.handle_daemons('Stop','BLBDI');
        #self.stop_daemons('BL1CYCLEMAINT') # need to update function to woth without PSU string or to write new 
        logger.info("Cleaning TRB tables....")
        data = subproc_popen(sqlplus_query(ClnTRB,db,set_echo='On')); 
        print_data(data);
        if (CleanInd=='Y'):
            logger.info("Cleaning all Cycle instances ....")
            data= subproc_popen(sqlplus_query(ClnCycleInstData,db,set_echo='On'));
            print_data(data);
        logger.info("Updating Logical Date ....")
        if date:   
            set_logical_date(date,'N')
        else:
            set_logical_date('sysdate','N')#will set to sysdate     
                           
        self.handle_daemons('Trigger' ,'AMC_SERVER', 'AMC_DAEMON_MANAGER' , 'TRB', 'INVOKER1' ,'INVOKER2' ,'INVOKER10' , 'BTLSOR' ,'BTLQUOTE')
        self.RunJob('BL1CYCLEMAINT','ENDDAY');
        #Check invoicing is updated
        if wait_db_update(InstanceCount,db) < 2:
            logger.error("BL1_CYCLE_CONTROL was not updated ,Check that Trx 2006 was Processed")
            return
        else:
            logger.info("BL1_CYCLE_CONTROL is updated!")
        time.sleep(10)#waiting for BTLSOR to finish all entries 
        logger.info("Checking CM tables..")
        if wait_db_update(CheckCM,db) < 2:
            logger.error("CM1_CYCLE_INSTANCE is not updated check TRB Tables")
            return
        else:
            logger.info("CM tables are updated.... " + ( subproc_popen(sqlplus_query(CheckCM,db)) )[0].rstrip('/n') +" entries found" )
        logger.info("Running ADJ1CYCMNTEOD ...")
        self.RunJob('ADJ1CYCMNTEOD','ENDDAY');
        #if wait_db_update(InstanceCount,db) < 2:
            
        logger.info("Wating for requests to be processed...")
        #CheckADJ is update is Updated 
        if wait_db_update(CheckADJ,db) <2:
            logger.error("ADJtable is not populated ,check TRB for 3017")
            logger.error( ( subproc_popen(sqlplus_query(CheckADJ,db)) )[0].rstrip('/n') )
            return
        else:
            logger.info("ADJ1_CYCLE_STATE is populated .... " + ( subproc_popen(sqlplus_query(CheckADJ,db)) )[0].rstrip('/n') +" entries found" )       

        # check no errors in TRB 
        if wait_db_update(CheckTRBErrs,db,timeout=0) > 0:
            logger.error("TRB error is detected for Cycle Maintanence")
            logger.error( ( subproc_popen(sqlplus_query(GetTRBErrs,db)) )[0].rstrip('/n') )
            return
        else:
            logger.info("No TRB Errors detected.... ")