Browse Source

add support for NetGear GS724TPv2.. This increases the timeout

to 10 seconds to deal w/ slow switches, but also puts in a proper
state machine for creating vlans.  This deals w/ the fact that
this switch can not create the vlan and activate the vlan in a
single command...
ssh-lenovo
John-Mark Gurney 4 years ago
parent
commit
288e4df9d7
2 changed files with 55 additions and 4 deletions
  1. +13
    -0
      NOTES.md
  2. +42
    -4
      vlanmang/__init__.py

+ 13
- 0
NOTES.md View File

@@ -59,3 +59,16 @@ NetGear GS108Tv2
----------------

Does not list VLAN 1 under dot1qVlanStaticName.

NetGear GS724TPv2
-----------------

Requires firmware version of at least v1.1.50.39 for SNMPv3 to be
functional. This version of firmware also requires a timeout of 2
seconds, which is longer than the 1 second default for queries to
complete. An issue with net-snmp has been filed:
https://github.com/net-snmp/net-snmp/issues/194

This swich cannot create vlans with the state set to createAndGo, they
must use createAndWait, set the egress ports (even if they are all
empty), before the vlan may be set active.

+ 42
- 4
vlanmang/__init__.py View File

@@ -397,7 +397,7 @@ class SNMPSwitch(object):
None else privProtocol
self._auth = UsmUserData(*args, **kwargs)

self._targ = UdpTransportTarget((host, 161))
self._targ = UdpTransportTarget((host, 161), timeout=10)

def __repr__(self): # pragma: no cover
return '<SNMPSwitch: auth=%s, targ=%s>' % (repr(self._auth), repr(self._targ))
@@ -536,9 +536,47 @@ class SNMPSwitch(object):
return bytes(v).decode('utf-8')

def createvlan(self, vlan, name):
# createAndGo(4)
self._set(('Q-BRIDGE-MIB', 'dot1qVlanStaticRowStatus',
int(vlan)), 4)
try:
while True:
try:
status = self._get(('Q-BRIDGE-MIB', 'dot1qVlanStaticRowStatus',
int(vlan)))
except ValueError:
status = 0

#print('got vlan', vlan, 'status:', status)
# if status == 0, vlan does not exist.

if status == 1: # active
# vlan is active
return

elif status == 0:
try:
# createAndGo(4)
self._set(('Q-BRIDGE-MIB', 'dot1qVlanStaticRowStatus',
int(vlan)), 4)
except ValueError:
# need to use createAndWait(5)
self._set(('Q-BRIDGE-MIB', 'dot1qVlanStaticRowStatus',
int(vlan)), 5)

elif status == 2: # notInService
# should be able to be marked active(1)
self._set(('Q-BRIDGE-MIB', 'dot1qVlanStaticRowStatus',
int(vlan)), 1)
elif status == 3: # notReady
# Set itself, it'll be set more properly later
# This is because a switch requires exact length
mib = ('Q-BRIDGE-MIB', 'dot1qVlanStaticEgressPorts', int(vlan))
self._set(mib, self._get(mib))
else:
raise ValueError('do not know how to handle status: %s' % status)
except Exception:
import traceback
traceback.print_exc()
raise

self._set(('Q-BRIDGE-MIB', 'dot1qVlanStaticName', int(vlan)),
name.encode('utf-8'))



Loading…
Cancel
Save