def _sendFile(self): """ Copy file to remote server """ _conn = SSH(host=self.host) status, file = _conn.send_file(self.source, self.destination) _conn.close() return status, file
def _install_java(self): """ Install latest version of JAVA """ cmd = "yum install -y " + self.required_version _conn = SSH(host=self.host) exit_status, stdout, stderr = _conn.exec_command(cmd) _conn.close() return exit_status, stderr
def _downloadFile(self): """ Download file on remote server """ cmd = "wget " + self.downloadURL + " -P " + self.downloadPath _conn = SSH(host=self.host) exit_status, stdout, stderr = _conn.exec_command(cmd) _conn.close() return exit_status, stderr
def _remove_older(self): """ Keep one latest version and remove rest of JAVA installations. """ _conn = SSH(host=self.host) for i in range(1, len(self.installed_versions)): cmd = "yum remove -y " + self.installed_versions[i] exit_status, stdout, stderr = _conn.exec_command(cmd) if exit_status != 0: return exit_status, stderr _conn.close() return 0, None
def run(self, host=None): """ Install the JAVA """ self._conn = SSH(host=host) exit_status, stdout, stderr = self._conn.exec_command( "rpm -qa | grep java.*openjdk | grep -v headless | sort -r") self._conn.close() output = [] for version in stdout.split(): output.append(version) if exit_status != 0: return (False, stderr) else: return (True, output)