fix: reject non-VPCS nodes in the VPCS config tool

VPCS syntax typed into another node's console is silently discarded
(IOS answers % Invalid input) while the tool still reports success.
get_device_ports_from_topology now carries the GNS3 node type through
to callers, and VPCSCommands fails device preparation with a per-device
error unless the node type is vpcs.
This commit is contained in:
YueGuobin committed 2026-08-26 00:36:47 +08:00
1 parent 8a8314ab29
commit 2951af6eab
4 files changed
+93

No files matched your search

@@ -59,6 +59,7 @@ def get_device_ports_from_topology(
"device_name": {
"port": console_port,
"platform": "huawei", # Extracted from tags
"node_type": "vpcs", # GNS3 node type from the topology
"groups": ["network_devices"], # For inheriting shared settings
"connection_options": {
"netmiko": {
@@ -160,9 +161,14 @@ def get_device_ports_from_topology(
# This is the Nornir best practice - each host has its own
# connection configuration (device_type), while sharing common
# settings (hostname, timeout) via group inheritance.
# node_type (the GNS3 node type, e.g. vpcs/iou/docker) lets callers
# reject mismatched devices before opening a console connection;
# DictInventory ignores keys it does not know, so carrying it here
# is safe for entries fed straight into Nornir.
host_entry = {
"port": node_info["console_port"],
"platform": platform,
"node_type": node_info.get("type"),
"groups": ["network_devices"], # For inheriting hostname, timeout, etc.
"connection_options": {
"netmiko": {