I'm having difficulty with a show license summary template for cisco. It's close, but not quite, and this is my first template so any help is appreciated.
The CLI output is
Smart Licensing is ENABLED
Registration:
Status: REGISTERED
Smart Account: My Company
Virtual Account: myVa
Export-Controlled Functionality: ALLOWED
Last Renewal Attempt: None
Next Renewal Attempt: Feb 19 19:29:14 2024 CDT
License Authorization:
Status: OUT OF COMPLIANCE
Last Communication Attempt: SUCCEEDED
Next Communication Attempt: Aug 24 07:29:17 2023 CDT
License Usage:
License Entitlement tag Count Status
-----------------------------------------------------------------------------
C9500 Network Advantage (C9500 Network Advantage) 2 AUTHORIZED
C9500 48Y4C DNA Adva... (C9500 48Y4C DNA Advantage) 2 OUT OF COMPLIANCE
My template is
Value Filldown SMART_LICENSE_STATE (.*)
Value Filldown REG_STATUS (\S+)
Value Filldown VIRTUAL_ACCOUNT (.*)
Value LICENSE_AUTH_STATUS (.*)
Value Filldown LAST_COMM_STATUS (.*)
Value LICENSE_TYPE (.*)
Value LICENSE_COUNT (\d+)
Value LICENSE_STATUS (.*)
Value LICENSE_TAG (.*)
Start
^Smart Licensing is ${SMART_LICENSE_STATE}
^\s+Status:\s+${REG_STATUS}$$
^\s+Virtual\s+Account:\s+${VIRTUAL_ACCOUNT}
^\s+Status:\s+${LICENSE_AUTH_STATUS}$$
^.*\s+Last Communication Attempt:\s+${LAST_COMM_STATUS}$$
^\s-+ -> Continue
^\s+${LICENSE_TYPE}.*\(${LICENSE_TAG}\).*${LICENSE_COUNT}\s+${LICENSE_STATUS} -> Record
The output though, outputs a 3rd item for some reason.
[
{
"LAST_COMM_STATUS": "SUCCEEDED",
"LICENSE_AUTH_STATUS": "OUT OF COMPLIANCE",
"LICENSE_COUNT": "2",
"LICENSE_STATUS": "AUTHORIZED ",
"LICENSE_TAG": "C9500 Network Advantage",
"LICENSE_TYPE": "C9500 Network Advantage ",
"REG_STATUS": "REGISTERED",
"SMART_LICENSE_STATE": "ENABLED",
"VIRTUAL_ACCOUNT": "myVa"
},
{
"LAST_COMM_STATUS": "SUCCEEDED",
"LICENSE_AUTH_STATUS": "",
"LICENSE_COUNT": "2",
"LICENSE_STATUS": "OUT OF COMPLIANCE ",
"LICENSE_TAG": "C9500 48Y4C DNA Advantage",
"LICENSE_TYPE": "C9500 48Y4C DNA Adva... ",
"REG_STATUS": "REGISTERED",
"SMART_LICENSE_STATE": "ENABLED",
"VIRTUAL_ACCOUNT": "myVa"
},
{
"LAST_COMM_STATUS": "SUCCEEDED",
"LICENSE_AUTH_STATUS": "",
"LICENSE_COUNT": "",
"LICENSE_STATUS": "",
"LICENSE_TAG": "",
"LICENSE_TYPE": "",
"REG_STATUS": "REGISTERED",
"SMART_LICENSE_STATE": "ENABLED",
"VIRTUAL_ACCOUNT": "myVa"
}
]
I've tried a few different things, like using a list for LICENSE to create an array, but I get illegal or duplicate variable.
This is caused by the Filldown
values. The CLI output likely has a newline at the end, so a new line is started, filldown values are added to the output list, and the other values are left empty because they cannot be matched.
A quick workaround is to identify a value that is always present in the output and make that Required
. Then when there is no match for this value the empty line is discarded.
For example:
Value Filldown SMART_LICENSE_STATE (.*)
Value Filldown REG_STATUS (\S+)
Value Filldown VIRTUAL_ACCOUNT (.*)
Value LICENSE_AUTH_STATUS (.*)
Value Filldown LAST_COMM_STATUS (.*)
Value Required LICENSE_TYPE (.*)
Value LICENSE_COUNT (\d+)
Value LICENSE_STATUS (.*)
Value LICENSE_TAG (.*)