New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cisco_nxos_show_interface_transciever parsing issue #1534
Comments
I have replicated the steps you describe and everything appears to be working correctly with the parsing to me. The transceiver data that you are getting back from sbx-nxos-mgmt.cisco.com is empty ("transciever is not applicable"). When the cisco_nxos_show_interface_transciever parser is applied to the output stored in your variable called "transcievers" it returns an empty list, which is correct as there is no actual transciever data in the output. If you look at the second line after the Start state (^\s+transceiver is not -> Clear) this line is accounting for the potential situation where the transceiver state for a particular interface begins with is "transceiver is not" (as the output in your transcivers variable does) and clears any previously captured parsing data, moves onto parsing the next line, and does not record any values for that particular line of output, as it does not contain any applicable transciever data. In short, this does not appear to be a bug with the parsing template but is the intended result for the command_output ("transciver" variable data) that you are feeding into it |
Hi @collin-wicker, thanks for you explanation. I get your point regarding the issue. But, I want to mention that when I use the NX-API feature (with the below code), I can successfully get the parsed output.
I know that # Imports
import csv
from datetime import date
from getpass import getpass
from pprint import pprint
import requests
import urllib3
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)
# Inputs
host = input("Host [sbx-nxos-mgmt.cisco.com]: ") or "sbx-nxos-mgmt.cisco.com"
usr = input("Username [admin]: ") or "admin"
pwd = getpass("Password: ") or "Admin_1234!"
data = {
"ins_api": {
"version": "1.0",
"type": "cli_show",
"chunk": "0",
"sid": "1",
"input": "show interface transceiver", # the command
"output_format": "json", # or xml
}
}
sess = requests.Session()
try:
print(f"Trying {host}...", end="\r")
# POST: Request
r = sess.post(
url=f"https://{host}:443/ins", auth=(usr, pwd), json=data, verify=False
)
r.raise_for_status()
except requests.HTTPError as e:
raise SystemExit(e) from e
else:
print(f"Connected to {host} successfully")
interfaces = (
r.json()
.get("ins_api")
.get("outputs")
.get("output")
.get("body")
.get("TABLE_interface")
.get("ROW_interface")
)
pprint(interfaces)
# Create CSV file
with open(
file=f"{host}-transceivers_{date.today()}.csv", mode="wt", newline=""
) as csvfile:
csvwriter = csv.DictWriter(csvfile, fieldnames=["interface", "sfp"])
csvwriter.writerows(interfaces)
print(f"Created {csvfile.name} file successfully") PPrint output [{'interface': 'Ethernet1/1', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/2', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/3', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/4', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/5', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/6', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/7', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/8', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/9', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/10', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/11', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/12', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/13', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/14', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/15', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/16', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/17', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/18', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/19', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/20', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/21', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/22', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/23', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/24', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/25', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/26', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/27', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/28', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/29', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/30', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/31', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/32', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/33', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/34', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/35', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/36', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/37', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/38', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/39', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/40', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/41', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/42', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/43', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/44', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/45', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/46', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/47', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/48', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/49', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/50', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/51', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/52', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/53', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/54', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/55', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/56', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/57', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/58', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/59', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/60', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/61', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/62', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/63', 'sfp': 'not applicable'},
{'interface': 'Ethernet1/64', 'sfp': 'not applicable'}] |
@Tes3awy I see what you're saying regarding the above output you received from the NX-API. This seems like a logical way to parse the "show interface transceiver" command output and could certainly be achieved with NTC-Templates parser. I will defer to the repo maintainers on this. @jvanderaa, @itdependsnetworks, @jmcgill298 Do you all have an opinion as to the format of the data being returned from ntc-templates in this instance. It is currently returning an empty list due to the "transceiver is not applicable" line but @Tes3awy is suggesting it return something similar to the directly above output from the NX-API. |
Personally, I would expect an empty list. But I'm not really concerned either way |
I just submitted a pull request #1614 as I was facing another issue that did throw an error with the vendor ID. |
ISSUE TYPE
TEMPLATE USING
SAMPLE COMMAND OUTPUT
SUMMARY
Cannot parse Nexus 9000
show interface transciever
output.STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: