def __exec_sip_calls__(self, **kwargs): self._init_args(**kwargs) tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) remote_dir_path = '/home/'+self.tvmc_username+'/testframework_tmp' tvmc_ftp.mkd(remote_dir_path) files_list = [self.tvm_config_file, self.caller_list, self.callee_list, self.perl_script] file_names = dict(zip(['config_file', 'caller_list', 'callee_list', 'perl_script'],[x.split('/')[-1] for x in files_list])) for fil in files_list: tvmc_ftp.cwd(remote_dir_path) tvmc_ftp.storbinary('STOR '+fil.split('/')[-1], open(fil, 'rb')) tvmc_ftp.quit() import pdb;pdb.set_trace() #time.sleep(180) tvmc_client = utils.get_ssh_conn(self.tvmc_host, self.tvmc_username, self.tvmc_password) interfaces = tvmutils.get_interfaces(tvmc_client) while len(interfaces) != num_of_test_clients(): interfaces = tvmutils.get_interfaces(tvmc_client) #output, err = utils.exec_command("cli listInterfaces| tail --lines=+2 | awk '{print $1}'", client=tvmc_client) #interfaces = output.rstrip('\n').split('\n') import pdb;pdb.set_trace() cmd_perl = "perl "+remote_dir_path+'/'+file_names['perl_script']+" --config "+remote_dir_path+'/'+file_names['config_file']+' --calleelist '+remote_dir_path+'/'+file_names['callee_list']+' --callerlist '+remote_dir_path+'/'+file_names['caller_list'] for interface_num in range(0, len(interfaces)): cmd_perl = cmd_perl + ' --interface '+interfaces[interface_num] cmd_perl = cmd_perl+"> voip_onecall.xml" cmds = [cmd_perl, "cli importTestGroup \"//\" voip_onecall.xml", "cli startTestGroup "+self.test_group, "cli listHosts|awk '{print $1, $3}'", "cli listApplications "+self.test_group+"|awk '{print $1, $3}'", "cli saveTestGroupCurrentDetailedResults "+self.test_group+" "+remote_dir_path+"/"+result_filename, "cli stopTestGroup "+self.test_group, "cli deleteTestGroup "+self.test_group] for cmd in cmds: import pdb;pdb.set_trace() output, err = utils.exec_command(cmd, client=tvmc_client) if 'awk' in cmd: for line in output.rstrip().split('\n')[1:]: if line.split()[1] != "Active": print "Error" #self.logger.warn("Error: %s not configured!!", line.split()[0]) elif 'save' in cmd: tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) tvmc_ftp.cwd(remote_dir_path) tvmc_ftp.retrbinary('RETR '+remote_dir_path+'/'+result_filename, open(self.local_path+'/'+self.result_filename, 'wb').write) tvmc_ftp.quit() elif 'stop' in cmd: tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) tvmc_ftp.cwd(remote_dir_path) for fil in tvmc_ftp.nlst(): tvmc_ftp.delete(fil) tvmc_ftp.cwd('/home/'+self.tvmc_username) tvmc_ftp.rmd(remote_dir_path) tvmc_ftp.quit() elif 'start' in cmd: time.sleep(100) else: pass
def __exec_sip_calls__(self, **kwargs): self._init_args(**kwargs) tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) remote_dir_path = '/home/'+self.tvmc_username+'/testframework_tmp' result_filename = "tvm_results_"+time.strftime("%Y%m%d-%H%M%S")+".zip" tvmc_ftp.mkd(remote_dir_path) files_list = [self.tvm_config_file, self.caller_list, self.callee_list, self.perl_script] file_names = dict(zip(['config_file', 'caller_list', 'callee_list', 'perl_script'],[x.split('/')[-1] for x in files_list])) for fil in files_list: tvmc_ftp.cwd(remote_dir_path) tvmc_ftp.storbinary('STOR '+fil.split('/')[-1], open(fil, 'rb')) tvmc_ftp.quit() tvmc_client = utils.get_ssh_conn(self.tvmc_host, self.tvmc_username, self.tvmc_password) interfaces = tvmutils.get_interfaces(tvmc_client) while len(interfaces) != 2: interfaces = tvmutils.get_interfaces(tvmc_client) cmd_perl = "perl "+remote_dir_path+'/'+file_names['perl_script']+" --config "+remote_dir_path+'/'+file_names['config_file']+' --calleelist '+remote_dir_path+'/'+file_names['callee_list']+' --callerlist '+remote_dir_path+'/'+file_names['caller_list'] for interface_num in range(0, len(interfaces)): cmd_perl = cmd_perl + ' --interface '+interfaces[interface_num] cmd_perl = cmd_perl+"> voip_onecall.xml" cmds = [cmd_perl, "cli importTestGroup \"//\" voip_onecall.xml", "cli startTestGroup "+self.test_group, "cli saveTestGroupCurrentDetailedResults "+self.test_group+" "+remote_dir_path+"/"+result_filename, "cli stopTestGroup "+self.test_group, "cli deleteTestGroup "+self.test_group] for cmd in cmds: try: output, err = utils.exec_command(cmd, client=tvmc_client) except: pass if 'awk' in cmd: for line in output.rstrip().split('\n')[1:]: if line.split()[1] != "Active": print "Error" #self.logger.warn("Error: %s not configured!!", line.split()[0]) elif 'save' in cmd: tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) tvmc_ftp.cwd(remote_dir_path) tvmc_ftp.retrbinary('RETR '+remote_dir_path+'/'+result_filename, open(self.local_path+'/'+result_filename, 'wb').write) tvmc_ftp.quit() elif 'stop' in cmd: tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password) tvmc_ftp.cwd(remote_dir_path) for fil in tvmc_ftp.nlst(): tvmc_ftp.delete(fil) tvmc_ftp.cwd('/home/'+self.tvmc_username) tvmc_ftp.rmd(remote_dir_path) tvmc_ftp.quit() elif 'start' in cmd: time.sleep(120) else: pass return self.__analyze_logs__(result_filename)