templates
Templates module.
- class homer.templates.DeviceConfigurationBase(config: dict)[source]
Bases:
ABCabstractA base class for all the device configurations.Initialize the instance.
- Parameters:
config (dict) -- the generated configuration.
- class homer.templates.JinjaDeviceConfiguration(config: dict)[source]
Bases:
DeviceConfigurationBaseThe device configuration returned as a string combining the ACLs and other config.
Initialize the instance.
- Parameters:
config (dict) -- the generated configuration.
- class homer.templates.JinjaRenderer(base_path: str, base_private_path: str = '')[source]
Bases:
RendererBaseLoad and render templates using Jinja.
Initialize the instance.
- Parameters:
base_path (str) -- the base path to initialize the Jinja2 environment with. All templates path must be relative to this base path.
base_private_path (str, optional) -- a secondary base path to initialize the Jinja2 environment with. Templates that are not found in base_path will be looked up in this secondary private location.
- render(template_name: str, data: Mapping, acls: list) homer.templates.DeviceConfigurationBase[source]
Render a template with the given data.
- Parameters:
- Raises:
homer.exceptions.HomerError -- on error.
- Returns:
the rendered template on success. None: on failure.
- Return type:
- class homer.templates.PythonRenderer(base_path: str, base_private_path: str = '')[source]
Bases:
RendererBaseGenerate the configuration using Python modules.
Initialize the instance.
- Parameters:
- render(template_name: str, data: Mapping, acls: list) homer.templates.DeviceConfigurationBase[source]
Render a template with the given data.
- Parameters:
- Raises:
homer.exceptions.HomerError -- on error.
- Returns:
the rendered template on success.
- Return type:
- class homer.templates.RendererBase(base_path: str, base_private_path: str = '')[source]
Bases:
ABCabstractBase class for the configuration renderers.Initialize the instance.
- Parameters:
- abstract render(template_name: str, data: Mapping, acls: list) homer.templates.DeviceConfigurationBase[source]
Render a template with the given data.
- Parameters:
- Raises:
homer.exceptions.HomerError -- on error.
- Returns:
the rendered template on success. None: on failure.
- Return type: