changes
This commit is contained in:
commit
5e31dd0214
37 changed files with 2082 additions and 0 deletions
21
modules/neighbors.py
Normal file
21
modules/neighbors.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
def parse_neighbors_data(data):
|
||||
neighbors_table = []
|
||||
|
||||
if "data" in data:
|
||||
raw_data = data["data"]
|
||||
|
||||
for line in raw_data.split("\n"):
|
||||
if line.strip() and not line.startswith("Address") and "---" not in line:
|
||||
neighbors_info = line.split()
|
||||
if len(neighbors_info) >= 4:
|
||||
neighbors_table.append({
|
||||
"address": neighbors_info[0],
|
||||
"interface": neighbors_info[1],
|
||||
"link_layer_address": neighbors_info[2],
|
||||
"state": neighbors_info[3]
|
||||
})
|
||||
|
||||
return neighbors_table
|
||||
|
||||
def generate_neighbors_json(neighbors_table):
|
||||
return {"neighbors_table": neighbors_table}
|
||||
Loading…
Add table
Add a link
Reference in a new issue