Skip to content

neops.core.provider.device_exec_from_jinja

DeviceJinjaExecProvider

Provider to execute commands in exec mode


Device Configure Parameters

Template

A Jinja Template which is processed before apply the result of this template.

The following parameters are passed to the template processing:

  • input: all inputs from the task run arguments
  • device: the current device object serialized as dictionary
  • neops: the neops object brings methods to access to other elements over the neops.io search
    • 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

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

Example of device and neops usage (only to show usage, config change doesn't make sense):

copy ftp://host/file.text flash: :expect destination
yes
Expecting User Feedback

Normally a prompt is expected after executing commands on a device. But as you can see in the template above, there could be commands whichone are asking for user feedback. To handle user feedbacks you can pass an other value than the prompt to be expected by passing :expect [expect value].


JSON Schema

Device Exec

Properties
  • template (string): Jinja Template to generate the configuration.

Methods

run_on_device(self,task: nornir.core.task.Task,device_id: int,**kwargs) -> nornir.core.task.Result
run_on_device is called by the run cycle. It processes the template and executes the commands on the device