Beispiel #1
0
 def _connect_health(self, user, password, timeout):
     output = timeout_command(
         [VSQL_PATH, "-U", user, "-w", password, "-c", "select version();"], timeout)
     if (output is not None) and ('Vertica Analytic Database' in output):
         # healthy
         return 0
     else:
         return 1
Beispiel #2
0
 def _query_database(self, user, password, timeout, query):
     stdout, stderr, return_code = timeout_command(["/opt/vertica/bin/vsql", "-U", user, "-w", password, "-A", "-R",
                                                    "|", "-t", "-F", ",", "-x"], timeout, command_input=query)
     if return_code == 0:
         # remove trailing newline
         stdout = stdout.rstrip()
         return stdout, 0
     else:
         self.log.error("Error querying vertica with return code of {0} and error {1}".format(return_code, stderr))
         return stderr, 1
Beispiel #3
0
 def _query_database(self, user, password, timeout, query):
     stdout, stderr, return_code = timeout_command(["/opt/vertica/bin/vsql", "-U", user, "-w", password, "-A", "-R",
                                                    "|", "-t", "-F", ",", "-x"], timeout, command_input=query)
     if return_code == 0:
         # remove trailing newline
         stdout = stdout.rstrip()
         return stdout, 0
     else:
         self.log.error("Error querying vertica with return code of {0} and error {1}".format(return_code, stderr))
         return stderr, 1
Beispiel #4
0
 def _connection_test(self):
     """Attempt to connect to Vertica DB to verify credentials.
     :return: bool status of the test
     """
     log.info("\tVertica connection test.")
     output = timeout_command(
         [VSQL_PATH, "-U", self.user, "-w", self.password, "-c", "select version();"], self.timeout)
     if (output is not None) and ('Vertica Analytic Database' in output):
         return True
     else:
         return False
Beispiel #5
0
 def _get_raw_data(cmd, timeout=10):
     # If the command times out, nothing is returned
     stdout, stderr, rc = (timeout_command(cmd, timeout)
                           or (None, None, None))
     if rc == 0:
         return stdout
     elif rc is None:
         err_msg = ("Command: {} timed out after {} seconds.".format(
             cmd, timeout))
     else:
         err_msg = (
             "Failed to query Slurm. Return code: {0}, error: {1}.".format(
                 rc, stderr))
     raise Exception(err_msg)
Beispiel #6
0
 def _connection_test(self):
     """Attempt to connect to Vertica DB to verify credentials.
     :return: bool status of the test
     """
     log.info("\tVertica connection test.")
     stdout, stderr, return_code = timeout_command(
         ["/opt/vertica/bin/vsql", "-U", self.user, "-w", self.password, "-t", "-A", "-c",
          "SELECT node_name FROM current_session"], self.timeout)
     # remove trailing newline
     stdout = stdout.rstrip()
     if return_code == 0:
         self.node_name = stdout
         return True
     else:
         log.error("Error querying vertica with return code of {0} and the error {1}".format(return_code, stderr))
         return False