Closed hisaza closed 5 years ago
Could also use :
regex: "Hardware is ([^,]+),"
This could show another way working with python re.
For the same result it's possible to use
regex: "Hardware is (.*),"
Unfortunately I haven't figured out a way to show the loopback device type.
For a loopback device the hardware line doesn't end with a comma. There is a newline right after the device type:
Loopback2 is up, line protocol is up \n Hardware is Loopback\n Description:
Hi @joubbi,
for capturing both case, you can use non-greedy expression and use | to add multiple ending:
regex: "Hardware is (.*?)(?:,|\\\n)"
Thank you @kvernNC ! I still have a lot to learn about regex ;-) I updated my version https://github.com/joubbi/command_parser_show_interfaces
ISSUE TYPE
ANSIBLE VERSION
Network OS
SUMMARY
STEPS TO REPRODUCE
In this path: https://github.com/ansible-network/network-engine/blob/devel/tests/command_parser/command_parser/parser_templates/ios/show_interfaces.yaml
There is a minor bug that has a comma next to the regex key, that will not display the captured data.
EXPECTED RESULTS
ok: [csr1] => { "interface": { "ansible_facts": { "interface_facts": [ { "GigabitEthernet1": { "config": { "description": null, "mtu": "1500", "name": "GigabitEthernet1", "type": "CSR" <----- Expect to see the type value to be populated } } },
ACTUAL RESULTS
ok: [csr1] => { "interface": { "ansible_facts": { "interface_facts": [ { "GigabitEthernet1": { "config": { "description": null, "mtu": "1500", "name": "GigabitEthernet1", "type": null <--------- Comes back as null } } },