summaryrefslogtreecommitdiffstats
path: root/notFinishedCode/tricode/gsmselftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'notFinishedCode/tricode/gsmselftest.py')
-rwxr-xr-xnotFinishedCode/tricode/gsmselftest.py783
1 files changed, 783 insertions, 0 deletions
diff --git a/notFinishedCode/tricode/gsmselftest.py b/notFinishedCode/tricode/gsmselftest.py
new file mode 100755
index 0000000..3e82b27
--- /dev/null
+++ b/notFinishedCode/tricode/gsmselftest.py
@@ -0,0 +1,783 @@
+#! /usr/bin/env python
+import sys
+import ControllerClass
+import DbClass
+import PingClass
+from time import sleep
+
+global resultsList
+resultsList = list()
+
+def ping(handler):
+
+ global serverStatus
+
+ if handler == 'landline':
+ server = PingClass.Ping('sipgate.de')
+ serverStatus = server.ping(1)
+
+ elif handler == 'sip':
+ server = PingClass.Ping('132.230.4.8')
+ serverStatus = server.ping(1)
+
+ elif handler == 'unisip':
+ server = PingClass.Ping('132.230.252.228')
+ serverStatus = server.ping(1)
+
+ elif handler == 'GSMRZ3':
+ server = PingClass.Ping('localhost')
+ serverStatus = server.ping(1)
+
+ elif handler == 'GSMRZ2':
+ server = PingClass.Ping('10.4.58.241')
+ serverStatus = server.ping(1)
+ else:
+ serverStatus = 1
+
+def allPing():
+
+ global sipGate
+ global sipServer
+ global unisip
+ global gsmBox1
+ global gsmBox2
+
+ server = PingClass.Ping('sipgate.de')
+ sipGate = server.ping(1)
+
+ server = PingClass.Ping('132.230.4.8')
+ sipServer = server.ping(1)
+
+ server = PingClass.Ping('132.230.252.228')
+ unisip = server.ping(1)
+
+ server = PingClass.Ping('localhost')
+ gsmBox1 = server.ping(1)
+
+ server = PingClass.Ping('10.4.58.241')
+ gsmBox2 = server.ping(1)
+
+def initDB():
+ global dbStatus
+ global db
+
+ db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+ db.connectDB()
+ dbStatus = db.connectDB()
+
+def initTest(callFrom,callTo):
+ global dest
+ global caller
+ global callAdd
+ global accCaller
+ global recAdd
+ global destNo
+ global accDest
+ global result
+ global repeatTest
+
+ initDB()
+
+ if dbStatus != 0:
+
+ dest = db.deviceAddress(str(callTo))
+
+ caller = db.deviceAddress(str(callFrom))
+
+ callAdd = caller[0]
+ accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
+
+ destAdd = dest[0]
+ destNo = dest[1]
+ accDest = dest[2]+':'+dest[3]+':'+dest[4]+':'
+
+ makeTest = ControllerClass.doTheTest(callFrom, callAdd, accCaller, callTo, destAdd, destNo, accDest)
+ makeTest.FuncTest()
+
+ result = str(makeTest.testResult)
+
+ else:
+ print "No connection to Database"
+
+ return result
+
+def initTrueTable():
+ nanoBTS1 = None
+ nanoBTS2 = None
+ nanoBTS3 = None
+ o2Card = None
+ eplusCard = None
+ vodaCard = None
+ tmobileCard = None
+ outgoingLandline = None
+ asteriskServer = None
+
+ for x in resultsList:
+
+ destination = x[1]
+ result = x[2]
+ caller = x[0]
+
+ if destination == 'GSMRZ1':
+ if result =='486':
+ nanoBTS1 = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMRZ1':
+ if result == '200':
+ nanoBTS1 = True
+
+ if destination == 'GSMRZ1':
+ if result == '200':
+ nanoBTS1 = True
+ elif result =='200':
+ nanoBTS1 = True
+
+ elif destination == 'GSMRZ2':
+ if result =='486':
+ nanoBTS2 = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMRZ2':
+ if result == '200':
+ nanoBTS2 = True
+
+ if destination == 'GSMRZ2':
+ if result == '200':
+ nanoBTS2 = True
+ elif result =='200':
+ nanoBTS2 = True
+
+ elif destination == 'GSMRZ3':
+ if result =='486':
+ nanoBTS3 = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMRZ3':
+ if result == '200':
+ nanoBTS3 = True
+
+ if destination == 'GSMRZ2':
+ if result == '200':
+ nanoBTS3 = True
+ elif result =='200':
+ nanoBTS3 = True
+
+ elif destination == 'GSMExt.O2':
+ if result =='486':
+ o2Card = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMExt.O2':
+ if result == '200':
+ o2Card = True
+
+ if destination == 'GSMExt.O2':
+ if result == '200':
+ o2Card = True
+ elif result =='200':
+ o2Card = True
+
+ elif destination == 'GSMExt.Voda':
+ if result =='486':
+ vodaCard = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMExt.Voda':
+ if result == '200':
+ vodaCard = True
+
+ if destination == 'GSMExt.Voda':
+ if result == '200':
+ vodaCard = True
+ elif result =='200':
+ vodaCard = True
+
+ elif destination == 'GSMExt.Eplus':
+ if result =='486':
+ eplusCard = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMExt.Eplus':
+ if result == '200':
+ eplusCard = True
+
+ if destination == 'GSMExt.Eplus':
+ if result == '200':
+ eplusCard = True
+ elif result =='200':
+ eplusCard = True
+
+ elif destination == 'GSMExt.Tm':
+ if result =='486':
+ tmobileCard = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'GSMExt.Tm':
+ if result == '200':
+ tmobileCard = True
+
+ if destination == 'GSMExt.Tm':
+ if result == '200':
+ tmobileCard = True
+ elif result =='200':
+ tmobileCard = True
+
+ elif destination == 'sip':
+ if result =='486':
+ asteriskServer = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if call == 'sip':
+ if result == '200':
+ asteriskServer = True
+
+ if destination == 'sip':
+ if result == '200':
+ asteriskServer = True
+
+ elif result =='200':
+ asteriskServer = True
+
+ if caller == 'GSMRZ1' or caller == 'GSMRZ2' or caller == 'GSMRZ3':
+
+ if destination == 'landline':
+ if result =='486':
+ outgoingLandline = False
+ for y in resultsList:
+ call = y[0]
+ destination = y[1]
+ result = y[2]
+ if caller == 'GSMRZ1' or caller == 'GSMRZ2' or caller == 'GSMRZ3':
+ if destination == 'landline':
+ if result == '200':
+ outgoingLandline = True
+
+ print '\n'
+ if o2Card == False and eplusCard == False and vodaCard == False and tmobileCard == False:
+ print 'GSM BOX Modem down'
+ else:
+ if o2Card == False:
+ print "O2 card indicate having problem"
+ if eplusCard == False:
+ print "eplus card indicate having problem"
+ if vodaCard == False:
+ print "vodaphone card indicate having problem"
+ if tmobileCard == False:
+ print "T-Mobile card indicate having problem"
+ print '\n'
+
+ if nanoBTS1 == False and nanoBTS2 == False and nanoBTS3 == False:
+ print 'openBSC down'
+ else:
+ if nanoBTS1 == False:
+ print "nanoBTS 1 indicate having problem"
+ if nanoBTS2 == False:
+ print "nanoBTS 2 indicate having problem"
+ if nanoBTS3 == False:
+ print "nanoBTS 3 indicate having problem"
+
+ if outgoingLandline == False:
+ print 'outgoing from GSM RZ to landline having problem'
+ print '\n'
+
+ if asteriskServer == False:
+ print "Asterisk server indicate having problem"
+ elif asteriskServer == True:
+ print 'Asterisk server working good'
+ print '\n'
+
+
+def doTest(callFrom,callTo):
+ ping(callFrom)
+
+ if serverStatus <> 0:
+
+ ping(callTo)
+ if serverStatus <> 0:
+ print 'Call From : ', callFrom
+ print 'Call Destination : ', callTo
+ initTest(callFrom,callTo)
+ resultsList.append([callFrom, callTo, result])
+ db.errorCode(result)
+ print 'Result : ' +result+ ' ' +db.errCode
+ sleep(5)
+ else:
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ print '[failed] 500 '+callFrom+ ' Server Internal Error'
+
+def doSipTest():
+
+ print '--SIP Part Test--'
+ destList = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
+ for callTo in destList:
+
+ callFrom = 'sip'
+ doTest(callFrom, callTo)
+
+def doLandlineTest():
+
+ print '--Landline Part Test--'
+ destList = ['GSMRZ1','unisip', 'sip']
+
+ for callTo in destList:
+
+ callFrom = 'landline'
+ doTest(callFrom, callTo)
+
+def doGsmrzTest():
+
+ print '--GSM Part Test--'
+ destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
+ callList = ['sip']
+
+ for callFrom in callList:
+
+ for callTo in destList:
+ doTest(callFrom, callTo)
+ resultsList.append([callFrom, callTo, result])
+ initTrueTable()
+
+def doGsmExtTest():
+
+ destList = ['GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm']
+ callList = ['sip']
+
+ for callFrom in callList:
+ for callTo in destList:
+ doTest(callFrom, callTo)
+ resultsList.append([callFrom, callTo, result])
+ initTrueTable()
+
+def doAllTest():
+
+ doSipTest()
+ doLandlineTest()
+ doGsmrzTest()
+ doGsmExtTest()
+
+def smartTest():
+ ping('sip')
+ if serverStatus == 0:
+ print "Dont have connection to SIP Asterisk server, can't make a test"
+ sys.exit(1)
+
+ callerList = ['sip']
+ destinationList = ['SIP', 'GSMExt']
+ #destinationList = ['GSMExt', 'GSMRZ', 'SIP', 'RZOutgoing', 'RZincoming']
+ for callFrom in callerList:
+ for destination in destinationList:
+
+ if destination == 'GSMRZ':
+ print "make a call to GSMRZ1"
+ initTest(callFrom,'GSMRZ1')
+
+ if result == '200':
+ print "make a call to GSMRZ2"
+ initTest(callFrom,'GSMRZ2')
+
+ if result == '200':
+ print "make a call to GSMRZ3"
+ initTest(callFrom,'GSMRZ3')
+
+ if result == '200':
+ print "all network on GSMRZ are working"
+ elif result == '486':
+ print "BTS 3 Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to GSMRZ3"
+ initTest(callFrom,'GSMRZ3')
+
+ if result == '200':
+ print "BTS 2 Down"
+ elif result == '486':
+ print "BTS 2 and 3 indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to GSMRZ2"
+ initTest(callFrom,'GSMRZ2')
+
+ if result == '200':
+ print "make a call to GSMRZ3"
+ initTest(callFrom,'GSMRZ3')
+
+ if result == '200':
+ print "BTS 1 Down"
+ elif result == '486':
+ print "BTS 1 & 3 indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+ print "make a call to GSMRZ3"
+
+ if result == '200':
+ print "BTS 1 & 2 indicate having problem"
+ elif result == '486':
+ print "OpenBSc Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+
+ elif destination == 'GSMExt':
+
+ initTest(callFrom,'GSMExt.O2')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Voda')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Eplus')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "All network on GSM external are working"
+ elif result == '486':
+ print "T-Mobile card indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "E-Plus card indicate having problem"
+ elif result == '486':
+ print "T-Mobile and E-Plus card indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Eplus')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "Vodaphone card indicate having problem"
+ elif result == '486':
+ print "T-Mobile and Vodaphone cards indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "Vodaphone and E-Plus card indicate having problem"
+ elif result == '486':
+ print "T-Mobile, E-Plus and Vodaphone cards indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "Incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Voda')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Eplus')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "O2 card indicate having problem"
+ elif result == '486':
+ print "T-Mobile and O2 cards indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "O2 and E-Plus cards indicate having problem"
+ elif result == '486':
+ print "T-Mobile, E-Plus and O2 cards indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Eplus')
+ if result == '200':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "O2 and Vodaphone cards indicate having problem"
+ elif result == '486':
+ print "T-Mobile, O2 and Vodaphone cards indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '486':
+
+ initTest(callFrom,'GSMExt.Tm')
+ if result == '200':
+ print "O2, E-Plus and Vodaphone cards indicate having problem"
+ elif result == '486':
+ print "GSM External Modem Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif destination == 'SIP':
+
+ ping('landline')
+ if serverStatus <> 0:
+ initTest(callFrom,'landline')
+
+ if result == '200':
+ ping('unisip')
+ if serverStatus <> 0:
+ initTest(callFrom,'unisip')
+
+ if result =='200':
+ print "All SIP network are working"
+ elif result == '486':
+ print "University telephone network indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to University telephone network server, check your connection"
+
+ elif result == '486':
+ ping('unisip')
+ if serverStatus <> 0:
+ initTest(callFrom,'unisip')
+
+ if result == '200':
+ print "Landline indicate having problem"
+ elif result == '486':
+ print "SIP Network Down"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to University telephone network server, check your connection"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to SIP Gate server, check your connection"
+
+ elif destination == 'RZOutgoing':
+
+ ping('landline')
+ if serverStatus <> 0:
+ initTest('GSMRZ1','landline')
+
+ if result == '200':
+ ping('unisip')
+ if serverStatus <> 0:
+ initTest('GSMRZ1','unisip')
+
+ if result =='200':
+ print "Outgoing call from GSM RZ is working"
+
+ elif result == '486':
+ print "Outgoing call from GSM RZ to UTN indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to University telephone network server, check your connection"
+
+ elif result == '486':
+ ping('unisip')
+ if serverStatus <> 0:
+ initTest('GSMRZ1','unisip')
+
+ if result == '200':
+ print "Outgoing call from GSM RZ to Landline indicate having problem"
+
+ elif result == '486':
+ print "Outgoing call from GSM RZ to Landline and UTN indicate having problem"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to University telephone network server, check your connection"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+ else:
+ print "No connection to SIP Gate server, check your connection"
+
+ elif destination == 'RZincoming':
+
+ ping('landline')
+ if serverStatus <> 0:
+ initTest('landline', 'GSMRZ1')
+
+ if result == '486':
+
+ initTest('GSMExt.O2','GSMRZ1')
+
+ if result =='200':
+ print "incoming call to GSM RZ working"
+
+ elif result == '486':
+
+ initTest('GSMExt.Voda','GSMRZ1')
+ if result =='200':
+ print "incoming call to GSM RZ working"
+ elif result == '486':
+ print "incoming call to GSM RZ notworking"
+ else:
+ print "incomplete test, GSM Handler having error, please do one more test"
+ else:
+ print "incomplete test, Handler having error, please do one more test"
+
+ elif result == '200':
+ print "incoming call to GSM RZ working"
+ else:
+ print "No connection to SIP Gate server, check your connection"
+
+
+if len(sys.argv) > 1:
+
+ command = sys.argv[1]
+ print ' '
+
+ if command == '--all':
+ doAllTest()
+
+ elif command == '--sip':
+ doSipTest()
+
+ elif command == '--gsmrz':
+ doGsmrzTest()
+
+ elif command == '--gsmext':
+ doGsmExtTest()
+
+ elif command == '--landline':
+ doLandlineTest()
+
+ elif command == '--smart':
+ smartTest()
+
+ elif command == '--help':
+ file = open('help.txt', 'r')
+ print file.read()
+
+ else:
+ print "command not found, Type '--help', '--credits' for more information."
+ print '\n'
+else:
+
+ initDB()
+ if dbStatus == 1:
+
+ if db.anyTasksToDo() == 1:
+
+ #allPing()
+ i=0
+ for item in db.tasksList:
+
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+
+ #if i == 0:
+ #db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ print '\n'
+ print 'Task ID :', taskID
+ print 'Calling From :', callFrom
+ print 'To :', callTo
+
+ ping(callFrom)
+
+ if serverStatus <> 0:
+
+ ping(callTo)
+ if serverStatus <> 0:
+
+ initTest(callFrom,callTo)
+
+ db.addResult(taskID, result)
+
+ resultsList.append([callFrom, callTo, result])
+
+ db.errorCode(result)
+ print 'Result : ' +result+ ' ' +db.errCode
+
+ db.deleteTempTask(taskID)
+ i = i+1
+
+ sleep(5)
+
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callTo+ ' Server Internal Error'
+ else:
+ db.addResult(taskID, '500')
+ print '[failed] 500 '+callFrom+' Server Internal Error'
+ db.cleanTasksList()
+
+ # fetch result list and make adjustment about the result
+ print '\n'
+ initTrueTable()
+ else:
+ print "--- No job at all ---"
+ else:
+ sys.exit(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+