better error handling and log messages in network_cli (#20204)
This commit is contained in:
parent
3f949358c7
commit
fec773a2b4
1 changed files with 13 additions and 5 deletions
|
@ -72,16 +72,24 @@ class Connection(_Connection):
|
||||||
network_os = self._play_context.network_os
|
network_os = self._play_context.network_os
|
||||||
if not network_os:
|
if not network_os:
|
||||||
for cls in terminal_loader.all(class_only=True):
|
for cls in terminal_loader.all(class_only=True):
|
||||||
network_os = cls.guess_network_os(self.ssh)
|
try:
|
||||||
if network_os:
|
network_os = cls.guess_network_os(self.ssh)
|
||||||
break
|
if network_os:
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
raise AnsibleConnectionFailure(
|
||||||
|
'Unable to automatically determine host network os. '
|
||||||
|
'Please manually configure ansible_network_os value '
|
||||||
|
'for this host'
|
||||||
|
)
|
||||||
|
|
||||||
if not network_os:
|
if not network_os:
|
||||||
raise AnsibleConnectionFailure(
|
raise AnsibleConnectionFailure(
|
||||||
'unable to determine device network os. Please configure '
|
'Unable to automatically determine host network os. Please '
|
||||||
'ansible_network_os value'
|
'manually configure ansible_network_os value for this host'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
self._terminal = terminal_loader.get(network_os, self)
|
self._terminal = terminal_loader.get(network_os, self)
|
||||||
if not self._terminal:
|
if not self._terminal:
|
||||||
raise AnsibleConnectionFailure('network os %s is not supported' % network_os)
|
raise AnsibleConnectionFailure('network os %s is not supported' % network_os)
|
||||||
|
|
Loading…
Reference in a new issue