Skip to content

neops.core.provider.generic_jinja_check

GenericJinjaCheckProvider

This Provider is used to set check results from existing facts or checks.


JSON Schema

Generic Jinja Check

Properties
  • check_key (string): Set the key where the check is saved.

  • check_on (string): Select on which entity you want save the Check. Must be one of: ['GROUP', 'DEVICE', 'INTERFACE', 'CLIENT ON GROUP', 'CLIENT ON INTERFACE'].

  • template (string): Jinja Template to set the check results. Default: {% do neops.set_result(True) %} {% do neops.set_reason("because") %}.


Template

The Jinja template which is processed to map the values to the new facts.

The following parameters are passed to the template processing:

  • input: all inputs from the task run arguments
  • entity objects based on check_on
    • none on GLOBAL
    • device_group: on GROUP, the current device group object serialized as dictionary
    • device: on DEVICE, the current device object serialized as dictionary
    • interface: on INTERFACE, the current interface object serialized as dictionary
    • client: on CLIENT ON GROUP or CLIENT ON INTERFACE, the current client object serialized as dictionary
  • neops: the neops object brings methods to access to other elements over the neops.io search and to save the facts objects
    • neops.search_devices(query): returns a list of devices found by the search query
    • neops.search_interfaces(query): returns a list of interfaces found by the search query
    • neops.search_device_groups(query): returns a list of groups found by the search query
    • neops.search_client(query): returns a list of clients found by the search query
    • neops.get_common_facts(key): returns the common/global fact of the given key
    • neops.set_result(result): sets the check result, if the check is successful (ok or true), not successful (nok or false) or if the check execution is failed (any other value)
    • neops.set_metrics(metrics): set metrics values (dictionary) of a check
    • neops.set_reason(reason): set reason for the check result
    • set reference to related results for teardown
      • neops.add_related_device_group_facts(device_group_id, fact_key): set reference to device group facts by id and fact key
      • neops.add_related_device_facts(device_id, fact_key): set reference to device facts by id and fact key
      • neops.add_related_interface_facts(interface_id, fact_key): set reference to interface facts by id and fact key
      • neops.add_related_client_facts(client_id, fact_key): set reference to client facts by id and fact key
      • neops.add_related_device_group_check(device_group_id, check_key): set reference to device group check by id and check key
      • neops.add_related_device_check(device_id, check_key): set reference to device check by id and check key
      • neops.add_related_interface_check(interface_id, check_key): set reference to interface check by id and check key
      • neops.add_related_client_check(client_id, check_key): set reference to client check by id and check key

For more information on how to build a Jinja2 template, have a look at Appendix under Jinja2

Methods

run_on_client_of_interface(self,task: nornir.core.task.Task,client_id: int,check_on: str,template: str,**kwargs) -> Union[neops.core.provider.base.base_check.NeopsCheckResult, NoneType]
Processes the template if the "Check on" is set to CLIENT ON INTERFACE


run_on_client_of_location(self,client_id: int,check_on: str,template: str,**kwargs) -> Union[neops.core.provider.base.base_check.NeopsCheckResult, NoneType]
Processes the template if the "Check on" is set to CLIENT ON GROUP


run_on_device(self,task: nornir.core.task.Task,device_id: int,check_on: str,template: str,**kwargs) -> Union[neops.core.provider.base.base_check.NeopsCheckResult, NoneType]
Processes the template if the "Check on" is set to DEVICE


run_on_device_group(self,device_group_id: int,check_on: str,template: str,**kwargs) -> Union[neops.core.provider.base.base_check.NeopsCheckResult, NoneType]
Processes the template if the "Check on" is set to GROUP


run_on_interface(self,task: nornir.core.task.Task,interface_id: int,check_on: str,template: str,**kwargs) -> Union[neops.core.provider.base.base_check.NeopsCheckResult, NoneType]
Processes the template if the "Check on" is set to INTERFACE