Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
    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)