def start_traffic(self): test_name = self.repository.testList[0].cget("name") test = self.repository.testList.getItem(test_name) test.config(statsRequired=1, enableResetPorts=1, csvInterval=2, enableForceOwnership=True) self.run_start = datetime.now() IxLoad._TclEval("set ::ixTestControllerMonitor \"\"") self.controller.run(test) self.task_queue.task_done() IxLoad._TclEval("""\ set ::test_cont 1 while {$::ixTestControllerMonitor == "" && $::test_cont == 1} { after 1000 set wakeup 1 vwait wakeup } """) if self.elapsed is None: stop = datetime.now() self.elapsed = (stop - self.run_start).total_seconds() self.result_queue.put(["ixload::ok"])
def stop_traffic(self): IxLoad._TclEval("set ::test_cont 0") self.controller.stopRun() if self.elapsed is None: stop = datetime.now() self.elapsed = (stop - self.run_start).total_seconds() self.result_queue.put(["ixload::ok", self.elapsed]) self.task_queue.task_done()
def load_config(self, config_name, port_list): """ Loads config file named ``config`` ``config`` is the name of the confif file related to current active config path. """ try: ixload_tmp_dir = self._ixload_tmp_dir() config_src = Common.get_item_config_path() + '/' + config_name config_dst = ixload_tmp_dir + '_' + config_name log = "IxLoad send file `%s` to `%s`" % (config_src, config_dst) IxLoad._TclEval("::IxLoad sendFileCopy %s %s" % (config_src, config_dst)) self.controller = self.ix.new("ixTestController", outputDir=1) self.controller.setResultDir(ixload_tmp_dir) self.repository = self.ix.new("ixRepository", name=config_dst) test_name = self.repository.testList[0].cget('name') test = self.repository.testList.getItem(test_name) port_num = 0 num = int(test.clientCommunityList.indexCount()) for i in range(num): port_num = port_num + int( test.clientCommunityList[i].network.portList.indexCount()) num = int(test.serverCommunityList.indexCount()) for i in range(num): port_num = port_num + int( test.serverCommunityList[i].network.portList.indexCount()) if len(port_list) == 0: self.result_queue.put(["ixload::ok"]) elif port_num != len(port_list): self.result_queue.put(["ixload::err", "Wrong port number"]) else: num = int(test.clientCommunityList.indexCount()) for i in range(num): test.clientCommunityList[i].network.portList.clear() num = int(test.serverCommunityList.indexCount()) for i in range(num): test.serverCommunityList[i].network.portList.clear() test.setPorts(port_list) self.result_queue.put(["ixload::ok", ixload_tmp_dir, log]) except Exception as err: self.result_queue.put([err]) self.task_queue.task_done()
def connect(self, ip): self.ix = IxLoad.IxLoad() self.ix.connect(ip) # logger = self.ix.new("ixLogger","Ixload-RENAT",1) # log_engine = logger.getEngine() # log_engine.setLevels(self.ix.ixLogger.kLevelDebug,self.ix.ixLogger.kLevelInfo) self.result_queue.put(["ixload::ok"]) self.task_queue.task_done()
def connect(self,ip,verbose=False): self.ix = IxLoad.IxLoad() self.ix.connect(ip) # logger prepare self.logger = self.ix.new("ixLogger","Ixload-RENAT",1) self.log_engine = self.logger.getEngine() # 1st is File level and 2nd is console Level if verbose: self.log_engine.setLevels(self.ix.ixLogger.kLevelDebug,self.ix.ixLogger.kLevelInfo) else: self.log_engine.setLevels(self.ix.ixLogger.kLevelDebug,self.ix.ixLogger.kLevelError) self.log_engine.setFile(self._ixload_tmp_dir()+'/'+ self._ixload_tmp_dir(),1,256,1) self.result_queue.put(["ixload::ok"]) self.task_queue.task_done()