Merge pull request #62924 from garethgreenaway/61542_remove_napalm_base_references

Removing all references to napalm-base which is no longer supported.
This commit is contained in:
Gareth J. Greenaway 2022-10-21 12:22:49 -07:00 committed by GitHub
commit 4206994aad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 15 deletions

View file

@ -0,0 +1 @@
Removing all references to napalm-base which is no longer supported.

View file

@ -30,7 +30,6 @@ try:
# https://github.com/napalm-automation/napalm
# pylint: disable=unused-import,no-name-in-module
import napalm
import napalm.base as napalm_base
# pylint: enable=unused-import,no-name-in-module
HAS_NAPALM = True
@ -315,16 +314,8 @@ def get_device(opts, salt_obj=None):
"""
log.debug("Setting up NAPALM connection")
network_device = get_device_opts(opts, salt_obj=salt_obj)
provider_lib = napalm_base
provider_lib = napalm.base
if network_device.get("PROVIDER"):
# In case the user requires a different provider library,
# other than napalm-base.
# For example, if napalm-base does not satisfy the requirements
# and needs to be enahanced with more specific features,
# we may need to define a custom library on top of napalm-base
# with the constraint that it still needs to provide the
# `get_network_driver` function. However, even this can be
# extended later, if really needed.
# Configuration example:
# provider: napalm_base_example
try:
@ -333,7 +324,6 @@ def get_device(opts, salt_obj=None):
log.error(
"Unable to import %s", network_device.get("PROVIDER"), exc_info=True
)
log.error("Falling back to napalm-base")
_driver_ = provider_lib.get_network_driver(network_device.get("DRIVER_NAME"))
try:
network_device["DRIVER"] = _driver_(
@ -346,7 +336,7 @@ def get_device(opts, salt_obj=None):
network_device.get("DRIVER").open()
# no exception raised here, means connection established
network_device["UP"] = True
except napalm_base.exceptions.ConnectionException as error:
except napalm.base.exceptions.ConnectionException as error:
base_err_msg = "Cannot connect to {hostname}{port} as {username}.".format(
hostname=network_device.get("HOSTNAME", "[unspecified hostname]"),
port=(
@ -360,7 +350,7 @@ def get_device(opts, salt_obj=None):
)
log.error(base_err_msg)
log.error("Please check error: %s", error)
raise napalm_base.exceptions.ConnectionException(base_err_msg)
raise napalm.base.exceptions.ConnectionException(base_err_msg)
return network_device
@ -420,7 +410,7 @@ def proxy_napalm_wrap(func):
# in order to make sure we are editing the same session.
try:
wrapped_global_namespace["napalm_device"] = get_device(opts)
except napalm_base.exceptions.ConnectionException as nce:
except napalm.base.exceptions.ConnectionException as nce:
log.error(nce)
return "{base_msg}. See log for details.".format(
base_msg=str(nce.msg)
@ -490,7 +480,7 @@ def proxy_napalm_wrap(func):
wrapped_global_namespace["napalm_device"] = get_device(
opts, salt_obj=_salt_obj
)
except napalm_base.exceptions.ConnectionException as nce:
except napalm.base.exceptions.ConnectionException as nce:
log.error(nce)
return "{base_msg}. See log for details.".format(
base_msg=str(nce.msg)