You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to utilize network-engine's command_parser to extract key facts, such as network device version number, from the device.
Because different versions of NXOS and IOS seem to present the data in a slightly different way, I was hoping to use a regex branch reset group to apply 'OR' logic to match the different variants of how the data is displayed to the same regex group.
STEPS TO REPRODUCE
To reproduce, attempt to use a branch reset group under 'regex' within pattern_match.
The above should match either 'doggies' or 'Cisco Nexus Operating' to regex group 1. This works fine on online Regex editors, but throws an error when I try this through command_parser.
TASK [Parsing command data into JSON format: show version] *********************
task path: /var/lib/awx/projects/_69__network_data_collection/data-discovery/show-nxos.yml:30
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 140, in run
res = self._execute()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 612, in _execute
result = self._handler.run(task_vars=variables)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/command_parser.py", line 187, in run
res = self._process_directive(task)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/command_parser.py", line 391, in _process_directive
return meth(**args)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/command_parser.py", line 406, in do_pattern_match
return parser.match(regex, match_all, match_until, match_greedy)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/../lib/network_engine/plugins/parser/pattern_match.py", line 39, in match
return self._match_all(content, regex)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/../lib/network_engine/plugins/parser/pattern_match.py", line 44, in _match_all
match = self.re_matchall(pattern, content)
File "/var/lib/awx/projects/_69__network_data_collection/data-discovery/roles/ansible-network.network-engine/action_plugins/../lib/network_engine/plugins/parser/pattern_match.py", line 153, in re_matchall
regex = re.compile(regex)
File "/usr/lib64/python2.7/re.py", line 190, in compile
return _compile(pattern, flags)
File "/usr/lib64/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
error: unexpected end of pattern
fatal: [S022DC3N5212]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}
The text was updated successfully, but these errors were encountered:
Python re doesn't support branch reset which command_parser uses.
3rd party PyPi regex module supports a branch reset feature.
Hence command_parser is failing.
Please file a bug report if you face issue further. Thanks!
ISSUE TYPE
ANSIBLE VERSION
Network OS
SUMMARY
I am attempting to utilize network-engine's command_parser to extract key facts, such as network device version number, from the device.
Because different versions of NXOS and IOS seem to present the data in a slightly different way, I was hoping to use a regex branch reset group to apply 'OR' logic to match the different variants of how the data is displayed to the same regex group.
STEPS TO REPRODUCE
To reproduce, attempt to use a branch reset group under 'regex' within pattern_match.
EXPECTED RESULTS
The above should match either 'doggies' or 'Cisco Nexus Operating' to regex group 1. This works fine on online Regex editors, but throws an error when I try this through command_parser.
regex101.com: Link to expected result example
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: