Skip to content

Commit

Permalink
Allow increasing of napalm timeout (for slow firewall clusters)
Browse files Browse the repository at this point in the history
  • Loading branch information
indy-independence committed Oct 31, 2024
1 parent 052977d commit 41385b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Defines parameters for the API:
specified in seconds. Defaults to 300.
- commit_confirmed_wait: Time to wait between comitting configuration and checking
that the device is still reachable, specified in seconds. Defaults to 1.
- napalm_timeout: Timeout for NAPALM operations, specified in seconds. Defaults to 60.
Increase if you get errors like "jnpr.junos.exception.RpcTimeoutError: RpcTimeoutError" on jobs.

/etc/cnaas-nms/auth_config.yml
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/cnaas_nms/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ApiSettings(BaseSettings):
COMMIT_CONFIRMED_TIMEOUT: int = 300
COMMIT_CONFIRMED_WAIT: int = 1
SETTINGS_OVERRIDE: Optional[dict] = None
NAPALM_TIMEOUT: int = 60

@field_validator("MGMTDOMAIN_PRIMARY_IP_VERSION")
@classmethod
Expand Down Expand Up @@ -118,6 +119,7 @@ def construct_api_settings() -> ApiSettings:
COMMIT_CONFIRMED_TIMEOUT=config.get("commit_confirmed_timeout", 300),
COMMIT_CONFIRMED_WAIT=config.get("commit_confirmed_wait", 1),
SETTINGS_OVERRIDE=config.get("settings_override", None),
NAPALM_TIMEOUT=config.get("napalm_timeout", 60),
)
else:
return ApiSettings()
Expand Down
5 changes: 3 additions & 2 deletions src/cnaas_nms/devicehandler/nornir_plugins/cnaas_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from nornir.core.inventory import ConnectionOptions, Defaults, Group, Groups, Host, Hosts, Inventory, ParentGroups

import cnaas_nms.db.session
from cnaas_nms.app_settings import app_settings
from cnaas_nms.app_settings import api_settings, app_settings
from cnaas_nms.db.device import Device, DeviceState, DeviceType
from cnaas_nms.db.settings import get_groups
from cnaas_nms.tools.pki import ssl_context
Expand Down Expand Up @@ -41,11 +41,12 @@ def load(self) -> Inventory:
connection_options={
"napalm": ConnectionOptions(
extras={
"timeout": api_settings.NAPALM_TIMEOUT,
"optional_args": {
# args to eAPI HttpsEapiConnection for EOS
"enforce_verification": True,
"context": ssl_context,
}
},
}
),
"netmiko": ConnectionOptions(extras={}),
Expand Down

0 comments on commit 41385b4

Please sign in to comment.