neulab/tldr huggingface dataset:
salt.modules.napalm_formula.traverse(data, key, default=None, delimiter=':') Traverse a dict or list using a colon-delimited (or otherwise delimited, using the delimiter param) target string. The target foo:bar:0 will return data['foo']['bar'][0] if this value exists, and will otherwise return the dict in the default argument. Function will automatically determine the target type.  The target foo:bar:0 will return data['foo']['bar'][0] if data like {'foo':{'bar':['baz']}} , if data like {'foo':{'bar':{'0':'baz'}}} then return data['foo']['bar']['0']
salt '*' napalm_formula.traverse "{'foo': {'bar': {'baz': True}}}" foo:baz:bar
salt.modules.napalm_mod NAPALM helpers Helpers for the NAPALM modules.
salt.modules.napalm_mod.alive(**kwargs) Returns the alive status of the connection layer.  The output is a dictionary under the usual dictionary output of the NAPALM modules.
salt '*' napalm.alive
result: True out: is_alive: False comment: ''
salt.modules.napalm_mod.call(method, *args, **kwargs) Execute arbitrary methods from the NAPALM library.  To see the expected output, please consult the NAPALM documentation.
NOTE: This feature is not recommended to be used in production.  It should be used for testing only!
salt '*' napalm.call get_lldp_neighbors salt '*' napalm.call get_firewall_policies salt '*' napalm.call get_bgp_config group='my-group'
salt.modules.napalm_mod.compliance_report(filepath=None, string=None, renderer='jinja|yaml', **kwargs) Return the compliance report.
filepath The absolute path to the validation file.
Beginning with release codename 2019.2.0, this function has been enhanced, to be able to leverage the multi-engine template rendering of Salt, besides the possibility to retrieve the file source from remote systems, the URL schemes supported being:
• http:// and https://
• swift:/
Or on the local file system (on the Minion).
NOTE: The rendering result does not necessarily need to be YAML, instead it can be any format interpreted by Salt's rendering pipeline (including pure Python).
string New in version 2019.2.0.
The compliance report send as inline string, to be used as the file to send through the renderer system. Note, not all renderer modules can work with strings; the 'py' renderer requires a file, for example.
renderer: jinja|yaml New in version 2019.2.0.
The renderer pipe to send the file through; this is overridden by a "she-bang" at the top of the file.
kwargs Changed in version 2019.2.0.
Keyword args to pass to Salt's compile_template() function.
salt '*' napalm.compliance_report ~/validate.yml salt '*' napalm.compliance_report salt://path/to/validator.sls
Validation File Example (pure YAML):
- get_facts: os_version: 4.17
- get_interfaces_ip: Management1: ipv4: 10.0.2.14: prefix_length: 24 _mode: strict
Validation File Example (as Jinja + YAML):
- get_facts: os_version: {{ grains.version }} - get_interfaces_ip: Loopback0: ipv4: {{ grains.lo0.ipv4 }}: prefix_length: 24 _mode: strict - get_bgp_neighbors: {{ pillar.bgp.neighbors }}
device1: ---------- comment: out: ---------- complies: False get_facts: ---------- complies: False extra: missing: present: ---------- os_version: ---------- actual_value: 15.1F6-S1.4 complies: False nested: False get_interfaces_ip: ---------- complies: False extra: missing: - Management1 present: ---------- skipped: result: True
salt.modules.napalm_mod.config_diff_text(source1='candidate', candidate_path=None, source2='running', running_path=None) New in version 2019.2.0.
Return the diff, as text, between the two different configuration sources.  The sources can be either specified using the source1 and source2 arguments when retrieving from the managed network device.
source1: candidate The source from where to retrieve the configuration to be compared with.  Available options: candidate, running, startup. Default: candidate.
source2: running The source from where to retrieve the configuration to compare with.  Available options: candidate, running, startup. Default: running.
salt '*' napalm.config_diff_text salt '*' napalm.config_diff_text candidate_path=https://bit.ly/2mAdq7z # Would compare the running config with the configuration available at # https://bit.ly/2mAdq7z
salt.modules.napalm_mod.config_diff_tree(source1='candidate', candidate_path=None, source2='running', running_path=None) New in version 2019.2.0.
Return the diff, as Python dictionary, between two different sources.  The sources can be either specified using the source1 and source2 arguments when retrieving from the managed network device.
salt '*' napalm.config_diff_tree salt '*' napalm.config_diff_tree running startup
salt.modules.napalm_mod.config_filter_lines(parent_regex, child_regex, source='running') New in version 2019.2.0.
Return a list of detailed matches, for the configuration blocks (parent-child relationship) whose parent respects the regular expressions configured via the parent_regex argument, and the child matches the child_regex regular expression. The result is a list of dictionaries with the following keys:
NOTE: This function is only available only when the underlying library ciscoconfparse is installed. See ciscoconfparse module for more details.
parent_regex The regular expression to match the parent configuration lines against.
child_regex The regular expression to match the child configuration lines against.
source: running The configuration type to retrieve from the network device. Default: running. Available options: running, startup, candidate.
salt '*' napalm.config_filter_lines '^interface' 'ip address' salt '*' napalm.config_filter_lines '^interface' 'shutdown' source=candidate
salt.modules.napalm_mod.config_find_lines(regex, source='running') New in version 2019.2.0.
Return the configuration lines that match the regular expressions from the regex argument. The configuration is read from the network device interrogated.
regex  The regular expression to match the configuration lines against.
salt '*' napalm.config_find_lines '^interface Ethernet1\d'
salt.modules.napalm_mod.config_lines_w_child(parent_regex, child_regex, source='running') New in version 2019.2.0.
Return the configuration lines that match the regular expressions from the parent_regex argument, having child lines matching child_regex.  The configuration is read from the network device interrogated.
salt '*' napalm.config_lines_w_child '^interface' 'ip address' salt '*' napalm.config_lines_w_child '^interface' 'shutdown' source=candidate
salt.modules.napalm_mod.config_lines_wo_child(parent_regex, child_regex, source='running') New in version 2019.2.0.
Return the configuration lines that match the regular expressions from the parent_regex argument, having the child lines not matching child_regex.  The configuration is read from the network device interrogated.
salt '*' napalm.config_lines_wo_child '^interface' 'ip address' salt '*' napalm.config_lines_wo_child '^interface' 'shutdown' source=candidate
salt.modules.napalm_mod.config_merge_diff(source='running', merge_config=None, merge_path=None, saltenv='base') New in version 2019.2.0.
Return the merge diff, as text, after merging the merge config into the configuration source requested (without loading the config on the device).
saltenv: base Salt fileserver environment from which to retrieve the file.  Ignored if merge_path is not a salt:// URL.
salt '*' napalm.config_merge_diff merge_path=salt://path/to/merge.cfg
salt.modules.napalm_mod.config_merge_text(source='running', merge_config=None, merge_path=None, saltenv='base') New in version 2019.2.0.
Return the merge result of the configuration from source with the merge configuration, as plain text (without loading the config on the device).
salt '*' napalm.config_merge_text merge_path=salt://path/to/merge.cfg
salt.modules.napalm_mod.config_merge_tree(source='running', merge_config=None, merge_path=None, saltenv='base') New in version 2019.2.0.
Return the merge tree of the initial_config with the merge_config, as a Python dictionary.
salt '*' napalm.config_merge_tree merge_path=salt://path/to/merge.cfg
salt.modules.napalm_mod.config_tree(source='running', with_tags=False) New in version 2019.2.0.
Transform Cisco IOS style configuration to structured Python dictionary.  Depending on the value of the with_tags argument, this function may provide different views, valuable in different situations.
salt '*' napalm.config_tree
salt.modules.napalm_mod.junos_call(fun, *args, **kwargs) New in version 2019.2.0.
Execute an arbitrary function from the junos execution module. To check what args and kwargs you must send to the function, please consult the appropriate documentation.
fun    The name of the function. E.g., set_hostname.
args   List of arguments to send to the junos function invoked.
kwargs Dictionary of key-value arguments to send to the juno function invoked.
salt '*' napalm.junos_fun cli 'show system commit'
salt.modules.napalm_mod.junos_cli(command, format=None, dev_timeout=None, dest=None, **kwargs) New in version 2019.2.0.
Execute a CLI command and return the output in the specified format.
command The command to execute on the Junos CLI.
format: text Format in which to get the CLI output (either text or xml).
dev_timeout: 30 The NETCONF RPC timeout (in seconds).
dest   Destination file where the RPC output is stored. Note that the file will be stored on the Proxy Minion. To push the files to the Master, use cp.push.
salt '*' napalm.junos_cli 'show lldp neighbors'
salt.modules.napalm_mod.junos_commit(**kwargs) New in version 2019.2.0.
Commit the changes loaded in the candidate configuration.
comment Provide a comment for the commit.
sync: False When True, on dual control plane systems, requests that the candidate configuration on one control plane be copied to the other control plane, checked for correct syntax, and committed on both Routing Engines.
force_sync: False When True, on dual control plane systems, force the candidate configuration on one control plane to be copied to the other control plane.
detail When True, return commit detail.
salt '*' napalm.junos_commit comment='Commitiing via Salt' detail=True salt '*' napalm.junos_commit dev_timeout=60 confirm=10 salt '*' napalm.junos_commit sync=True dev_timeout=90
salt.modules.napalm_mod.junos_copy_file(src, dst, **kwargs) New in version 2019.2.0.
Copies the file on the remote Junos device.
src    The source file path. This argument accepts the usual Salt URIs (e.g., salt://, http://, https://, s3://, ftp://, etc.).
dst    The destination path on the device where to copy the file.
salt '*' napalm.junos_copy_file https://example.com/junos.cfg /var/tmp/myjunos.cfg
salt.modules.napalm_mod.junos_facts(**kwargs) New in version 2019.2.0.
The complete list of Junos facts collected by junos-eznc.
salt '*' napalm.junos_facts
salt.modules.napalm_mod.junos_install_os(path=None, **kwargs) New in version 2019.2.0.
Installs the given image on the device.
path   The image file source. This argument supports the following URIs:
• Absolute path on the Minion.
• salt:// to fetch from the Salt fileserver.
dev_timeout: 30 The NETCONF RPC timeout (in seconds)
reboot: False Whether to reboot the device after the installation is complete.
no_copy: False If True the software package will not be copied to the remote device.
salt '*' napalm.junos_install_os salt://images/junos_16_1.tgz reboot=True
salt.modules.napalm_mod.junos_rpc(cmd=None, dest=None, format=None, **kwargs) New in version 2019.2.0.
Execute an RPC request on the remote Junos device.
cmd    The RPC request to the executed. To determine the RPC request, you can check the from the command line of the device, by executing the usual command followed by | display xml rpc, e.g., show lldp neighbors | display xml rpc.
dest   Destination file where the RPC output is stored. Note that the file will be stored on the Proxy Minion. To push the files to the Master, use cp.push Execution function.
format: xml The format in which the RPC reply is received from the device.
dev_timeout: 30 The NETCONF RPC timeout.
filter Used with the get-config RPC request to filter out the config tree.
terse: False Whether to return terse output.
NOTE: Some RPC requests may not support this argument.
interface_name Name of the interface to query.
salt '*' napalm.junos_rpc get-lldp-neighbors-information salt '*' napalm.junos_rpc get-config <configuration><system><ntp/></system></configuration>
salt.modules.napalm_mod.netmiko_args(**kwargs) New in version 2019.2.0.
Return the key-value arguments used for the authentication arguments for the netmiko module.
When running in a non-native NAPALM driver (e.g., panos, f5`, mos - either from https://github.com/napalm-automation-community or defined in user's own environment, one can specify the Netmiko device type (the device_type argument) via the netmiko_device_type_map configuration option / Pillar key, e.g.,
netmiko_device_type_map: f5: f5_ltm dellos10: dell_os10
The configuration above defines the mapping between the NAPALM os Grain and the Netmiko device_type, e.g., when the NAPALM Grain is f5, it would use the f5_ltm SSH Netmiko driver to execute commands over SSH on the remote network device.
salt '*' napalm.netmiko_args
salt.modules.napalm_mod.netmiko_call(method, *args, **kwargs) New in version 2019.2.0.
Execute an arbitrary Netmiko method, passing the authentication details from the existing NAPALM connection.
method The name of the Netmiko method to execute.
args   List of arguments to send to the Netmiko method specified in method.
kwargs Key-value arguments to send to the execution function specified in method.
salt '*' napalm.netmiko_call send_command 'show version'
salt.modules.napalm_mod.netmiko_commands(*commands, **kwargs) New in version 2019.2.0.
Invoke one or more commands to be executed on the remote device, via Netmiko.  Returns a list of strings, with the output from each command.
commands A list of commands to be executed.
expect_string Regular expression pattern to use for determining end of output.  If left blank will default to being based on router prompt.
delay_factor: 1 Multiplying factor used to adjust delays (default: 1).
max_loops: 500 Controls wait time in conjunction with delay_factor. Will default to be based upon self.timeout.
auto_find_prompt: True Whether it should try to auto-detect the prompt (default: True).
strip_prompt: True Remove the trailing router prompt from the output (default: True).
strip_command: True Remove the echo of the command from the output (default: True).
normalize: True Ensure the proper enter is sent at end of command (default: True).
use_textfsm: False Process command output through TextFSM template (default: False).
salt '*' napalm.netmiko_commands 'show version' 'show interfaces'
salt.modules.napalm_mod.netmiko_config(*config_commands, **kwargs) New in version 2019.2.0.
Load a list of configuration commands on the remote device, via Netmiko.
WARNING: Please remember that netmiko does not have any rollback safeguards and any configuration change will be directly loaded into the running config if the platform doesn't have the concept of candidate config.
On Junos, or other platforms that have this capability, the changes will not be loaded into the running config, and the user must set the commit argument to True to transfer the changes from the candidate into the running config before exiting.
config_commands A list of configuration commands to be loaded on the remote device.
config_file Read the configuration commands from a file. The file can equally be a template that can be rendered using the engine of choice (see template_engine).
exit_config_mode: True Determines whether or not to exit config mode after complete.
delay_factor: 1 Factor to adjust delays.
max_loops: 150 Controls wait time in conjunction with delay_factor (default: 150).
strip_prompt: False Determines whether or not to strip the prompt (default: False).
strip_command: False Determines whether or not to strip the command (default: False).
config_mode_command The command to enter into config mode.
commit: False Commit the configuration changes before exiting the config mode. This option is by default disabled, as many platforms don't have this capability natively.
salt '*' napalm.netmiko_config 'set system ntp peer 1.2.3.4' commit=True salt '*' napalm.netmiko_config https://bit.ly/2sgljCB
salt.modules.napalm_mod.netmiko_conn(**kwargs) New in version 2019.2.0.
Return the connection object with the network device, over Netmiko, passing the authentication details from the existing NAPALM connection.
WARNING: This function is not suitable for CLI usage, more rather to be used in various Salt modules.
conn = __salt__['napalm.netmiko_conn']() res = conn.send_command('show interfaces') conn.disconnect()
salt.modules.napalm_mod.netmiko_fun(fun, *args, **kwargs) New in version 2019.2.0.
Call an arbitrary function from the Netmiko module, passing the authentication details from the existing NAPALM connection.
fun    The name of the function from the Netmiko to invoke.
args   List of arguments to send to the execution function specified in fun.
kwargs Key-value arguments to send to the execution function specified in fun.
salt '*' napalm.netmiko_fun send_command 'show version'
salt.modules.napalm_mod.netmiko_multi_call(*methods, **kwargs) New in version 2019.2.0.
Execute a list of arbitrary Netmiko methods, passing the authentication details from the existing NAPALM connection.
methods List of dictionaries with the following keys:
• name: the name of the Netmiko function to invoke.
• args: list of arguments to send to the name method.
• kwargs: key-value arguments to send to the name method.
salt '*' napalm.netmiko_multi_call "{'name': 'send_command', 'args': ['show version']}" "{'name': 'send_command', 'args': ['show interfaces']}"
salt.modules.napalm_mod.nxos_api_config(commands=None, config_file=None, template_engine='jinja', context=None, defaults=None, saltenv='base', **kwargs) New in version 2019.2.0.
Configures the Nexus switch with the specified commands, via the NX-API.
commands The list of configuration commands to load on the Nexus switch.
The file can also be a template that can be rendered using the template engine of choice. This can be specified using the absolute path to the file, or using one of the following URL schemes:
• https://
• ftp:/
• s3:/
context: None Variables to add to the template context.
defaults: None Default values of the context dict.
saltenv: base Salt fileserver environment from which to retrieve the file. Ignored if config_file is not a salt:// URL.
salt '*' napalm.nxos_api_config 'spanning-tree mode mstp' salt '*' napalm.nxos_api_config config_file=https://bit.ly/2LGLcDy context="{'servers': ['1.2.3.4']}"
salt.modules.napalm_mod.nxos_api_rpc(commands, method='cli', **kwargs) New in version 2019.2.0.
Execute an arbitrary RPC request via the Nexus API.
commands The RPC commands to be executed.
method: cli The type of the response, i.e., raw text (cli_ascii) or structured document (cli). Defaults to cli (structured data).
salt '*' napalm.nxos_api_rpc 'show version'
salt.modules.napalm_mod.nxos_api_show(commands, raw_text=True, **kwargs) New in version 2019.2.0.
Execute one or more show (non-configuration) commands.
commands The commands to be executed.
raw_text: True Whether to return raw text or structured data.
salt '*' napalm.nxos_api_show 'show version' salt '*' napalm.nxos_api_show 'show bgp sessions' 'show processes' raw_text=False
salt.modules.napalm_mod.pyeapi_call(method, *args, **kwargs) New in version 2019.2.0.
Invoke an arbitrary method from the pyeapi library.  This function forwards the existing connection details to the pyeapi.run_commands execution function.
kwargs Key-value arguments to send to the pyeapi method.
salt '*' napalm.pyeapi_call run_commands 'show version' encoding=text salt '*' napalm.pyeapi_call get_config as_string=True
salt.modules.napalm_mod.pyeapi_config(commands=None, config_file=None, template_engine='jinja', context=None, defaults=None, saltenv='base', **kwargs) New in version 2019.2.0.
Configures the Arista switch with the specified commands, via the pyeapi library. This function forwards the existing connection details to the pyeapi.run_commands execution function.
commands The list of configuration commands to load on the Arista switch.
salt '*' napalm.pyeapi_config 'ntp server 1.2.3.4'
salt.modules.napalm_mod.pyeapi_conn(**kwargs) New in version 2019.2.0.
Return the connection object with the Arista switch, over pyeapi, passing the authentication details from the existing NAPALM connection.
WARNING: This function is not suitable for CLI usage, more rather to be used in various Salt modules, to reusing the established connection, as in opposite to opening a new connection for each task.
conn = __salt__['napalm.pyeapi_conn']() res1 = conn.run_commands('show version') res2 = conn.get_config(as_string=True)
salt.modules.napalm_mod.pyeapi_nxos_api_args(**prev_kwargs) New in version 2019.2.0.
Return the key-value arguments used for the authentication arguments for the pyeapi execution module.
salt '*' napalm.pyeapi_nxos_api_args
salt.modules.napalm_mod.pyeapi_run_commands(*commands, **kwargs) Execute a list of commands on the Arista switch, via the pyeapi library.  This function forwards the existing connection details to the pyeapi.run_commands execution function.
commands A list of commands to execute.
encoding: json The requested encoding of the command output. Valid values for encoding are json (default) or text.
salt '*' napalm.pyeapi_run_commands 'show version' encoding=text salt '*' napalm.pyeapi_run_commands 'show ip bgp neighbors'
salt.modules.napalm_mod.reconnect(force=False, **kwargs) Reconnect the NAPALM proxy when the connection is dropped by the network device.  The connection can be forced to be restarted using the force argument.
NOTE: This function can be used only when running proxy minions.
salt '*' napalm.reconnect salt '*' napalm.reconnect force=True
salt.modules.napalm_mod.rpc(command, **kwargs) New in version 2019.2.0.
This is a wrapper to execute RPC requests on various network operating systems supported by NAPALM, invoking the following functions for the NAPALM native drivers:
• napalm.junos_rpc for junos
• napalm.pyeapi_run_commands for eos
• napalm.nxos_api_rpc for nxos
• napalm.netmiko_commands for ios, iosxr, and nxos_ssh
command The RPC command to execute. This depends on the nature of the operating system.
kwargs Key-value arguments to be sent to the underlying Execution function.
The function capabilities are extensible in the user environment via the napalm_rpc_map configuration option / Pillar, e.g.,
napalm_rpc_map: f5: napalm.netmiko_commands panos: panos.call
The mapping above reads: when the NAPALM os Grain is f5, then call napalm.netmiko_commands for RPC requests.
By default, if the user does not specify any map, non-native NAPALM drivers will invoke the napalm.netmiko_commands Execution function.
salt '*' napalm.rpc 'show version' salt '*' napalm.rpc get-interfaces
salt.modules.napalm_mod.scp_get(remote_path, local_path='', recursive=False, preserve_times=False, **kwargs) New in version 2019.2.0.
Transfer files and directories from remote network device to the localhost of the Minion.
NOTE: This function is only available only when the underlying library scp is installed. See scp module for more details.
remote_path Path to retrieve from remote host. Since this is evaluated by scp on the remote host, shell wildcards and environment variables may be used.
recursive: False Transfer files and directories recursively.
preserve_times: False Preserve mtime and atime of transferred files and directories.
passphrase Used for decrypting private keys.
pkey   An optional private key to use for authentication.
key_filename The filename, or list of filenames, of optional private key(s) and/or certificates to try for authentication.
timeout An optional timeout (in seconds) for the TCP connect.
socket_timeout: 10 The channel socket timeout in seconds.
buff_size: 16384 The size of the SCP send buffer.
allow_agent: True Set to False to disable connecting to the SSH agent.
look_for_keys: True Set to False to disable searching for discoverable private key files in ~/.ssh/
banner_timeout An optional timeout (in seconds) to wait for the SSH banner to be presented.
auth_timeout An optional timeout (in seconds) to wait for an authentication response.
auto_add_policy: False Automatically add the host to the known_hosts.
salt '*' napalm.scp_get /var/tmp/file /tmp/file auto_add_policy=True
salt.modules.napalm_mod.scp_put(files, remote_path=None, recursive=False, preserve_times=False, saltenv='base', **kwargs) New in version 2019.2.0.
Transfer files and directories to remote network device.
files  A single path or a list of paths to be transferred.
remote_path The path on the remote device where to store the files.
recursive: True Transfer files and directories recursively.
saltenv: base The name of the Salt environment. Ignored when files is not a salt:// URL.
hostname The hostname of the remote device.
port: 22 The port of the remote device.
username The username required for SSH authentication on the device.
password Used for password authentication. It is also used for private key decryption if passphrase is not given.
salt '*' napalm.scp_put /path/to/file /var/tmp/file auto_add_policy=True
salt.modules.napalm_netacl NAPALM ACL Generate and load ACL (firewall) configuration on network devices.
depends capirca, napalm
To be able to load configuration on network devices, it requires NAPALM library to be installed:  pip install napalm.  Please check Installation for complete details.
salt.modules.napalm_netacl.get_filter_pillar(filter_name, pillar_key='acl', pillarenv=None, saltenv=None) Helper that can be used inside a state SLS, in order to get the filter configuration given its name.
salt.modules.napalm_netacl.get_term_pillar(filter_name, term_name, pillar_key='acl', pillarenv=None, saltenv=None) Helper that can be used inside a state SLS, in order to get the term configuration given its name, under a certain filter uniquely identified by its name.
salt.modules.napalm_netacl.load_filter_config(filter_name, filter_options=None, terms=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, only_lower_merge=False, revision_id=None, revision_no=None, revision_date=True, revision_date_format='%Y/%m/%d', test=False, commit=True, debug=False, **kwargs) Generate and load the configuration of a policy filter.
NOTE: The order of the terms is very important. The configuration loaded on the device respects the order defined in the terms and/or inside the pillar.
When merging the terms with the pillar data, consider the prepend argument to make sure the order is correct!
The merge logic depends on the prepend argument and the CLI has higher priority than the pillar.
only_lower_merge: False Specify if it should merge only the terms fields. Otherwise it will try to merge also filters fields. Default: False. This option requires merge_pillar, otherwise it is ignored.
test: False Dry run? If set as True, will apply the config, discard and return the changes.  Default: False and will commit the changes on the device.
commit: True Commit? Default: True.
debug: False Debug mode. Will insert a new key under the output dictionary, as loaded_config containing the raw configuration loaded on the device.
The output is a dictionary having the same form as net.load_config.
salt 'edge01.bjm01' netacl.load_filter_config my-filter pillar_key=netacl debug=True
edge01.bjm01: ---------- already_configured: False comment: diff: [edit firewall] +    family inet { +        /* +         ** $Date: 2017/03/22 $ +         ** +         */ +        filter my-filter { +            interface-specific; +            term my-term { +                from { +                    source-port [ 1234 1235 ]; +                } +                then { +                    reject; +                } +            } +            term my-other-term { +                from { +                    protocol tcp; +                    source-port 5678-5680; +                } +                then accept; +            } +        } +    } loaded_config: firewall { family inet { replace: /* ** $Date: 2017/03/22 $ ** */ filter my-filter { interface-specific; term my-term { from { source-port [ 1234 1235 ]; } then { reject; } } term my-other-term { from { protocol tcp; source-port 5678-5680; } then accept; } } } } result: True
netacl: - my-filter: terms: - my-term: source_port: - 1234 - 1235 action: reject - my-other-term: source_port: - - 5678 - 5680 protocol: tcp action: accept
salt.modules.napalm_netacl.load_policy_config(filters=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, only_lower_merge=False, revision_id=None, revision_no=None, revision_date=True, revision_date_format='%Y/%m/%d', test=False, commit=True, debug=False, **kwargs) Generate and load the configuration of the whole policy.
NOTE: The order of the filters and their terms is very important. The configuration loaded on the device respects the order defined in the filters and/or inside the pillar.
When merging the filters with the pillar data, consider the prepend argument to make sure the order is correct!
only_lower_merge: False Specify if it should merge only the filters and terms fields. Otherwise it will try to merge everything at the policy level. Default: False.  This option requires merge_pillar, otherwise it is ignored.
salt 'edge01.flw01' netacl.load_policy_config debug=True
edge01.flw01: ---------- already_configured: False comment: diff: --- +++ @@ -1228,9 +1228,24 @@ ! +ipv4 access-list my-filter + 10 remark my-term + 20 deny tcp host 1.2.3.4 eq 1234 any + 30 deny udp host 1.2.3.4 eq 1234 any + 40 deny tcp host 1.2.3.4 eq 1235 any + 50 deny udp host 1.2.3.4 eq 1235 any + 60 remark my-other-term + 70 permit tcp any range 5678 5680 any +! +! +ipv4 access-list block-icmp + 10 remark first-term + 20 deny icmp any any ! loaded_config: ! $Date: 2017/03/22 $ no ipv4 access-list my-filter ipv4 access-list my-filter remark my-term deny tcp host 1.2.3.4 eq 1234 any deny udp host 1.2.3.4 eq 1234 any deny tcp host 1.2.3.4 eq 1235 any deny udp host 1.2.3.4 eq 1235 any remark my-other-term permit tcp any range 5678 5680 any exit no ipv4 access-list block-icmp ipv4 access-list block-icmp remark first-term deny icmp any any exit result: True
acl: - my-filter: terms: - my-term: source_port: - 1234 - 1235 protocol: - tcp - udp source_address: 1.2.3.4 action: reject - my-other-term: source_port: - [5678, 5680] protocol: tcp action: accept - block-icmp: terms: - first-term: protocol: - icmp action: reject
salt.modules.napalm_netacl.load_term_config(filter_name, term_name, filter_options=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, revision_id=None, revision_no=None, revision_date=True, revision_date_format='%Y/%m/%d', test=False, commit=True, debug=False, source_service=None, destination_service=None, **term_fields) Generate and load the configuration of a policy term.
The properties specified through the CLI have higher priority than the pillar.
term_fields Term attributes. To see what fields are supported, please consult the list of supported keywords. Some platforms have a few other optional keywords.
NOTE: The following fields are accepted (some being platform-specific):
source_port: - - 1000 - 2000 - - 3000 - 4000
salt 'edge01.bjm01' netacl.load_term_config filter-name term-name source_address=1.2.3.4 destination_address=5.6.7.8 action=accept test=True debug=True
edge01.bjm01: ---------- already_configured: False comment: Configuration discarded. diff: [edit firewall] +    family inet { +        /* +         ** $Date: 2017/03/22 $ +         ** +         */ +        filter filter-name { +            interface-specific; +            term term-name { +                from { +                    source-address { +                        1.2.3.4/32; +                    } +                    destination-address { +                        5.6.7.8/32; +                    } +                } +                then accept; +            } +        } +    } loaded_config: firewall { family inet { replace: /* ** $Date: 2017/03/22 $ ** */ filter filter-name { interface-specific; term term-name { from { source-address { 1.2.3.4/32; } destination-address { 5.6.7.8/32; } } then accept; } } } } result: True
salt.modules.napalm_network NAPALM Network Basic methods for interaction with the network device through the virtual proxy 'napalm'.
salt.modules.napalm_network.arp(interface='', ipaddr='', macaddr='', **kwargs) NAPALM returns a list of dictionaries with details of the ARP entries.
• interface -- interface name to filter on
• ipaddr -- IP address to filter on
• macaddr -- MAC address to filter on
Returns List of the entries in the ARP table
salt '*' net.arp salt '*' net.arp macaddr='5c:5e:ab:da:3c:f0'
[ { 'interface' : 'MgmtEth0/RSP0/CPU0/0', 'mac'       : '5c:5e:ab:da:3c:f0', 'ip'        : '172.17.17.1', 'age'       : 1454496274.84 }, { 'interface': 'MgmtEth0/RSP0/CPU0/0', 'mac'       : '66:0e:94:96:e0:ff', 'ip'        : '172.17.17.2', 'age'       : 1435641582.49 } ]
salt.modules.napalm_network.blockreplace(marker_start, marker_end, content='', append_if_not_found=False, prepend_if_not_found=False, show_changes=True, append_newline=False, source='running', path=None, test=False, commit=True, debug=False, replace=True) New in version 2019.2.0.
Replace content of the configuration source, delimited by the line markers.
A block of content delimited by comments can help you manage several lines without worrying about old entries removal.
marker_start The line content identifying a line as the start of the content block.  Note that the whole line containing this marker will be considered, so whitespace or extra content before or after the marker is included in final output.
marker_end The line content identifying a line as the end of the content block.  Note that the whole line containing this marker will be considered, so whitespace or extra content before or after the marker is included in final output.
append_newline: False Controls whether or not a newline is appended to the content block.  If the value of this argument is True then a newline will be added to the content block. If it is False, then a newline will not be added to the content block. If it is None then a newline will only be added to the content block if it does not already end in a newline.
show_changes: True Controls how changes are presented. If True, this function will return the of the changes made.  If False, then it will return a boolean (True if any changes were made, otherwise False).
source: running The configuration source. Choose from: running, candidate, or startup. Default: running.
path: None Save the temporary configuration to a specific path, then read from there. This argument is optional, can be used when you prefers a particular location of the temporary file.
test: False Dry run? If set as True, will apply the config, discard and return the changes. Default: False and will commit the changes on the device.
commit: True Commit the configuration changes? Default: True.
debug: False Debug mode. Will insert a new key in the output dictionary, as loaded_config containing the raw configuration loaded on the device.
replace: True Load and replace the configuration. Default: True.
salt '*' net.blockreplace 'ntp' 'interface' ''
salt.modules.napalm_network.cancel_commit(jid) New in version 2019.2.0.
Cancel a commit scheduled to be executed via the commit_in and commit_at arguments from the net.load_template or net.load_config execution functions. The commit ID is displayed when the commit is scheduled via the functions named above.
salt '*' net.cancel_commit 20180726083540640360
salt.modules.napalm_network.cli(*commands, **kwargs) Returns a dictionary with the raw output of all commands passed as arguments.
commands List of commands to be executed on the device.
textfsm_parse: False Try parsing the outputs using the TextFSM templates.
NOTE: This option can be also specified in the minion configuration file or pillar as napalm_cli_textfsm_parse.
textfsm_path The path where the TextFSM templates can be found. This option implies the usage of the TextFSM index file. textfsm_path can be either absolute path on the server, either specified using the following URL mschemes: file://, salt://, http://, https://, ftp://, s3://, swift://.
NOTE: This needs to be a directory with a flat structure, having an index file (whose name can be specified using the index_file option) and a number of TextFSM templates.
NOTE: This option can be also specified in the minion configuration file or pillar as textfsm_path.
textfsm_template The path to a certain the TextFSM template.  This can be specified using the absolute path to the file, or using one of the following URL schemes:
• salt://, to fetch the template from the Salt fileserver.
textfsm_template_dict A dictionary with the mapping between a command and the corresponding TextFSM path to use to extract the data.  The TextFSM paths can be specified as in textfsm_template.
NOTE: This option can be also specified in the minion configuration file or pillar as napalm_cli_textfsm_template_dict.
platform_grain_name: os The name of the grain used to identify the platform name in the TextFSM index file. Default: os.
NOTE: This option can be also specified in the minion configuration file or pillar as textfsm_platform_grain.
platform_column_name: Platform The column name used to identify the platform, exactly as specified in the TextFSM index file.  Default: Platform.
NOTE: This is field is case sensitive, make sure to assign the correct value to this option, exactly as defined in the index file.
NOTE: This option can be also specified in the minion configuration file or pillar as textfsm_platform_column_name.
index_file: index The name of the TextFSM index file, under the textfsm_path. Default: index.
NOTE: This option can be also specified in the minion configuration file or pillar as textfsm_index_file.
saltenv: base Salt fileserver environment from which to retrieve the file.  Ignored if textfsm_path is not a salt:// URL.
include_empty: False Include empty files under the textfsm_path.
include_pat Glob or regex to narrow down the files cached from the given path.  If matching with a regex, the regex must be prefixed with E@, otherwise the expression will be interpreted as a glob.
exclude_pat Glob or regex to exclude certain files from being cached from the given path.  If matching with a regex, the regex must be prefixed with E@, otherwise the expression will be interpreted as a glob.
salt '*' net.cli "show version" "show chassis fan"
CLI Example with TextFSM template:
salt '*' net.cli textfsm_parse=True textfsm_path=salt://textfsm/
{ 'show version and haiku':  'Hostname: re0.edge01.arn01 Model: mx480 Junos: 13.3R6.5 Help me, Obi-Wan I just saw Episode Two You're my only hope ', 'show chassis fan' :   'Item                      Status   RPM     Measurement Top Rear Fan              OK       3840    Spinning at intermediate-speed Bottom Rear Fan           OK       3840    Spinning at intermediate-speed Top Middle Fan            OK       3900    Spinning at intermediate-speed Bottom Middle Fan         OK       3840    Spinning at intermediate-speed Top Front Fan             OK       3810    Spinning at intermediate-speed Bottom Front Fan          OK       3840    Spinning at intermediate-speed ' }
Example output with TextFSM parsing:
{ "comment": "", "result": true, "out": { "sh ver": [ { "kernel": "9.1S3.5", "documentation": "9.1S3.5", "boot": "9.1S3.5", "crypto": "9.1S3.5", "chassis": "", "routing": "9.1S3.5", "base": "9.1S3.5", "model": "mx960" } ] } }
salt.modules.napalm_network.commit(inherit_napalm_device=None, **kwargs) Commits the configuration changes made on the network device.
salt '*' net.commit
salt.modules.napalm_network.compare_config(inherit_napalm_device=None, **kwargs) Returns the difference between the running config and the candidate config.
salt '*' net.compare_config
salt.modules.napalm_network.config(source=None, **kwargs) New in version 2017.7.0.
Return the whole configuration of the network device. By default, it will return all possible configuration sources supported by the network device.  At most, there will be:
• running config
• startup config
• candidate config
To return only one of the configurations, you can use the source argument.
source Which configuration type you want to display, default is all of them.
• candidate
• startup
Returns The object returned is a dictionary with the following keys:
• running (string): Representation of the native running configuration.
candidate (string): Representation of the native candidate configuration. If the device doesn't differentiate between running and startup configuration this will an empty string.
startup (string): Representation of the native startup configuration. If the device doesn't differentiate between running and startup configuration this will an empty string.
salt '*' net.config salt '*' net.config source=candidate
salt.modules.napalm_network.config_changed(inherit_napalm_device=None, **kwargs) Will prompt if the configuration has been changed.
Returns A tuple with a boolean that specifies if the config was changed on the device.    And a string that provides more details of the reason why the configuration was not changed.
salt '*' net.config_changed
salt.modules.napalm_network.config_control(inherit_napalm_device=None, **kwargs) Will check if the configuration was changed.  If differences found, will try to commit.  In case commit unsuccessful, will try to rollback.
Returns A tuple with a boolean that specifies if the config was changed/committed/rollbacked on the device.    And a string that provides more details of the reason why the configuration was not committed properly.
salt '*' net.config_control
salt.modules.napalm_network.confirm_commit(jid) New in version 2019.2.0.
Confirm a commit scheduled to be reverted via the revert_in and revert_at  arguments from the net.load_template or net.load_config execution functions. The commit ID is displayed when the commit confirmed is scheduled via the functions named above.
salt '*' net.confirm_commit 20180726083540640360
salt.modules.napalm_network.connected(**kwargs) Specifies if the connection to the device succeeded.
salt '*' net.connected
salt.modules.napalm_network.discard_config(inherit_napalm_device=None, **kwargs) Discards the changes applied.
salt '*' net.discard_config
salt.modules.napalm_network.environment(**kwargs) Returns the environment of the device.
salt '*' net.environment
{ 'fans': { 'Bottom Rear Fan': { 'status': True }, 'Bottom Middle Fan': { 'status': True }, 'Top Middle Fan': { 'status': True }, 'Bottom Front Fan': { 'status': True }, 'Top Front Fan': { 'status': True }, 'Top Rear Fan': { 'status': True } }, 'memory': { 'available_ram': 16349, 'used_ram': 4934 }, 'temperature': { 'FPC 0 Exhaust A': { 'is_alert': False, 'temperature': 35.0, 'is_critical': False } }, 'cpu': { '1': { '%usage': 19.0 }, '0': { '%usage': 35.0 } } }
salt.modules.napalm_network.facts(**kwargs) Returns characteristics of the network device.  :return: a dictionary with the following keys:
• uptime - Uptime of the device in seconds.
• vendor - Manufacturer of the device.
• model - Device model.
• hostname - Hostname of the device
• fqdn - Fqdn of the device
• os_version - String with the OS version running on the device.
• serial_number - Serial number of the device
• interface_list - List of the interfaces of the device
salt '*' net.facts
{ 'os_version': '13.3R6.5', 'uptime': 10117140, 'interface_list': [ 'lc-0/0/0', 'pfe-0/0/0', 'pfh-0/0/0', 'xe-0/0/0', 'xe-0/0/1', 'xe-0/0/2', 'xe-0/0/3', 'gr-0/0/10', 'ip-0/0/10' ], 'vendor': 'Juniper', 'serial_number': 'JN131356FBFA', 'model': 'MX480', 'hostname': 're0.edge05.syd01', 'fqdn': 're0.edge05.syd01' }
salt.modules.napalm_network.interfaces(**kwargs) Returns details of the interfaces on the device.
Returns Returns a dictionary of dictionaries. The keys for the first dictionary will be the interfaces in the devices.
salt '*' net.interfaces
{ 'Management1': { 'is_up': False, 'is_enabled': False, 'description': '', 'last_flapped': -1, 'speed': 1000, 'mac_address': 'dead:beef:dead', }, 'Ethernet1':{ 'is_up': True, 'is_enabled': True, 'description': 'foo', 'last_flapped': 1429978575.1554043, 'speed': 1000, 'mac_address': 'beef:dead:beef', } }
salt.modules.napalm_network.ipaddrs(**kwargs) Returns IP addresses configured on the device.
Returns A dictionary with the IPv4 and IPv6 addresses of the interfaces.  Returns all configured IP addresses on all interfaces as a dictionary of dictionaries.  Keys of the main dictionary represent the name of the interface. Values of the main dictionary represent are dictionaries that may consist of two keys 'ipv4' and 'ipv6' (one, both or none) which are themselvs dictionaries with the IP addresses as keys.
salt '*' net.ipaddrs
{ 'FastEthernet8': { 'ipv4': { '10.66.43.169': { 'prefix_length': 22 } } }, 'Loopback555': { 'ipv4': { '192.168.1.1': { 'prefix_length': 24 } }, 'ipv6': { '1::1': { 'prefix_length': 64 }, '2001:DB8:1::1': { 'prefix_length': 64 }, 'FE80::3': { 'prefix_length': 'N/A' } } } }
salt.modules.napalm_network.lldp(interface='', **kwargs) Returns a detailed view of the LLDP neighbors.
Parameters interface -- interface name to filter on
Returns A dictionary with the LLDL neighbors. The keys are the interfaces with LLDP activated on.
salt '*' net.lldp salt '*' net.lldp interface='TenGigE0/0/0/8'
{ 'TenGigE0/0/0/8': [ { 'parent_interface': 'Bundle-Ether8', 'interface_description': 'TenGigE0/0/0/8', 'remote_chassis_id': '8c60.4f69.e96c', 'remote_system_name': 'switch', 'remote_port': 'Eth2/2/1', 'remote_port_description': 'Ethernet2/2/1', 'remote_system_description': 'Cisco Nexus Operating System (NX-OS) Software 7.1(0)N1(1a) TAC support: http://www.cisco.com/tac Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.', 'remote_system_capab': 'B, R', 'remote_system_enable_capab': 'B' } ] }
salt.modules.napalm_network.load_config(filename=None, text=None, test=False, commit=True, debug=False, replace=False, commit_in=None, commit_at=None, revert_in=None, revert_at=None, commit_jid=None, inherit_napalm_device=None, saltenv='base', **kwargs) Applies configuration changes on the device. It can be loaded from a file or from inline string.  If you send both a filename and a string containing the configuration, the file has higher precedence.
By default this function will commit the changes. If there are no changes, it does not commit and the flag already_configured will be set as True to point this out.
To avoid committing the configuration, set the argument test to True and will discard (dry run).
To keep the changes but not commit, set commit to False.
To replace the config, set replace to True.
filename Path to the file containing the desired configuration. This can be specified using the absolute path to the file, or using one of the following URL schemes:
text   String containing the desired configuration.  This argument is ignored when filename is specified.
replace: False Load and replace the configuration. Default: False.
commit_in: None Commit the changes in a specific number of minutes / hours. Example of accepted formats: 5 (commit in 5 minutes), 2m (commit in 2 minutes), 1h (commit the changes in 1 hour)`, 5h30m (commit the changes in 5 hours and 30 minutes).
NOTE: This feature works on any platforms, as it does not rely on the native features of the network operating system.
NOTE: After the command is executed and the diff is not satisfactory, or for any other reasons you have to discard the commit, you are able to do so using the net.cancel_commit execution function, using the commit ID returned by this function.
WARNING: Using this feature, Salt will load the exact configuration you expect, however the diff may change in time (i.e., if an user applies a manual configuration change, or a different process or command changes the configuration in the meanwhile).
commit_at: None Commit the changes at a specific time. Example of accepted formats: 1am (will commit the changes at the next 1AM), 13:20 (will commit at 13:20), 1:20am, etc.
revert_in: None Commit and revert the changes in a specific number of minutes / hours.  Example of accepted formats: 5 (revert in 5 minutes), 2m (revert in 2 minutes), 1h (revert the changes in 1 hour)`, 5h30m (revert the changes in 5 hours and 30 minutes).
NOTE: To confirm the commit, and prevent reverting the changes, you will have to execute the net.confirm_commit function, using the commit ID returned by this function.