def test3_download(self): """ Attempts to download the SOS reports from each host in the cloud and store in a local directory """ error_msg = "" count = 0 err_count = 0 host_count = len(self.ip_list) for ip in self.ip_list: if self.tc: if ip in self.tc.sysadmin.eucahosts.keys(): host = self.tc.sysadmin.eucahosts.get(ip) ssh = host.ssh else: ssh = SshConnection(host=ip, password=self.args.password) try: remote_tarball_path = ssh.sys( "ls -1 {0}/*.xz | grep {1}".format(self.remote_dir, self.ticket_number), code=0)[0] tarball_name = os.path.basename(remote_tarball_path) local_name = "sosreport-{0}.{1}{2}".format( ip, self.ticket_number, tarball_name.split(str(self.ticket_number))[1]) local_tarball_path = os.path.join(self.args.local_dir, local_name) self.log.debug("Downloading file to: " + local_tarball_path) ssh.sftp_get(localfilepath=local_tarball_path, remotefilepath=remote_tarball_path) except Exception, e: err_count += 1 msg = '\nError Downloading from: {0}. Error:"{0}"\n'.format( ip, e) self.log.error("{0}\n{1}".format(get_traceback(), msg)) error_msg += msg else: count += 1 self.log.info( markup('Downloaded SOS report {0}/{1} to:{2}'.format( count, host_count, local_tarball_path), markups=[ ForegroundColor.WHITE, BackGroundColor.BG_GREEN ]))
def test3_download(self): """ Attempts to download the SOS reports from each host in the cloud and store in a local directory """ error_msg = "" count = 0 err_count = 0 host_count = len(self.ip_list) for ip in self.ip_list: if self.tc: if ip in self.tc.sysadmin.eucahosts.keys(): host = self.tc.sysadmin.eucahosts.get(ip) ssh = host.ssh else: ssh = SshConnection(host=ip, password=self.args.password) try: remote_tarball_path = ssh.sys("ls -1 {0}/*.xz | grep {1}" .format(self.remote_dir, self.ticket_number), code=0)[0] tarball_name = os.path.basename(remote_tarball_path) local_name = "sosreport-{0}.{1}{2}".format(ip, self.ticket_number, tarball_name.split(str(self.ticket_number))[1]) local_tarball_path = os.path.join(self.args.local_dir, local_name) self.log.debug("Downloading file to: " + local_tarball_path) ssh.sftp_get(localfilepath=local_tarball_path, remotefilepath=remote_tarball_path) except Exception, e: err_count += 1 msg = '\nError Downloading from: {0}. Error:"{0}"\n'.format(ip, e) self.log.error("{0}\n{1}".format(get_traceback(), msg)) error_msg += msg else: count += 1 self.log.info(markup('Downloaded SOS report {0}/{1} to:{2}' .format(count, host_count, local_tarball_path), markups=[ForegroundColor.WHITE, BackGroundColor.BG_GREEN]))