Exemplo n.º 1
0
    def sqldump(self, kwargs):
        """
        Dump the database.

        No parameters.

        Returns the dump of the database.
        """
        try:
            exp_params = []
            check_arguments(exp_params, kwargs)
            self.check_state([self.S_RUNNING])
        except Exception as ex:
            return HttpErrorResponse("%s" % ex)

        # at least one agent since state is S_RUNNING
        one_node = self.config.get_nodes()[0]
        # adding option '--skip-lock-tables' to avoid issue
        #  mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user
        #   'root'@'10.158.0.28' for table 'cond_instances'
        #   when using LOCK TABLES
        # FIXME: is it MySQL 5.1 only? does it still occur with MySQL 5.5?
        cmd = 'mysqldump -u root -h %s --password=%s -A --skip-lock-tables' \
              % (one_node.ip, self.root_pass)
        out, error, return_code = run_cmd_code(cmd)

        if return_code == 0:
            return HttpJsonResponse(out)
        else:
            return HttpErrorResponse("Failed to run mysqldump: %s." % error)
Exemplo n.º 2
0
 def _wait_daemon_started(self):
     code = 1
     while code != 0:
         poll_cmd = "mysql -u mysql" \
                    + " -BN" \
                    + " -e \"SHOW STATUS LIKE 'wsrep_local_state_comment';\""
         sql_logger.debug("Polling mysql daemon: %s" % poll_cmd)
         out, error, code = run_cmd_code(poll_cmd)
         if code != 0:
             wait_time = 5
             sql_logger.info("MySQL daemon is not ready yet: %s %s."
                             " Returned error code %s."
                             " Retrying in %s seconds."
                             % (out, error, code, wait_time))
             time.sleep(wait_time)
         else:
             sql_logger.info("MySQL daemon is ready with state: %s" % out)
Exemplo n.º 3
0
    def _wait_daemon_started(self, is_first_node):
        if is_first_node:
            # for the first node there is no password set yet
            password = ""
        else:
            password = "******" % self.conn_password

        code = 1
        while code != 0:
            poll_cmd = ("mysql -u root %s"
                        "-BN "
                        "-e \"SHOW STATUS LIKE 'wsrep_local_state_comment';\""
                        % password)
            sql_logger.debug("Polling the MySQL daemon") #: %s" % poll_cmd)
            out, error, code = run_cmd_code(poll_cmd)
            if code != 0:
                wait_time = 5
                sql_logger.info("MySQL daemon is not ready yet: %s %s."
                                " Returned error code %s."
                                " Retrying in %s seconds."
                                % (out.strip(), error.strip(), code, wait_time))
                time.sleep(wait_time)
            else:
                sql_logger.info("MySQL daemon is ready with state: %s" % out.strip())