Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR-119] Fix SNMP support in connection-manager UniConfig workers #62

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions uniconfig/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@
- Fix connection-manager and discovery workers.
- Connection-manager - Pydantic cannot correctly handle combination of aliases and unions.
- Discovery - Fixed renamed elements.

# 3.0.2
- Fix missing SNMP support in connection-manager UniConfig workers.
16 changes: 12 additions & 4 deletions uniconfig/python/frinx_worker/uniconfig/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class InstallNode(WorkerImpl):
from frinx_api.uniconfig.connection.manager.installnode import Cli
from frinx_api.uniconfig.connection.manager.installnode import Gnmi
from frinx_api.uniconfig.connection.manager.installnode import Netconf
from frinx_api.uniconfig.connection.manager.installnode import Snmp
from frinx_api.uniconfig.rest_api import InstallNode as UniconfigApi

class ExecutionProperties(TaskExecutionProperties):
Expand All @@ -37,7 +38,7 @@ class WorkerDefinition(TaskDefinition):

class WorkerInput(TaskInput):
node_id: str
connection_type: Literal["netconf", "cli", "gnmi"]
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
install_params: DictAny
uniconfig_url_base: str = UNICONFIG_URL_BASE
# todo: remove this flag after low-quality Pydantic code is fixed
Expand Down Expand Up @@ -65,6 +66,9 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
gnmi=self.Gnmi(**worker_input.install_params)
if worker_input.connection_type == "gnmi"
else None,
snmp=self.Snmp(**worker_input.install_params)
if worker_input.connection_type == "snmp"
else None,
),
),
)
Expand All @@ -80,6 +84,8 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
data["input"]["netconf"] = worker_input.install_params
elif worker_input.connection_type == "gnmi":
data["input"]["gnmi"] = worker_input.install_params
elif worker_input.connection_type == "snmp":
data["input"]["snmp"] = worker_input.install_params
import json
data = json.dumps(data)

Expand Down Expand Up @@ -108,7 +114,7 @@ class WorkerDefinition(TaskDefinition):

class WorkerInput(TaskInput):
node_id: str
connection_type: Literal["netconf", "cli", "gnmi"]
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
uniconfig_url_base: str = UNICONFIG_URL_BASE

class WorkerOutput(TaskOutput):
Expand Down Expand Up @@ -313,7 +319,7 @@ class WorkerInput(TaskInput):
"""
Identifier of the node in the UniConfig network topology.
"""
connection_type: Literal["netconf", "cli", "gnmi"]
connection_type: Literal["netconf", "cli", "gnmi", "snmp"]
"""
Type of connection to the device.
"""
Expand Down Expand Up @@ -357,11 +363,13 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]:
return handle_response(response, self.WorkerOutput)

@staticmethod
def _derive_topology_id(connection_type: Literal["netconf", "cli", "gnmi"]) -> str:
def _derive_topology_id(connection_type: Literal["netconf", "cli", "gnmi", "snmp"]) -> str:
if connection_type == "netconf":
return "topology-netconf"
if connection_type == "cli":
return "cli"
if connection_type == "gnmi":
return "gnmi-topology"
if connection_type == "snmp":
return "topology-snmp"
raise ValueError(f"Unknown connection type {connection_type}")
Loading
Loading