Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbyrnes committed Mar 18, 2024
1 parent fc7bb15 commit ee42593
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions lab-2/3_netmiko_update_description_to_lldp_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,44 @@
# Send a command to the router, and get back the output "dictionaried" by textfsm.
textfsm_output = connection.send_command(command_to_run, use_textfsm=True)

# We know that the output looks like this:
# OUTPUT HERE
# We know that textfsm_output looks something like this for a host:
# [
# {
# "local_interface": "GigabitEthernet0/0/0/0",
# "chassis_id": "0006.283d.5b1f",
# "neighbor_port_description": "-> CISCO3",
# "neighbor_port_id": "GigabitEthernet0/0/0/0",
# "neighbor": "cisco1",
# "system_description": "7.11.1, XRd Control Plane",
# "capabilities": "R",
# "management_ip": "172.17.1.18",
# "management_ipv6": "2001:db8:16:1::2",
# "mac_address": "aa:c1:ab:40:84:35"
# },
# {
# "local_interface": "GigabitEthernet0/0/0/1",
# "chassis_id": "0012.003b.94fe",
# "neighbor_port_description": "-> CISCO3",
# "neighbor_port_id": "GigabitEthernet0/0/0/0",
# "neighbor": "cisco2",
# "system_description": "7.11.1, XRd Control Plane",
# "capabilities": "R",
# "management_ip": "172.17.1.20",
# "management_ipv6": "2001:db8:16:1::3",
# "mac_address": "aa:c1:ab:0f:7e:46"
# }
# ]

for lldp_neighbor in textfsm_output:
my_interface = lldp_neighbor["local_interface"]
neighbor_interface = lldp_neighbor["neighbor_port_id"]
neighbor_name = lldp_neighbor["neighbor"]

configuration = [
f"int {my_interface}",
f"description ->{neighbor_name}, {neighbor_interface}"
]

output = connection.send_config_set(configuration)
print(output)
print(connection.send_command(f"show run int {my_interface}"))

0 comments on commit ee42593

Please sign in to comment.