Skip to content

SROS: Migrate gNMI collection from nokia.grpc to nokia.openconfig - #4017

Open
andywhitaker wants to merge 1 commit into
ipspace:devfrom
andywhitaker:sros-ansible-gnmi-fix
Open

andywhitaker wants to merge 1 commit into
ipspace:devfrom
andywhitaker:sros-ansible-gnmi-fix

Conversation

@andywhitaker

@andywhitaker andywhitaker commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Nokia has archived nokia/ansible-networking-collections (nokia.grpc) and replaced it with nokia-steward/openconfig-ansible-integration, published on Ansible Galaxy as nokia.openconfig (>= 2.0.0, latest 2.0.2).

The legacy nokia.grpc collection shipped pre-compiled protobuf 3.x descriptors (gnmi_pb2.py) that failed on protobuf >= 4.21.0 (TypeError: Descriptors cannot be created directly), forcing netlab install grpc to clone from GitHub, pin protobuf==3.20.1 (breaking modern Python environments), and apply an ansible>=9.5.1 workaround. nokia.openconfig 2.0.x ships directly on Ansible Galaxy, supports ansible-core >= 2.18.0 (2.0.2+), and works cleanly with modern protobuf (3.20 through 7.x) and grpcio releases.

Changes

  • netsim/install/grpc.sh & netsim/install/install.yml:
    • Remove the legacy git+ install URL, protobuf==3.20.1 version lock, and obsolete ansible>=9.5.1 workaround.
    • Install grpcio + protobuf via python3 -m pip and nokia.srlinux + nokia.openconfig directly from Ansible Galaxy (ansible-galaxy collection install --upgrade nokia.srlinux nokia.openconfig).
  • netsim/devices/sros.py & netsim/devices/srsim.py:
    • Check for nokia.openconfig (version='2.0.0', install='netlab install grpc') in check_config_sw.
  • netsim/ansible/tasks/{deploy-config,fetch-config,readiness-check}/{sros,srsim}*.yml:
    • Switch ansible_connection to nokia.openconfig.grpc and modules to nokia.openconfig.gnmi_set, nokia.openconfig.gnmi_get, and nokia.openconfig.gnmi_capabilities.
    • Verify initial gNMI readiness with nokia.openconfig.gnmi_capabilities (with retries) and guard result is succeeded in srsim.yml port readiness polling.
    • Guard empty/comment-only gNMI templates, null delete/updates/replace sections, and empty/null netlab_srsim_hw, while preserving explicit empty-string origin: "" (origin: "{{ cfg.get('origin') if cfg.get('origin') is not none else omit }}").
    • Set ansible_gnmi_encoding: JSON in fetch-config/sros.yml so SR OS configuration backups read /configure in JSON format.
  • SR OS & SR-SIM gNMI Jinja2 templates (netsim/ansible/templates/**, netsim/extra/**/sros.j2, srsim-hardware.j2, docs/dev/config/srv6.md):
    • Update gNMI update/replace entries from val: to value: to match nokia.openconfig.gnmi_set 2.0.
  • docs/caveats.md & docs/netlab/install.md:
    • Update SR OS caveats and netlab install documentation for nokia.openconfig >= 2.0.0.

Testing

  • Passed mypy -p netsim, ruff check netsim/, yamllint --no-warnings, pytest (305 passed), and check-integration-tests.sh.
  • Verified live against Nokia SR-SIM (25.7.R1) in Containerlab with official Ansible Galaxy nokia.openconfig:2.0.2 (Python 3.12, ansible-core 2.18.19, grpcio 1.85.1, protobuf 7.36.2), covering netlab up, netlab validate, empty/null/explicit-origin netlab config edge cases, netlab collect (normal and --check), and netlab down --cleanup, plus full 128-scenario SR-SIM integration verification.

@ipspace

ipspace commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks a million for your efforts, but this is a total mess (has been for quite a while), and I don't think it's a good idea to hot-patch third-party software just because they can't get it right.

Unfortunately, someone wanted to "showcase the bleeding edge possibilities," and I was too naive at that time to say "NO WAY", so we are where we are. Let's check how hard it would be to switch to NETCONF.

@ipspace

ipspace commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Looks like it could be possible to use existing data structures with NETCONF: #4019

Let me try to make that work; that would be much cleaner, as it relies on rock-solid libraries like ncclient. How much of a rush are we in (as in: is the ansible-galaxy installation of the gRPC collection already broken)?

@andywhitaker

andywhitaker commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

That sounds good. I'm going to dig into options as well. There's no rush and you're right waiting to get a cleaner solution is a better option. I mainly wanted to fix the old version pinning issue but getting it all clean is better.

NETCONF could be a solid path. Otherwise, gNMI could work if we can get a properly maintained version in Ansible Galaxy AND an install / usage procedure that keeps the dependency versions aligned.... Nokia pre-compiling the protobufs and shipping to Ansible Galaxy is probably not the right path. Compiling them locally on the user's machine might work though

@ipspace

ipspace commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Otherwise, gNMI could work if we can get a properly maintained version in Ansible Galaxy AND an install / usage procedure that keeps the dependency versions aligned

Let's just say that the history of that collection doesn't make me an optimist 🤷🏻‍♂️

@andywhitaker

andywhitaker commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

If moving away from Ansible is an option, what do you think about just using pygnmi? It should ship with all the precompiled protobufs so would solve the version pinning issues and avoid the complexity of converting to XML for NETCONF since it should be able to use the existing templates.

The plus I see with gNMI is just the config structure is easier and more native. That's literally the only reason I care to suggest staying on it. If only NETCONF wasn't using XML... :)

@andywhitaker

Copy link
Copy Markdown
Collaborator Author

Let's just say that the history of that collection doesn't make me an optimist 🤷🏻‍♂️

Totally understand! FYI, I found and tested an upstream fix for this version-pinning issue which should make this work now and in the future without those same version issues protoc was causing. I sent an internal message. I will try to figure out what our go-forward plans are for these libraries and let you know what I find out. Not sure it's the most attractive option but staying put could end up being an option. I'll keep you posted.

@ipspace

ipspace commented Nov 2, 2026

Copy link
Copy Markdown
Owner

If moving away from Ansible is an option, what do you think about just using pygnmi?

Yet another dependency? At least with NETCONF, we could use the same method to configure multiple devices (SR OS and Junos).

The plus I see with gNMI is just the config structure is easier and more native. That's literally the only reason I care to suggest staying on it. If only NETCONF wasn't using XML... :)

I would use the same config structure in the templates and just convert it to XML internally. Wouldn't even think about writing XML templates -- I had enough XSLT ages ago.

@andywhitaker

Copy link
Copy Markdown
Collaborator Author

The new collection going forward is nokia.openconfig. As you saw, I tried to work around some issues with it in my first approach which was not ideal. I've now reached out to the maintainer and the upstream is getting fixed. It's already much better but the maintainer and I are working on a few more updates. I'll keep this PR since the title is accurate and will let you know when I feel like it's dialed in. At that point hopefully you'll get what you want out of it without the extra layers of converting the models but totally understand if you end up wanting to own your own destiny instead given the previous experience you had. Either way I'll touch base this week with another update and a working and sane version :)

@andywhitaker
andywhitaker force-pushed the sros-ansible-gnmi-fix branch from c6e0b53 to 92bcd2e Compare November 5, 2026 07:46
@ipspace

ipspace commented Nov 5, 2026

Copy link
Copy Markdown
Owner

I've now reached out to the maintainer and the upstream is getting fixed. It's already much better but the maintainer and I are working on a few more updates.

Thanks a million for the update. I'll push out the 26.11 release in second half of November, if this is ready by then, we'll make the switch, otherwise it will be in the next release.

but totally understand if you end up wanting to own your own destiny instead given the previous experience you had.

No worries. I'm all for having a documented backup plan without creating extra work for myself ;))

@andywhitaker
andywhitaker force-pushed the sros-ansible-gnmi-fix branch from 92bcd2e to 7a60ba7 Compare November 5, 2026 18:17
- Replace archived nokia.grpc with official Ansible Galaxy
  nokia.openconfig (>= 2.0.0) in netsim/install/grpc.sh, install.yml,
  sros.py, and srsim.py, removing the legacy git+ clone, protobuf==3.20.1
  pin, and ansible>=9.5.1 workaround.
- Migrate SR OS / SR-SIM deploy-config, fetch-config, and readiness-check
  tasks to nokia.openconfig.grpc, gnmi_set, gnmi_get, and
  gnmi_capabilities, preserving empty-string origin and guarding empty or
  null gNMI YAML sections and netlab_srsim_hw.
- Update SR OS and SR-SIM gNMI Jinja2 templates and developer docs from
  'val' to 'value' to match nokia.openconfig.gnmi_set 2.0.
@andywhitaker
andywhitaker force-pushed the sros-ansible-gnmi-fix branch from 7a60ba7 to c6059c5 Compare November 5, 2026 19:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants