Beispiel #1
0
def Main():
    conn = M6.Connection("192.168.100.180:5050", "mdt", "123123", Database="mdt")
    c = conn.Cursor()
    c.SetFieldSep('|^|')
    c.SetRecordSep('\n')
    
    fail_cnt = 0
    mypath = "./dat_file"
    files = [f for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f)) and f.endswith(".dat")]
    file_list = []
    for file in files:
        os.path.join(mypath, file)
        file_list.append(os.path.join(mypath, file))
    for idx, file in enumerate(file_list):
        parse_list = files[idx][:-4].split("_")
        partition_date = parse_list[0]
        partition_key = "_".join([parse_list[1], parse_list[2]])
        print partition_date
        print partition_key
        load_str = c.Load('JP_MESH_SUMMARY', partition_key, partition_date, 'control_file.ctl', file)
        if load_str.strip().startswith("+OK"):
            pass
        else:
            fail_cnt += 1
        print load_str
    
    c.Close()
    conn.close()
    print "fail cnt : ", fail_cnt
Beispiel #2
0
    def selectCollectCheck(self, workId, lastChgDate):
        conn = None
        result = ''

        __LOG__.Trace("WORK_ID : %s , LAST_CHG_DATE : %s" %
                      (workId, lastChgDate))

        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """ SELECT COUNT(*)
					FROM TACS.TACS_WORK_COLLECT_CHECK
					WHERE WORK_ID = '%s' AND LAST_CHG_DATE = '%s'
				""" % (workId, lastChgDate)

            cursor.Execute2(sql)

            for oneRaw in cursor:
                result = oneRaw[0].encode('utf-8')

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #3
0
    def selectIpEmsData(self, emsIp):
        __LOG__.Trace('svrIp = %s' % emsIp)
        resultDict = {'vendor': '', 'eqpTyp': ''}
        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """
					SELECT SPLY_BP_ID, EQP_TYP
					FROM TACS.TNG_IM_EQP_BAS
					WHERE REP_IP_ADDR = '%s'
					""" % emsIp

            resultMsg = cursor.Execute2(sql)

            __LOG__.Trace(resultMsg)

            for oneRaw in cursor:
                resultDict['vendor'] = oneRaw[0].encode('utf-8')
                resultDict['eqpTyp'] = oneRaw[1].encode('utf-8')
        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return resultDict['vendor'], resultDict['eqpTyp']
Beispiel #4
0
    def selectIDX(self):
        conn = None
        result = ''
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """ SELECT IDX
					FROM TACS.TACS_WORK_INFO_IDX
				"""

            cursor.Execute2(sql)

            for oneRaw in cursor:
                result = oneRaw[0]

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #5
0
	def selectRelationCheck(self) :
		__LOG__.Trace('!! Relation Check !!')
		conn	= None
		result	= ''

		try :
			conn 	= M6.Connection(self.IRIS, self.IRIS_ID, self.IRIS_PASS, Database = 'tacs' )
			cursor 	= conn.cursor()

			sql	= """
					SELECT 
						RELATION_CHECK_YN
					FROM
						TACS.TACS_CORE_EMS_RELATION_CHECK
					LIMIT 1
				"""

			resultMsg = cursor.Execute2(sql)
			__LOG__.Trace(sql)
			__LOG__.Trace(resultMsg)

			if 'OK' in resultMsg :
				for oneRaw in cursor :
					result = oneRaw[0].encode('utf-8')

			else :
				__LOG__.Trace('Query Fail!! ')

		except :
			__LOG__.Exception()

		finally :
			if conn : conn.close()

		return result
Beispiel #6
0
    def deleteCollectCheck(self, workId, lastChgDate):
        conn = None
        __LOG__.Trace("WORK_ID : %s , LAST_CHG_DATE : %s" %
                      (workId, lastChgDate))

        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """ DELETE
					FROM TACS.TACS_WORK_COLLECT_CHECK
					WHERE WORK_ID = '%s' AND LAST_CHG_DATE = '%s'
				""" % (workId, lastChgDate)

            result = cursor.Execute2(sql)
            __LOG__.Trace("DELETE RESULT TACS.TACS_WORK_COLLECT_CHECK : %s" %
                          result)

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()
Beispiel #7
0
    def selectWorkInfoCnt(self, workId):
        workId = workId.strip()
        __LOG__.Trace('workId = %s' % workId)
        conn = None
        result = 0
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """
					SELECT COUNT(*) 
					FROM TACS.TACS_WORK_INFO
					WHERE WORK_ID = '%s'
					""" % workId

            cursor.Execute2(sql)

            for oneRaw in cursor:
                result = int(oneRaw.encode('utf-8'))

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #8
0
    def deleteWorkEqpInfo(self, workId, idx, key, partition):
        __LOG__.Trace('key : %s | partition : %s | workId : %s | idx : %s' %
                      (key, partition, workId, idx))

        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            workSql = """/*+ LOCATION( key = '%s' AND PARTITION = '%s' ) */
					DELETE 
					FROM TACS.TACS_WORK_INFO
					WHERE IDX = '%s' and WORK_ID = '%s' 
					""" % (key, partition, idx, workId)

            resultWorkMsg = cursor.Execute2(workSql)

            eqpSql = """/*+ LOCATION( key = '%s' AND PARTITION = '%s' ) */
					DELETE 
					FROM TACS.TACS_WORK_INFO
					WHERE IDX = '%s' and WORK_ID = '%s'
				""" % (key, partition, idx, workId)

            resultEqpMsg = cursor.Execute2(eqpSql)

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()
Beispiel #9
0
    def selectIdOmpData(self, tacsEqpId):
        tacsEqpId = tacsEqpId.strip()
        __LOG__.Trace('emsId = %s' % tacsEqpId)

        resultList = list()
        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """
				SELECT
					EQP_ID
				FROM
					TACS.TNG_IM_EQP_BAS
				WHERE 
					EMS_EQP_ID = '%s' AND EQP_TYP LIKE '%s'
				""" % (tacsEqpId, '%EMS')

            resultMsg = cursor.Execute2(sql)

            for oneRaw in cursor:
                resultList.append(oneRaw[0].encode('utf-8'))

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return resultList
Beispiel #10
0
    def selectNmEqpData(self, eqpNm):
        eqpNm = eqpNm.strip()
        __LOG__.Trace('eqpNm = %s' % eqpNm)
        conn = None
        result = ''
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """SELECT EQP_EMS_NM
					FROM TACS.TNG_IM_EQP_BAS
	      		    WHERE EQP_NM ='%s'""" % str(eqpNm)

            cursor.Execute2(sql)

            for oneRaw in cursor:
                result = oneRaw[0].encode('utf-8')

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #11
0
    def insertCollectCheck(self, workId, lastChgDate):
        conn = None
        __LOG__.Trace("WORK_ID : %s , LAST_CHG_DATE : %s" %
                      (workId, lastChgDate))

        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """ INSERT INTO TACS.TACS_WORK_COLLECT_CHECK(WORK_ID, LAST_CHG_DATE)
					VALUES('%s', '%s')
				""" % (workId, lastChgDate)

            result = cursor.Execute2(sql)
            __LOG__.Trace("INSERT RESULT TACS.TACS_WORK_COLLECT_CHECK : %s" %
                          result)

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()
Beispiel #12
0
	def selectNmEmsData (self, emsNm) :
		emsNm = emsNm.strip()
		__LOG__.Trace('emsNm = %s' % emsNm)
		resultDict = {'expEmsNm' : '' ,'expEmsIp' : '', 'vendor' : '', 'eqpTyp' : ''}
		conn 		= None
	
		try :
			conn = M6.Connection(self.IRIS, self.IRIS_ID, self.IRIS_PASS, Database='tacs')
			cursor = conn.cursor()	

			#ipList = '\'%s\'' % '\',\''.join(svrIpList)

			sql = """
				SELECT 
					EQP_NM, REP_IP_ADDR, SPLY_BP_ID, EQP_TYP
				FROM 
					TACS.TNG_IM_EQP_BAS 
				WHERE 
					EQP_EMS_NM = '%s' """ % emsNm

			resultMsg	= cursor.Execute2(sql)

			for oneRaw in cursor :
				resultDict['expEmsNm']	= oneRaw[0].encode('utf-8')
				resultDict['expEmsIp'] 	= oneRaw[1].encode('utf-8')
				resultDict['vendor']	= oneRaw[2].encode('utf-8')
				resultDict['eqpTyp'] 	= oneRaw[3].encode('utf-8')

		except :
			__LOG__.Exception()

		finally :
			if conn : conn.close()

		return resultDict['expEmsNm'], resultDict['expEmsIp'], resultDict['vendor'], resultDict['eqpTyp']
Beispiel #13
0
    def run(self):
        conn = M6.Connection(self.IRIS_MGR.IRIS_HOST, self.IRIS_MGR.ID,
                             self.IRIS_MGR.PWD)
        cur = conn.cursor()
        cur.SetFieldSep(self.IRIS_MGR.COLSEP)
        cur.SetRecordSep(self.IRIS_MGR.ROWSEP)

        csvFile = self.CSV_FILE.split('/')[-1]

        try:
            fileName = csvFile.rsplit('.', 1)[0]
            m = re.search("(\w+)_(\w+)_(\w+)", fileName)

            table = m.group(1)
            pat = m.group(2)
            key = m.group(3)

            print "(%s)(%s)(%s)(%s)\n" % (table, pat, key, self.CSV_FILE)

            retMessage = cur.Load(table, key, pat, self.CTL_FILE,
                                  self.CSV_FILE)
            if "+OK SUCCESS" in retMessage.strip():
                mvFile = "%s/%s" % (self.IRIS_MGR.LOAD_DONE_DIR, csvFile)
                os.rename(self.CSV_FILE, mvFile)
            else:
                __LOG__.Trace("%s" % retMessage.strip())
                mvFile = "%s/%s" % (self.IRIS_MGR.ERR_ETC_DIR, csvFile)
                os.rename(self.CSV_FILE, mvFile)

        except Exception, err:
            __LOG__.Exception()
            mvFile = "%s/%s" % (self.IRIS_MGR.ERR_LOAD_DIR, csvFile)
            os.rename(self.CSV_FILE, mvFile)
Beispiel #14
0
    def selectLkngUnit(self, emsIp):
        emsIp = emsIp.strip()
        __LOG__.Trace('emsIp : %s' % emsIp)
        conn = None
        resultDict = {'mqNm': '', 'unitDistYn': ''}
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()
            sql = "SELECT WORK_MQ_NM, UNIT_DIST_YN FROM TACS.TACS_TB_LNKG_UNIT WHERE EMS_IP = '%s'" % str(
                emsIp)
            cursor.Execute2(sql)

            for oneRaw in cursor:
                resultDict['mqNm'] = oneRaw[0].encode('utf-8')
                resultDict['unitDistYn'] = oneRaw[1].encode('utf-8')

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return resultDict
Beispiel #15
0
def main():
    conf = ConfigParser.ConfigParser()
    conf.read(sys.argv[1])
    host = conf.get('IRIS', 'IRIS_IP').strip()
    user = conf.get('IRIS', 'IRIS_ID').strip()
    pwd = conf.get('IRIS', 'IRIS_PWD').strip()
    tbl = conf.get('IRIS', 'TABLE').strip()

    conn = M6.Connection(host, user, pwd)
    c = conn.Cursor()
    c.SetFieldSep('|^|')
    c.SetRecordSep('\n')

    q = '''
    CREATE TABLE %s (
       k         TEXT,
       p         TEXT,
       a         TEXT
    )
    datascope       LOCAL
    ramexpire       30
    diskexpire      34200
    partitionkey    k
    partitiondate   p
    partitionrange  10
    ;
    ''' % tbl

    print c.Execute2(q)

    c.Close()
    conn.close()
Beispiel #16
0
    def updateEmsConnectCheck(self, emsIp, nowDate, firstConnDate,
                              connectCheck):
        __LOG__.Trace('emsIp : %s , nowDate : %s, firstConnDate : %s' %
                      (emsIp, nowDate, firstConnDate))
        result = ''
        try:
            conn = M6.Connection(self.IRIS_IP,
                                 self.IRIS_ID,
                                 self.IRIS_PW,
                                 Database=self.IRIS_DB)
            cursor = conn.cursor()
            sql = 'UPDATE TACS_TB_LNKG_UNIT '
            updateData = list()
            whereData = list()
            updateData.append(" SET CONN_YN = '%s'" % connectCheck)
            whereData.append(" WHERE EMS_IP = '%s'" % str(emsIp))

            if (firstConnDate == None
                    or firstConnDate == '') and 'Y' == connectCheck:
                updateData.append(" FIRST_CONN_DATE = '%s'" % str(nowDate))

            if 'Y' == connectCheck:
                updateData.append(" LAST_CONN_DATE = '%s'" % str(nowDate))

            updateQuery = ' '.join(
                [sql, ','.join(updateData), ','.join(whereData)])

            result = cursor.Execute2(updateQuery)

            cursor.Close()
            conn.close()
        except:
            __LOG__.Exception()

        return result
Beispiel #17
0
    def updateFirDate(self, connList, nowDate):
        result = ''
        try:
            conn = M6.Connection(self.IRIS_IP,
                                 self.IRIS_ID,
                                 self.IRIS_PW,
                                 Database=self.IRIS_DB)
            cursor = conn.cursor()

            ipList = '\'%s\'' % '\',\''.join(connList)

            sql = """ 
						UPDATE TACS_TB_LNKG_UNIT 
						SET CONN_YN = 'Y', FIRST_CONN_DATE = '%s' ,LAST_CONN_DATE = '%s'
						WHERE EMS_IP IN (%s)
						""" % (nowDate, nowDate, ipList)
            result = cursor.Execute2(sql)

            __LOG__.Trace('FirstDate Update : %s' % result)

            if cursor:
                cursor.Close()
            if conn:
                conn.close()
        except:
            __LOG__.Exception()

        return result
Beispiel #18
0
    def selectCheckTime(self, nowDate):
        checkCnt = ''
        try:
            conn = M6.Connection(self.IRIS_IP,
                                 self.IRIS_ID,
                                 self.IRIS_PW,
                                 Database=self.IRIS_DB)
            cursor = conn.cursor()

            sql = """
				SELECT 
					COUNT(*)
				FROM 
					TACS.TACS_EMS_CONNECTION_CHECK
				WHERE 
					EVNT_DATE = '%s'
				""" % nowDate

            cursor.Execute2(sql)

            for result in cursor:
                checkCnt = result[0].encode('utf-8')
        except:
            __LOG__.Exception()

        finally:
            cursor.Close()
            conn.close()

        return checkCnt
Beispiel #19
0
    def selectIpOtherEqpData(self, svrIpList, emsEqpId):
        __LOG__.Trace('svrIp = %s | parentEqpId : %s ' % (svrIpList, emsEqpId))
        conn = None
        result = ''
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            ipList = '\'%s\'' % '\',\''.join(svrIpList)

            if type(emsEqpId) is list:
                emsEqpId = '\'%s\'' % '\',\''.join(emsEqpId)
            elif type(emsEqpId) is str:
                emsEqpId = '\'%s\'' % emsEqpId
            else:
                __LOG__.Trace('TACS EQP ID invalid : %s' % emsEqpId)

            __LOG__.Trace(ipList)

            sql = """
					SELECT 
						EQP_EMS_NM 
					FROM 
						TACS.TNG_IM_EQP_BAS
					WHERE 
						(
							REP_IP_ADDR IN (%s)
							OR REP_IP_ADDR_1 IN (%s)
							OR REP_IP_ADDR_2 IN (%s)
							OR REP_IP_ADDR_3 IN (%s)
							OR REP_IP_ADDR_4 IN (%s)
							OR REP_IP_ADDR_5 IN (%s)
						) AND
						EMS_EQP_ID IN (%s)
					LIMIT 1
						""" % (ipList, ipList, ipList, ipList, ipList, ipList, emsEqpId)

            resultMsg = cursor.Execute2(sql)
            __LOG__.Trace(sql)
            __LOG__.Trace(resultMsg)

            if 'OK' in resultMsg:

                for oneRaw in cursor:
                    result = oneRaw[0].encode('utf-8')

            else:
                __LOG__.Trace('Query Fail!! ')

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()
            __LOG__.Trace(result)
        return result
Beispiel #20
0
    def execute(self, sql):
        conn = M6.Connection(self.IRIS_HOST, self.ID, self.PWD)
        cur = conn.cursor()
        cur.SetFieldSep(self.COLSEP)
        cur.SetRecordSep(self.ROWSEP)

        cur.Execute(sql)

        return (conn, cur)
Beispiel #21
0
    def updateDistributeYn(self, hint, workId, emsIp, workStaDate):
        __LOG__.Trace(
            'hint({}), workId({}), emsIp({}), workStaDate({})'.format(
                hint, workId, emsIp, workStaDate))
        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()
            selectSql = '''
				{}
				SELECT 
					MAX(IDX + 0) 
				FROM TACS.TACS_WORK_INFO 
				WHERE 
					WORK_ID = '{}'
				AND
					WORK_STA_DATE = '{}'
			'''.format(hint, workId, workStaDate)
            __LOG__.Trace('query: {}'.format(selectSql))
            cursor.Execute2(selectSql)

            idx = None
            for oneRow in cursor:
                idx = oneRow[0]

            if not idx:
                raise Exception('Unavailable IDX({})'.format(idx))

            updateSql = '''
					{}
					UPDATE  
			            TACS_EQP_INFO
				    SET
			            EXP_YN = 'Y'
			           	, EXP_DATE = SYSDATE
					WHERE
			            IDX = '{}'
					AND
			            EXP_VALID_YN = 'Y'
					AND
					(	EMS_IP = '{}'
					OR
		    			EXP_EMS_IP = '{}'
		     		)
					'''.format(hint, idx, emsIp, emsIp)
            __LOG__.Trace('query: {}'.format(selectSql))
            cursor.Execute2(updateSql)
        except Exception as e:
            __LOG__.Exception()

        finally:
            if conn:
                conn.close()
Beispiel #22
0
 def connect(self, host, user, pwd, direct, db):
     LOG.info('%s %s %s %s %s' % (host, user, pwd, str(direct), db))
     self.conn = M6.Connection(host,
                               str(user),
                               str(pwd),
                               Direct=direct,
                               Database=str(db))
     self.cursor = self.conn.Cursor()
     self.cursor.SetFieldSep(str(self.field_sep))
     self.cursor.SetRecordSep(str(self.record_sep))
     self.cursor.SetTimeout(self.timeout)
Beispiel #23
0
	def initConnect(self):
		self.conn = M6.Connection(self.IRIS, self.IRIS_ID, self.IRIS_PASS, Database='tacs')
		__LOG__.Trace('IRIS Connect!')
		try :
			self.cursor = self.conn.cursor()
			self.cursor.SetFieldSep('|^|')
			self.cursor.SetRecordSep('|^-^|')
		except :
			__LOG__.Exception()
		finally :
			self.conn.commit()
Beispiel #24
0
def m6_execute(query, is_select=False):
    conn = M6.Connection('127.0.0.1:5050', 'test', 'test')
    c = conn.Cursor()
    c.SetFieldSep('|^|')
    c.SetRecordSep('|^-^|')
    print
    print c.Execute2(query)
    if is_select:
        for row in c:
            print row
    c.Close()
    conn.close()
Beispiel #25
0
    def selectDate(self, workId, workStaDate):
        workIdKey = workId[-1]
        __LOG__.Trace('workIdKey = %s / workId = %s / workStaDate = %s' %
                      (workIdKey, workId, workStaDate))
        result = ''
        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql1 = """/*+ LOCATION( key = '%s' and partition = '%s' ) */
					SELECT MAX(IDX+0)
					FROM TACS.TACS_WORK_INFO
					WHERE WORK_ID = '%s'
					""" % (workIdKey, workStaDate, workId)

            cursor.Execute2(sql1)

            IDX = ''

            for oneRaw in cursor:
                IDX = oneRaw[0]

            sql2 = """/*+ LOCATION( key = '%s' and partition = '%s' ) */
					SELECT LAST_CHG_DATE
					FROM TACS.TACS_WORK_INFO 
					WHERE IDX = '%s' """ % (workIdKey, workStaDate, IDX)

            cursor.Execute2(sql2)

            lastChgDate = ''

            for oneRaw in cursor:
                result = oneRaw[0].encode('utf-8')

            __LOG__.Trace(result)

            cursor.Close()
            conn.close()

        except:

            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #26
0
    def selectIpEmsData(self, emsIp):
        emsIp = emsIp.strip()
        __LOG__.Trace('emsIp = %s' % emsIp)
        resultDict = {
            'tacsEqpId': '',
            'expEmsNm': '',
            'expEmsIp': '',
            'vendor': '',
            'eqpTyp': ''
        }
        conn = None
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            sql = """
					SELECT 
						EQP_NM, REP_IP_ADDR, SPLY_BP_ID, EQP_TYP, EQP_ID
					FROM 
						TACS.TNG_IM_EQP_BAS
					WHERE 
						EQP_TYP like '%EMS%'
					AND
						(REP_IP_ADDR = '{}'
						OR REP_IP_ADDR_1 = '{}'
						OR REP_IP_ADDR_2 = '{}'
						OR REP_IP_ADDR_3 = '{}'
						OR REP_IP_ADDR_4 = '{}'
						OR REP_IP_ADDR_5 = '{}')
					LIMIT 1
					""".format(emsIp, emsIp, emsIp, emsIp, emsIp, emsIp)

            resultMsg = cursor.Execute2(sql)

            for oneRaw in cursor:
                resultDict['expEmsNm'] = oneRaw[0].encode('utf-8')
                resultDict['expEmsIp'] = oneRaw[1].encode('utf-8')
                resultDict['vendor'] = oneRaw[2].encode('utf-8')
                resultDict['eqpTyp'] = oneRaw[3].encode('utf-8')
                resultDict['tacsEqpId'] = oneRaw[4].encode('utf-8')
        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return resultDict['expEmsNm'], resultDict['expEmsIp'], resultDict[
            'vendor'], resultDict['eqpTyp'], resultDict['tacsEqpId']
Beispiel #27
0
    def selectIpCommonEqpDataRelationOff(self, svrIpList):
        __LOG__.Trace('svrIp = %s | Realtion Off )' % (svrIpList))
        conn = None
        result = ''
        try:
            conn = M6.Connection(self.IRIS,
                                 self.IRIS_ID,
                                 self.IRIS_PASS,
                                 Database='tacs')
            cursor = conn.cursor()

            ipList = '\'%s\'' % '\',\''.join(svrIpList)

            __LOG__.Trace(ipList)

            sql = """
					SELECT 
						EQP_EMS_NM 
					FROM 
						TACS.TNG_IM_EQP_BAS
					WHERE 
						(
							REP_IP_ADDR IN (%s)
							OR REP_IP_ADDR_1 IN (%s)
							OR REP_IP_ADDR_2 IN (%s)
							OR REP_IP_ADDR_3 IN (%s)
							OR REP_IP_ADDR_4 IN (%s)
							OR REP_IP_ADDR_5 IN (%s)
						) 
					LIMIT 1
						""" % (ipList, ipList, ipList, ipList, ipList, ipList)

            resultMsg = cursor.Execute2(sql)
            __LOG__.Trace(sql)
            __LOG__.Trace(resultMsg)

            if 'OK' in resultMsg:

                for oneRaw in cursor:
                    result = oneRaw[0].encode('utf-8')

            else:
                __LOG__.Trace('Query Fail!! ')

        except:
            __LOG__.Exception()

        finally:
            if conn: conn.close()

        return result
Beispiel #28
0
def load(dat_path, table_name, ctl, dat):
    partition_date = dat_path.split("/")[-1].split(".")[0].replace("_",
                                                                   "") + "0000"
    conn = M6.Connection(info.host,
                         info.user_id,
                         info.user_passwd,
                         Direct=info.direct,
                         Database=info.database)
    c = conn.Cursor()
    c.SetFieldSep(info.field_sep)
    c.SetRecordSep(info.record_sep)
    start = time.time()
    print(c.LoadString(table_name, "0", partition_date, ctl, dat))
    print(time.time() - start)
Beispiel #29
0
	def irisInitConnection(self):
		try :
			conn = M6.Connection(self.IRIS, self.IRIS_ID, self.IRIS_PASS, Database = self.IRIS_DB)
			self.conn = conn

			cursor = conn.cursor()
			cursor.SetFieldSep('|^|')
			cursor.SetRecordSep('|^-^|')
			self.cursor = cursor

		except :
			__LOG__.Exception()
			time.sleep(60)
			self.irisInitConnection()
Beispiel #30
0
	def irisInitConnection(self) :
		conn = M6.Connection (self.IRIS_IP, self.IRIS_ID, self.IRIS_PW, Database = self.IRIS_DB)
		self.conn = conn

		try :
			cursor = conn.cursor()
			cursor.SetFieldSep('|^|')
			cursor.SetRecordSep('|^-^|')
			self.cursor	= cursor

		except :
			__LOG__.Exception()
			self.cursor.Close()
			conn.close()