Ejemplo n.º 1
0
def perform_query(query, key=None, handler=None):
    configuration = get_current_configuration()
    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_query(query, socket_path, key)

    raise ValueError('No handler {0}.'.format(handler))
def perform_query(query, key=None, handler=None):
    configuration = get_current_configuration()
    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_query(query, socket_path, key)

    raise ValueError('No handler {0}.'.format(handler))
def perform_command(command, key=None, handler=None):
    configuration = get_current_configuration()

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_command(command, socket_path, key)
    elif handler == 'icinga':
        command_file_path = configuration.icinga_command_file
        return perform_icinga_command(command, command_file_path, key)

    raise ValueError('No handler {0}.'.format(handler))
Ejemplo n.º 4
0
def perform_command(command, key=None, handler=None):
    configuration = get_current_configuration()

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_command(command, socket_path, key)
    elif handler == 'icinga':
        command_file_path = configuration.icinga_command_file
        return perform_icinga_command(command, command_file_path, key)

    raise ValueError('No handler {0}.'.format(handler))
Ejemplo n.º 5
0
def perform_query(query, key=None, auth=None, handler=None):
    configuration = get_current_configuration()

    # Admins could query everything
    if auth in configuration.admins:
        auth = None

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_query(query, socket_path, key, auth=auth)

    raise ValueError('No handler {0}.'.format(handler))
Ejemplo n.º 6
0
def perform_query(query, key=None, auth=None, handler=None):
    configuration = get_current_configuration()

    # Admins could query everything
    if auth in configuration.admins:
        auth = None

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_query(query, socket_path, key, auth=auth)

    raise ValueError('No handler {0}.'.format(handler))
Ejemplo n.º 7
0
def perform_command(command, key=None, auth=None, handler=None):
    configuration = get_current_configuration()

    LOGGER.debug("admins: %s", configuration.admins)
    # Admins users could run all commands
    if not auth in configuration.admins:
        check_contact_permissions(command, auth)

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_command(command, socket_path, key, auth=auth)
    elif handler == 'icinga':
        command_file_path = configuration.icinga_command_file
        return perform_icinga_command(command, command_file_path, key, auth=auth)

    raise ValueError('No handler {0}.'.format(handler))
Ejemplo n.º 8
0
def perform_command(command, key=None, auth=None, handler=None):
    configuration = get_current_configuration()

    LOGGER.debug("admins: %s", configuration.admins)
    # Admins users could run all commands
    if not auth in configuration.admins:
        check_contact_permissions(command, auth)

    if _is_livestatus_handler(handler):
        socket_path = configuration.livestatus_socket
        return perform_livestatus_command(command, socket_path, key, auth=auth)
    elif handler == 'icinga':
        command_file_path = configuration.icinga_command_file
        return perform_icinga_command(command,
                                      command_file_path,
                                      key,
                                      auth=auth)

    raise ValueError('No handler {0}.'.format(handler))
    def test_get_current_configuration_should_open_default_configuration_file(self, mock_configuration):
        get_current_configuration()

        self.assertEqual(mock_configuration.call_args, call(mock_configuration.DEFAULT_CONFIGURATION_FILE))
Ejemplo n.º 10
0
    def test_get_current_configuration_should_open_default_configuration_file(
            self, mock_configuration):
        get_current_configuration()

        self.assertEqual(mock_configuration.call_args,
                         call(mock_configuration.DEFAULT_CONFIGURATION_FILE))