def recover(self): board.touch() lan.sendcontrol('c') lan.expect(prompt) board.touch() print("Copying files from lan to dir = %s" % self.config.output_dir) lan.sendline('readlink -f $HOME/%s/' % self.dir) lan.expect_exact('$HOME/%s/' % self.dir) board.touch() lan.expect(prompt) board.touch() fname = lan.before.replace('\n', '').replace('\r', '') board.touch() rm_r(os.path.join(self.config.output_dir, self.dir)) scp_from(fname, lan.ipaddr, lan.username, lan.password, lan.port, self.config.output_dir) # let board settle down board.expect(pexpect.TIMEOUT, timeout=30) board.touch() board.parse_stats(dict_to_log=self.logged) board.touch() self.result_message = 'JMeter: DONE, name = %s cpu usage = %s' % ( self.shortname, self.logged['mpstat'])
def recover(self): lan.sendcontrol('c') lan.expect(prompt) print "Copying files from lan to dir = %s" % self.config.output_dir lan.sendline('readlink -f output/') lan.expect('readlink -f output/') lan.expect(prompt) fname = lan.before.strip() scp_from( fname, lan.ipaddr, lan.username, lan.password, lan.port, os.path.join(self.config.output_dir, 'jmeter_%s' % self.shortname)) # let board settle down board.expect(pexpect.TIMEOUT, timeout=30) board.parse_stats(dict_to_log=self.logged) self.result_message = 'JMeter: DONE, name = %s cpu usage = %s' % ( self.shortname, self.logged['mpstat'])
def get_conf_file_from_tftp(self, _tmpdir, board_config): '''Retrieve the files in the cfg_list from the tftp sever, puts them in localhost:/tmp/''' cfg_list = self.get_cfgs(board_config) if cfg_list is None: return False for elem in cfg_list: conf_file = self.tftp_dir + '/' + elem[0] server = elem[1] # this is where the current (to be downloaded from the tftp) # config is going to be placed dest_fname = _tmpdir + '/' + os.path.basename( conf_file) + "." + board_config['station'] + ".current" try: os.remove(dest_fname) except: pass try: print('Downloading ' + server + ':' + conf_file + ' to ' + dest_fname) from devices.common import scp_from scp_from(conf_file, server, self.tftp_device.username, self.tftp_device.password, self.tftp_device.port, dest_fname) if not os.path.isfile(dest_fname): # Something has gone wrong as the tftp client has not thrown an # exception, but the file is not where it should be!! print( "Tftp completed but %s not found in destination dir: " % dest_fname) return False print("Downloaded: " + conf_file) except: print("Failed to download %s from %s" % (conf_file, self.ipaddr)) return False return True