Skip to content

Commit

Permalink
Few checks on the code
Browse files Browse the repository at this point in the history
  • Loading branch information
aswinvk28 committed Nov 29, 2016
1 parent 4f17498 commit 51e24f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 8 additions & 9 deletions snmpload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,31 @@
net = Mininet(SingleSwitchTopo(2))

def mininet_start_nodes(net):
validated = false
validated = False
net.start()
pingResults = net.pingAll()
if(pingResults.find('100% dropped') & pingResults.find('100.0')):
validated = true
validated = True
if(validated):
return net.values()
return 0


def mininet_snmp_load(host, community, objectID):
g = getCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget(('demo.snmplabs.com', 161)),
CommunityData(community),
UdpTransportTarget((host, 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))

next(g)
ObjectType(ObjectIdentity('SNMPv2-MIB', objectID, 0)))

nodes = mininet_start_nodes(net)
if(nodes):
for node in nodes:
print ""
mininet_snmp_load(node, community='public', objectID='sysDesc')





net.stop()
net.stop()
sys.exit(0)
3 changes: 2 additions & 1 deletion topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

while 1:
data = connection.recv(1024)
if not data break
if (data != NULL):
break
list = data.split("\t")
mininetSNMPValues = mininet_snmp_load(list[0], list[1], list[2]) # returns a dictionary
connection.send(str(mininetSNMPValues))
Expand Down

0 comments on commit 51e24f6

Please sign in to comment.