mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Move errors from import to connect (#50034)
This commit is contained in:
parent
d4ee599fe9
commit
bf4ad56479
2 changed files with 14 additions and 5 deletions
|
@ -138,10 +138,7 @@ try:
|
|||
from napalm.base import ModuleImportError
|
||||
HAS_NAPALM = True
|
||||
except ImportError:
|
||||
raise AnsibleError(
|
||||
'Napalm is required to use the napalm connection type.\n'
|
||||
'Please run pip install napalm'
|
||||
)
|
||||
HAS_NAPALM = False
|
||||
|
||||
display = Display()
|
||||
|
||||
|
@ -158,6 +155,11 @@ class Connection(NetworkConnectionBase):
|
|||
self.napalm = None
|
||||
|
||||
def _connect(self):
|
||||
if not HAS_NAPALM:
|
||||
raise AnsibleError(
|
||||
'Napalm is required to use the napalm connection type.\n'
|
||||
'Please run pip install napalm'
|
||||
)
|
||||
super(Connection, self)._connect()
|
||||
|
||||
if not self.connected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue