Combiner for httpd configurations

Combiner for parsing part of httpd configurations. It collects all HttpdConf generated from each configuration file and combines them to expose a consolidated configuration tree.

Note

At this point in time, you should NOT filter the httpd configurations to avoid finding directives in incorrect sections.

class insights.combiners.httpd_conf.HttpdConfAll(httpd_conf)[source]

Bases: object

Warning

This combiner class is deprecated, please use insights.combiners.httpd_conf.HttpdConfTree instead.

A combiner for parsing all httpd configurations. It parses all sources and makes a composition to store actual loaded values of the settings as well as information about parsed configuration files and raw values.

Note

ParsedData is a named tuple with the following properties:
  • value - the value of the option.

  • line - the complete line as found in the config file.

  • section - the section type that the option belongs to.

  • section_name - the section name that the option belongs to.

  • file_name - the config file name.

  • file_path - the complete config file path.

ConfigData is a named tuple with the following properties:
  • file_name - the config file name.

  • file_path - the complete config file path.

  • data_dict - original data dictionary from parser.

data

Dictionary of parsed settings in format {option: [ParsedData, ParsedData]}. It stores a list of parsed values, usually only the last value is needed, except situations when directives which can use selective overriding, such as UserDir, are used.

Type

dict

config_data

List of parsed config files in containing ConfigData named tuples.

Type

list

class ConfigData(file_name, file_path, full_data_dict)

Bases: tuple

property file_name
property file_path
property full_data_dict
get_active_setting(directive, section=None)[source]

Returns the parsed data of the specified directive as a list of named tuples.

Parameters
  • directive (str) -- The directive to look for

  • section (str or tuple) --

    The section the directive belongs to

    • str: The section type, e.g. “IfModule”

    • tuple(section, section_name): e.g. (“IfModule”, “prefork”)

    Note::

    section_name can be ignored or can be a part of the actual name.

Returns

When section is not None, returns the list of named tuples ParsedData, in order how they are parsed. If directive or section does not exist, returns empty list.

When section is None, returns the named tuple ParsedData of the directive directly. If directive or section does not exist, returns None.

Return type

(list or named tuple ParsedData)

get_section_list(section)[source]

Returns the specified sections.

Parameters

section (str) -- The section to look for, e.g. “Directory”

Returns

List of tuples, each tuple has three elements - the first being a tuple of the section and section name, the second being the file name of the file where that section resides, the third being the full file path of the file. Therefore, the result looks like this: [((‘VirtualHost’, ‘192.0.2.1’), ‘00-z.conf’, ‘/etc/httpd/conf.d/00-z.conf’)]

If section does not exist, returns empty list.

Return type

(list of tuple)

get_setting_list(directive, section=None)[source]

Returns the parsed data of the specified directive as a list

Parameters
  • directive (str) -- The directive to look for

  • section (str or tuple) --

    The section the directive belongs to

    • str: The section type, e.g. “IfModule”

    • tuple(section, section_name): e.g. (“IfModule”, “prefork”)

    Note::

    section_name can be ignored or can be a part of the actual name.

Returns

When section is not None, returns the list of dict that wraps the section and the directive’s named tuples ParsedData, in order how they are parsed.

When section is None, returns the list of named tuples ParsedData, in order how they are parsed.

If directive or section does not exist, returns empty list.

Return type

(list of dict or named tuple ParsedData)

class insights.combiners.httpd_conf.HttpdConfSclHttpd24Tree(confs)[source]

Bases: insights.core.ConfigCombiner

Exposes httpd configuration Software Collection httpd24 through the parsr query interface. Correctly handles all include directives.

See the insights.core.ConfigComponent class for example usage.

class insights.combiners.httpd_conf.HttpdConfSclJbcsHttpd24Tree(confs)[source]

Bases: insights.core.ConfigCombiner

Exposes httpd configuration Software Collection jbcs-httpd24 through the parsr query interface. Correctly handles all include directives.

See the insights.core.ConfigComponent class for example usage.

class insights.combiners.httpd_conf.HttpdConfTree(confs)[source]

Bases: insights.core.ConfigCombiner

Exposes httpd configuration through the parsr query interface. Correctly handles all include directives.

See the insights.core.ConfigComponent class for example usage.

insights.combiners.httpd_conf.get_tree(root=None)[source]

This is a helper function to get an httpd configuration component for your local machine or an archive. Use it in interactive sessions.

insights.combiners.httpd_conf.in_network(val)

Predicate to check if an ip address is in a given network.

Example

conf[“VirtualHost”, in_network(“128.39.0.0/16”)]

insights.combiners.httpd_conf.is_private = <insights.parsr.query.boolean.Predicate object>

Predicate to check if an ip address is private.

Example

conf[“VirtualHost”, in_network(“128.39.0.0/16”)]

insights.combiners.httpd_conf.parse_doc(content, ctx=None)[source]

Parse a configuration document into a tree that can be queried.