network-engine icon indicating copy to clipboard operation
network-engine copied to clipboard

How to handle minor variations (is it possible to do "if")?

Open joubbi opened this issue 5 years ago • 0 comments

  • Documentation Report

I am creating templates for some Cisco IOS devices. Unfortunately Cisco is not consistent with the output on some of their commands across IOS versions and devices.

For example the command "show vtp status" outputs:

VTP version running             : 2

on some switches. And this on others:

VTP Version                     : 2

Is it possible to handle this with an if statement or or? (regexp like this, if null then regexp like this instead). Or something similar to this:

pattern_match:
    regex: "VTP Version capable             : (.*)" | "VTP Version                     : (.*)"

Also the amounts of whitespace between names and variables differ on different devices:

Number of existing VLANs          : 34
Number of existing VLANs        : 8

I haven't found any examples or documentation on how to handle these situations.

EDIT: I solved this particular problem with this regex:

regex: "VTP \\Sersion [r|\\s][u|\\s][n|\\s][n|\\s][i|\\s][n|\\s][g|\\s]             : (.*)"

Still I would like to know if there is a possibility to do an if statement. Also more documentation would be very helpful.

joubbi avatar May 13 '19 13:05 joubbi