Skip to content

Automatic "get_" prefix in napalm_get.py causes issues with NAPALM Getters #83

@miguletztim

Description

@miguletztim

The line in nornir_napalm/plugins/tasks/napalm_get.py at Line 42:

getter = g if g.startswith("get_") else "get_{}".format(g)

is causing issues when trying to retrieve data using custom getters that do not follow the "get_" prefix convention.

Problem:

Currently, the code forces any custom getter to follow the "get_" prefix format. If the provided getter name does not start with "get_", the code prepends "get_" to the getter name, which can lead to incorrect or failed data retrieval. This behavior is restrictive and does not account for the possibility of users defining or using getters that do not follow this naming convention.

Example Scenario:

If a custom getter named traceroute (without "get_" prefix) is passed to the task, the current logic will transform it to get_traceroute, causing the task to fail if this method does not exist.

Expected Behavior:

The code should not enforcing the "get_" prefix, or provide a clear option to bypass this transformation when needed.

Proposed Solution:

Modify the code to only use the getter name as provided. The logic could be simplified as:

getter = g

This means users must explicitly pass "get_interfaces", "get_bgp_neighbors", or any other standard getter prefixed with "get_", instead of relying on the function to automatically add it. This would provide clearer control and avoid conflicts.

For reference on standard NAPALM getters, see the Supported NAPALM Getters.

Steps to Reproduce:

  1. Use a custom getter name without a "get_" prefix.
  2. Run the task using nornir_napalm.
  3. Observe the failure or incorrect getter name being used.

Environment:

  • nornir_napalm version: 0.5.0
  • Python version: 3.12.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions