Ejemplo n.º 1
0
 def show_options(self):
     """ Show all audit log variables.
     """
     server = Server({'conn_info': self.options.get("server_vals", None)})
     server.connect()
     rows = server.show_server_variable("audit%")
     server.disconnect()
     if rows:
         print "#\n# Audit Log Variables and Options\n#"
         print_list(sys.stdout, "GRID", ['Variable_name', 'Value'], rows)
         print
     else:
         raise UtilError("No audit log variables found.")
Ejemplo n.º 2
0
    def check_audit_log(self):
        """Verify if the audit log plugin is installed on the server.
        Return the message error if not, or None.
        """
        error = None
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()
        # Check to see if the plug-in is installed
        if not server.supports_plugin("audit"):
            error = "The audit log plug-in is not installed on this " + \
                    "server or is not enabled."
        server.disconnect()

        return error
Ejemplo n.º 3
0
 def show_options(self):
     """ Show all audit log variables.
     """
     server = Server({'conn_info': self.options.get("server_vals", None)})
     server.connect()
     rows = server.show_server_variable("audit%")
     server.disconnect()
     if rows:
         print "#\n# Audit Log Variables and Options\n#"
         print_list(sys.stdout, "GRID", ['Variable_name', 'Value'],
                    rows)
         print
     else:
         raise UtilError("No audit log variables found.")
Ejemplo n.º 4
0
    def check_audit_log(self):
        """Verify if the audit log plugin is installed on the server.
        Return the message error if not, or None.
        """
        error = None
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()
        # Check to see if the plug-in is installed
        if not server.supports_plugin("audit"):
            error = "The audit log plug-in is not installed on this " + \
                    "server or is not enabled."
        server.disconnect()

        return error
Ejemplo n.º 5
0
    def do_command(self):
        """ Check and execute the audit log command (previously set by the the
        options of the object constructor).
        """
        # Check for valid command
        command = self.options.get("command", None)
        if not command in VALID_COMMANDS:
            raise UtilError("Invalid command.")

        command_value = self.options.get("value", None)
        # Check for valid value if needed
        if (command_requires_value(command)
                and not check_command_value(command, command_value)):
            raise UtilError("Please provide the correct value for the %s "
                            "command." % command)

        # Copy command does not need the server
        if command == "COPY":
            self._copy_log()
            return True

        # Connect to server
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()

        # Now execute the command
        print "#\n# Executing %s command.\n#\n" % command
        try:
            if command == "POLICY":
                server.exec_query("SET @@GLOBAL.audit_log_policy = %s" %
                                  command_value)
            elif command == "ROTATE":
                self._rotate_log(server)
            else:  # "ROTATE_ON_SIZE":
                server.exec_query(
                    "SET @@GLOBAL.audit_log_rotate_on_size = %s" %
                    command_value)
        finally:
            server.disconnect()

        return True
Ejemplo n.º 6
0
    def do_command(self):
        """ Check and execute the audit log command (previously set by the the
        options of the object constructor).
        """
        # Check for valid command
        command = self.options.get("command", None)
        if not command in VALID_COMMANDS:
            raise UtilError("Invalid command.")

        command_value = self.options.get("value", None)
        # Check for valid value if needed
        if (command_requires_value(command)
           and not check_command_value(command, command_value)):
            raise UtilError("Please provide the correct value for the %s "
                            "command." % command)

        # Copy command does not need the server
        if command == "COPY":
            self._copy_log()
            return True

        # Connect to server
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()

        # Now execute the command
        print "#\n# Executing %s command.\n#\n" % command
        try:
            if command == "POLICY":
                server.exec_query("SET @@GLOBAL.audit_log_policy = %s" %
                                  command_value)
            elif command == "ROTATE":
                self._rotate_log(server)
            else:  # "ROTATE_ON_SIZE":
                server.exec_query("SET @@GLOBAL.audit_log_rotate_on_size = %s"
                                  % command_value)
        finally:
            server.disconnect()

        return True