Python library to convert network outputs to structured JSON data.
Create a virtual env
python3.6 -m venv .venv
source .venv/bin/activate
pip install https://github.com/bobthebutcher/inquisitor/archive/master.zip
Leverage NetworkToCode TextFSM template repository ntc-tempaltes
git clone https://github.com/networktocode/ntc-templates.git
from inquisitor.constants import CISCO_IOS_TEMPLATE_MAP
from inquisitor.api import data_dict
from inquisitor.utils import jprint
vrf_data = '''
Name Default RD Protocols Interfaces
MGMT <not set> ipv4 Gi0/0
test-vrf 65000:100 ipv4 Gi0/1
'''
vrfs = data_dict(template=CISCO_IOS_TEMPLATE_MAP['vrfs'], data_type='vrfs', raw_data=vrf_data)
jprint(vrfs)
{
"vrfs": [
{
"name": "MGMT",
"default_rd": "<not set>",
"protocols": "ipv4",
"interfaces": [
"Gi0/0"
]
},
{
"name": "test-vrf",
"default_rd": "65000:100",
"protocols": "ipv4",
"interfaces": [
"Gi0/1"
]
}
]
}