def checkVMMessages(dom, sipNumber, sipGroup): returnedFromSSH = ccn.executeOnSSH('domain/' + dom + '/alias/info ' + sipNumber + ' ' + sipGroup + ' ' + sipNumber + '@' + dom) print(returnedFromSSH) if 'Unread message(s): 1' in returnedFromSSH: return True else: return False
def preconfigure(): if ccn.domainDeclare(dom=testingDomain, removeIfExists=True): print(Fore.GREEN + 'Successful domain declare') logging.info('Successful domain declare ' + testingDomain) else: print(Fore.RED + 'Smthing happen wrong with domain declaration...') logging.error('Failed to declare domain ' + testingDomain) return False cnt = 0 time.sleep(2) while not ccn.checkDomainInit( dom=testingDomain): # проверяем инициализацию домена #print(Fore.YELLOW + 'Not inited yet...') logging.info('Domain initialisation check') cnt += 1 if cnt > 5: print(Fore.RED + "Test domain wasn't inited :(") logging.error('Domain ' + testingDomain + ' was not initialised!') return False time.sleep(2) #print(Fore.GREEN +'Domain inited!') logging.info('Domain initialised successfully') time.sleep(2) print('Removing our test domain') if ccn.domainRemove(dom=testingDomain): print(Fore.GREEN + 'Successful domain remove') logging.info('Successful domain remove ' + testingDomain) else: print(Fore.RED + 'Smthing happen wrong with domain removing...') logging.error('Domain ' + testingDomain + ' failed to remove!') return False time.sleep(7) if ccn.checkDomainExist(dom=testingDomain): print(Fore.RED + 'Failed, domain exists!') logging.error('Domain ' + testingDomain + ' exists in domain list!') return False else: print(Fore.GREEN + 'Domain is not exists in domain/list') logging.info('Domain ' + testingDomain + ' is not exists in domain/list') returnedFromSSH = ccn.executeOnSSH('ls /domain/') print(returnedFromSSH) if testingDomain in returnedFromSSH: print(Fore.RED + 'Domain exists in cocon!') logging.error('Domain ' + testingDomain + ' is exists in cocon!') return False else: print(Fore.GREEN + 'Domain is not exsists in cocon! All ok!') logging.info('Domain ' + testingDomain + ' is not exists in cocon') return True
def removeVMPasswd(): global subscrUA print(Style.BRIGHT + 'Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# and remove VM password') logging.info('Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# and remove VM password') subscrUA[0].makeCall(phoneURI='*90#@' + testingDomain) phase = 0 print('waiting for answer...') logging.info('Waiting for answer...') cnt = 0 Answered = False while cnt < 50: time.sleep(0.1) if subscrUA[0].uaCurrentCallInfo.state == 5: Answered = True break print('.', end='') cnt += 1 if not Answered: print('Call not established') logging.error('Call not established') return False else: print('Call established') logging.info('Call established') print('Dialing VM password') logging.info('Dialing VM password') time.sleep(2) for k in range(0, len(vmPassword)): print('Dialing ' + vmPassword[k]) subscrUA[0].sendInbandDTMF(dtmfDigit=vmPassword[k]) time.sleep(1) time.sleep(2) print('Dialing 2 and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='2') time.sleep(2) print('Dialing 2 and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='2') time.sleep(2) print('Dialing 1 and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='1') time.sleep(2) print('Dialing old password ' + vmPassword + ' # and wait...') logging.info('Dialing old password ' + vmPassword + ' # and wait...') for k in range(0, len(vmPassword)): print('Dialing ' + vmPassword[k]) subscrUA[0].sendInbandDTMF(dtmfDigit=vmPassword[k]) time.sleep(1) print('Dialing #') subscrUA[0].sendInbandDTMF(dtmfDigit='#') time.sleep(2) print('Dialing new password # and wait...') logging.info('Dialing new password # and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='#') time.sleep(2) print('Dialing confirm new password # and wait...') logging.info('Dialing confirm new password # and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='#') time.sleep(2) if subscrUA[0].uaCurrentCallInfo.state != 5: print(Fore.RED + subscrUA[0].uaAccountInfo.uri + ' in wrong state!') return False print('Releasing from VM menu') try: subscrUA[0].uaCurrentCall.hangup(code=200, reason='Release') except: pass time.sleep(2) returnedFromSSH = ccn.executeOnSSH('domain/' + testingDomain + '/ss/info ' + firstNumber) print(returnedFromSSH) if 'password = []' in returnedFromSSH: print(Fore.GREEN + 'It seems that password for VM is removed') logging.info('It seems that password for VM is removed') return True else: logging.error('Failed to remove VM password') return False
def checkVMbox(): global subscrUA cnt = 0 readMsgBefore = 0 vmMessageLeaveTimeout = 10 print(Style.BRIGHT + 'Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# and check new message') logging.info('Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# and check new message') subscrUA[0].makeCall(phoneURI='*90#@' + testingDomain) phase = 0 print('waiting for answer...') cnt = 0 Answered = False while cnt < 50: time.sleep(0.1) if subscrUA[0].uaCurrentCallInfo.state == 5: Answered = True break print('.', end='') cnt += 1 if not Answered: print(Fore.YELLOW + 'Call not established') logging.error('Call not established') return False else: print('Call established') logging.info('Call established') time.sleep(2) print('Dialing 1 and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='1') time.sleep(1) print('Dialing 1 and wait untill voice message listen...') subscrUA[0].sendInbandDTMF(dtmfDigit='1') cnt = 0 callDuration = 20 failed = False while cnt < callDuration: time.sleep(1) print('.', end='') cnt += 1 if subscrUA[0].uaCurrentCallInfo.state != 5: print(Fore.YELLOW + subscrUA[0].uaAccountInfo.uri + ' in wrong state!') failed = True if not failed: print('DTMF # sent. Waiting for release from ssw...') logging.info('DTMF # sent. Waiting for release from ssw...') subscrUA[0].sendInbandDTMF(dtmfDigit='#') else: try: subscrUA[0].uaCurrentCall.hangup(code=200, reason='Release') except: pass cnt = 0 while subscrUA[0].uaCurrentCallInfo.state != 6: cnt += 1 time.sleep(0.1) print('.', end='') if cnt > 10: print(Fore.RED + 'SSW didnt released on DTMF') logging.error('SSW didnt relesed call on # DTMF') return False returnedFromSSH = ccn.executeOnSSH('domain/' + testingDomain + '/alias/info ' + firstNumber + ' ' + SIPgroup + ' ' + firstNumber + '@' + testingDomain) print(returnedFromSSH) if 'Unread message(s): 0' in returnedFromSSH: print(Fore.GREEN + 'Message successful read') logging.info('Message successful read') return True else: logging.info('Failed to read VM message') return False
def VMpropertyChange(VMpropertyName, enabling=True): global subscrUA logging.info('Set VM property ' + VMpropertyName + ' to ' + str(enabling) + ' via voicemail menu') if VMpropertyName is 'play_message_details': secondDigit = '2' thirdDigit = '3' elif VMpropertyName is 'send_by_email': secondDigit = '2' thirdDigit = '2' elif VMpropertyName is 'no_reply': secondDigit = '1' thirdDigit = '1' elif VMpropertyName is 'busy': secondDigit = '1' thirdDigit = '2' elif VMpropertyName is 'out_of_service': secondDigit = '1' thirdDigit = '3' elif VMpropertyName is 'unconditional': secondDigit = '1' thirdDigit = '4' else: print('Invalid property name ' + VMpropertyName) return False print('Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# to change property ' + VMpropertyName + ' to ' + str(enabling)) logging.info('Now ' + subscrUA[0].uaAccountInfo.uri + ' will call to voiceMail *90# to change property ' + VMpropertyName + ' to ' + str(enabling)) subscrUA[0].makeCall(phoneURI='*90#@' + testingDomain) print('waiting for answer...') logging.info('Waiting for answer...') cnt = 0 Answered = False while cnt < 50: time.sleep(0.1) if subscrUA[0].uaCurrentCallInfo.state == 5: Answered = True break print('.', end='') cnt += 1 if not Answered: print(Fore.YELLOW + 'Call not established') logging.error('Call not established') return False else: print('Call established') logging.info('Call established') time.sleep(2) print('Dialing 2 and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit='2') time.sleep(2) print('Dialing ' + secondDigit + ' and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit=secondDigit) time.sleep(2) print('Dialing ' + thirdDigit + ' and wait...') subscrUA[0].sendInbandDTMF(dtmfDigit=thirdDigit) time.sleep(2) if enabling: dialDigit = '1' checkStr = VMpropertyName + ' = true' else: dialDigit = '2' checkStr = VMpropertyName + ' = false' print('Dialing ' + dialDigit + ' to change ' + VMpropertyName + ' mode...') logging.info('Dialing ' + dialDigit + ' to change ' + VMpropertyName + ' mode...') subscrUA[0].sendInbandDTMF(dtmfDigit=dialDigit) time.sleep(3) print('Dialing # for exit from VM...') logging.info('Dialing # for exit from VM...') subscrUA[0].sendInbandDTMF(dtmfDigit='#') time.sleep(2) if subscrUA[0].uaCurrentCallInfo.state == 5: print(Fore.RED + 'The call was not released') logging.info('The call was not released') #subscrUA[0].uaCurrentCall.hangup(code=200, reason='Release') hangupAll() return False returnedFromSSH = ccn.executeOnSSH('domain/' + testingDomain + '/ss/info ' + firstNumber) print(returnedFromSSH) if checkStr in returnedFromSSH: print(Fore.GREEN + 'It seems that ' + VMpropertyName + ' is changed to ' + checkStr) logging.info('It seems that ' + VMpropertyName + ' is changed to ' + checkStr) return True else: print(Fore.RED + 'Something wrong with ' + VMpropertyName + ' property change') logging.error('Something wrong with ' + VMpropertyName + ' property change') return False