Skip to content
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

Rolling #3

Merged
merged 31 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
31883c6
Bugfix on buildJson in Naspy.py
FrancescoVengeance Aug 10, 2021
577b5bc
Bugfix
FrancescoVengeance Aug 10, 2021
6e654f9
Update README.md
FrancescoVengeance Aug 10, 2021
e6524c2
Bugfix
FrancescoVengeance Aug 11, 2021
654aa46
Merge remote-tracking branch 'origin/rolling' into rolling
FrancescoVengeance Aug 11, 2021
7404b8f
Bugfix
FrancescoVengeance Aug 11, 2021
01a88ef
Bugfix
FrancescoVengeance Aug 11, 2021
f34c9d2
Bugfix
FrancescoVengeance Aug 11, 2021
f834b92
Bugfix
FrancescoVengeance Aug 11, 2021
5dfd53f
Bugfix
FrancescoVengeance Aug 11, 2021
fdc81eb
Bugfix
FrancescoVengeance Aug 11, 2021
28f78e4
Bugfix
FrancescoVengeance Aug 11, 2021
9b373fe
Bugfix
FrancescoVengeance Aug 11, 2021
964f683
Bugfix
FrancescoVengeance Aug 11, 2021
da36a1e
Bugfix
FrancescoVengeance Aug 11, 2021
f08a450
Bugfix
FrancescoVengeance Aug 13, 2021
3f6fb2f
Bugfix
FrancescoVengeance Aug 13, 2021
869739b
Bugfix
FrancescoVengeance Aug 13, 2021
e69b2aa
Bugfix
FrancescoVengeance Aug 13, 2021
f4818b4
Bugfix
FrancescoVengeance Aug 13, 2021
b2416a6
Bugfix
FrancescoVengeance Aug 13, 2021
1c083ad
Bugfix
FrancescoVengeance Aug 13, 2021
2aa4e9e
Bugfix
FrancescoVengeance Aug 13, 2021
9a7aa28
Bugfix
FrancescoVengeance Aug 13, 2021
71e0079
Bugfix
FrancescoVengeance Aug 13, 2021
b1065e2
Bugfix
FrancescoVengeance Aug 13, 2021
38b0289
Bugfix
FrancescoVengeance Aug 13, 2021
c2da01c
Bugfix
FrancescoVengeance Aug 13, 2021
e8504f3
Bugfix
FrancescoVengeance Aug 13, 2021
9df5347
Bugfix
FrancescoVengeance Aug 13, 2021
75898c1
Merge branch 'master' into rolling
FrancescoVengeance Aug 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions naspy/CiscoElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from utilities import EntryNotFoundException, ElementException
from paramiko import Channel

import traceback

class CiscoElement(Element):
def connectionSSH(self, database: dict) -> str:
Expand Down Expand Up @@ -176,14 +176,14 @@ def showArp(self, shell: Channel) -> None:

def parseARP(self, text: str) -> None:
text = re.compile("\s\s+").split(text)
ip = text[0]
ip = text[1]
mac = text[3]

element = self.manager.getElementByIp(ip)
if element is None:
element = Element("", ip, "", "", self.manager)
element.setMac(mac)


def getHostname(self, shell: Channel) -> None:
# aggiustare anche inserendo il dominio
shell.send("show running-config\n")
Expand Down
5 changes: 3 additions & 2 deletions naspy/Naspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def visit(self) -> None:
print("\ndevice founded:")
count = 1
for hostname in self.manager.elementsByHostname:
print(f" [{count}]: {hostname}\n")
print(f" [{count}]: {hostname} | mac: {self.manager.elementsByHostname[hostname].macAddress}\n")
count += 1
self.buildJson()
pass
Expand Down Expand Up @@ -104,7 +104,8 @@ def buildJson(self) -> None:
+ self.manager.getElementByHostname(hostname).macAddress + '"}'

for link in self.manager.getElementByHostname(hostname).links:
if (hostname, link.element.hostname) not in computed and (link.element.hostname, hostname) not in computed:
if (hostname, link.element.hostname) not in computed or (link.element.hostname, hostname) not in computed:
print(f"entrato per {hostname}")
if firstEdge:
edges += '{"id":' + str(cont) + ', "source":"' + self.manager.elementsByHostname[hostname].ip \
+ '", "target": "' + link.element.ip \
Expand Down
11 changes: 6 additions & 5 deletions naspy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ def popToVisit(self) -> Element:
return self.toVisit.pop(0)

def getElementByIp(self, ip):
with self.lock:
for key in self.elementsByHostname.keys():
if ip == self.elementsByHostname[key].ip:
return self.elementsByHostname[key]
print("getElementByIp()")
for key in self.elementsByHostname.keys():
print(f"if {ip} == {self.elementsByHostname[key].ip}")
if ip == self.elementsByHostname[key].ip:
return self.elementsByHostname[key]

return None
return None

def getElementByMac(self, mac):
with self.lock:
Expand Down