Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- json-1 = {
- "channel": "scanner",
- "action": "create_device",
- "table": "U2",
- "device":[]
- }
- data = "device_name","ip_address","lldp_neighbors"
- my[data[0]] = connection.find_prompt().rstrip('>') #to get hostname
- my[data[1]] = device['ip'] #to get ip address
- my[data[2]] = connection.send_command('show lldp neighbors | display xml')
- #to get lldp data in xml format
- json1["device"].append(my) #append my data to device
- "lldp_neighbors": [
- {
- "local-port": "xe-3/0/4.0",
- "parent-interface": "ae31.0",
- "chassis-id": "b0:c6:9a:63:80:40",
- "port-info": "xe-0/0/0/0.0",
- "system-name": "host.jnpr.net"
- {
- "channel": "scanner",
- "action": "create_device",
- "table": "U2",
- "device": [
- {
- "device_name": "rtr1.wer",
- "ip_address": "1.1.1.1",
- "lldp_neighbors": [
- {
- "local-port": "xe-3/0/4.0",
- "parent-interface": "ae31.0",
- "chassis-id": "b0:c6:9a:63:80:40",
- "port-info": "xe-0/0/0/0.0",
- "system-name": "host.jnpr.net"
- }
- ]
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement