Skip to content

Commit 2bba67f

Browse files
Jaroslav Tóthmpastorek
authored andcommitted
FR-119 Fix SNMP support in connection-manager UniConfig workers
1 parent 5c6a2d6 commit 2bba67f

File tree

4 files changed

+457
-320
lines changed

4 files changed

+457
-320
lines changed

uniconfig/python/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@
6464
- Fix connection-manager and discovery workers.
6565
- Connection-manager - Pydantic cannot correctly handle combination of aliases and unions.
6666
- Discovery - Fixed renamed elements.
67+
68+
# 3.0.2
69+
- Fix missing SNMP support in connection-manager UniConfig workers.

uniconfig/python/frinx_worker/uniconfig/connection_manager.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class InstallNode(WorkerImpl):
2525
from frinx_api.uniconfig.connection.manager.installnode import Cli
2626
from frinx_api.uniconfig.connection.manager.installnode import Gnmi
2727
from frinx_api.uniconfig.connection.manager.installnode import Netconf
28+
from frinx_api.uniconfig.connection.manager.installnode import Snmp
2829
from frinx_api.uniconfig.rest_api import InstallNode as UniconfigApi
2930

3031
class ExecutionProperties(TaskExecutionProperties):
@@ -37,7 +38,7 @@ class WorkerDefinition(TaskDefinition):
3738

3839
class WorkerInput(TaskInput):
3940
node_id: str
40-
connection_type: Literal["netconf", "cli", "gnmi"]
41+
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
4142
install_params: DictAny
4243
uniconfig_url_base: str = UNICONFIG_URL_BASE
4344
# todo: remove this flag after low-quality Pydantic code is fixed
@@ -65,6 +66,9 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
6566
gnmi=self.Gnmi(**worker_input.install_params)
6667
if worker_input.connection_type == "gnmi"
6768
else None,
69+
snmp=self.Snmp(**worker_input.install_params)
70+
if worker_input.connection_type == "snmp"
71+
else None,
6872
),
6973
),
7074
)
@@ -80,6 +84,8 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
8084
data["input"]["netconf"] = worker_input.install_params
8185
elif worker_input.connection_type == "gnmi":
8286
data["input"]["gnmi"] = worker_input.install_params
87+
elif worker_input.connection_type == "snmp":
88+
data["input"]["snmp"] = worker_input.install_params
8389
import json
8490
data = json.dumps(data)
8591

@@ -108,7 +114,7 @@ class WorkerDefinition(TaskDefinition):
108114

109115
class WorkerInput(TaskInput):
110116
node_id: str
111-
connection_type: Literal["netconf", "cli", "gnmi"]
117+
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
112118
uniconfig_url_base: str = UNICONFIG_URL_BASE
113119

114120
class WorkerOutput(TaskOutput):
@@ -313,7 +319,7 @@ class WorkerInput(TaskInput):
313319
"""
314320
Identifier of the node in the UniConfig network topology.
315321
"""
316-
connection_type: Literal["netconf", "cli", "gnmi"]
322+
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
317323
"""
318324
Type of connection to the device.
319325
"""
@@ -357,11 +363,13 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
357363
return handle_response(response, self.WorkerOutput)
358364

359365
@staticmethod
360-
def _derive_topology_id(connection_type: Literal["netconf", "cli", "gnmi"]) -> str:
366+
def _derive_topology_id(connection_type: Literal["netconf", "cli", "gnmi", "snmp"]) -> str:
361367
if connection_type == "netconf":
362368
return "topology-netconf"
363369
if connection_type == "cli":
364370
return "cli"
365371
if connection_type == "gnmi":
366372
return "gnmi-topology"
373+
if connection_type == "snmp":
374+
return "topology-snmp"
367375
raise ValueError(f"Unknown connection type {connection_type}")

0 commit comments

Comments
 (0)