mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Raise error when trying to use older iosxr modules with netconf (#37423)
This commit is contained in:
parent
a6d31b6fb1
commit
85cc5ea129
2 changed files with 5 additions and 3 deletions
|
@ -42,12 +42,12 @@ class ActionModule(_ActionModule):
|
||||||
del tmp # tmp no longer has any effect
|
del tmp # tmp no longer has any effect
|
||||||
|
|
||||||
socket_path = None
|
socket_path = None
|
||||||
|
force_cli = self._task.action in ('iosxr_netconf', 'iosxr_config', 'iosxr_command', 'iosxr_facts')
|
||||||
|
|
||||||
if self._play_context.connection == 'local':
|
if self._play_context.connection == 'local':
|
||||||
provider = load_provider(iosxr_provider_spec, self._task.args)
|
provider = load_provider(iosxr_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
if self._task.action in ['iosxr_netconf', 'iosxr_config', 'iosxr_command'] or \
|
if force_cli or provider['transport'] == 'cli':
|
||||||
(provider['transport'] == 'cli'):
|
|
||||||
pc.connection = 'network_cli'
|
pc.connection = 'network_cli'
|
||||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||||
elif provider['transport'] == 'netconf':
|
elif provider['transport'] == 'netconf':
|
||||||
|
@ -75,6 +75,9 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
task_vars['ansible_socket'] = socket_path
|
task_vars['ansible_socket'] = socket_path
|
||||||
elif self._play_context.connection in ('netconf', 'network_cli'):
|
elif self._play_context.connection in ('netconf', 'network_cli'):
|
||||||
|
if force_cli and self._play_context.connection != 'network_cli':
|
||||||
|
return {'failed': True, 'msg': 'Connection type %s is not valid for module %s' %
|
||||||
|
(self._play_context.connection, self._task.action)}
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
|
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
|
||||||
|
|
|
@ -73,7 +73,6 @@ def transform_reply():
|
||||||
if sys.version < '3':
|
if sys.version < '3':
|
||||||
return reply
|
return reply
|
||||||
else:
|
else:
|
||||||
print("utf8")
|
|
||||||
return reply.encode('UTF-8')
|
return reply.encode('UTF-8')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue