Skip to content

Commit

Permalink
Reworked NodeDisvoeryBridge
Browse files Browse the repository at this point in the history
There was an error with the Vtp vlan
the bridge was not walked if the vtp is not active
  • Loading branch information
rssntn67 committed Jun 9, 2014
1 parent b781d2e commit 473aaf3
Showing 1 changed file with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,32 @@ public NodeDiscoveryBridge(final EnhancedLinkd linkd,
final LinkableSnmpNode node) {
super(linkd, node);
}

protected void runCollection() {

final Date now = new Date();

Map<Integer,String> vlanmap = getVtpVlanMap();

if (vlanmap.isEmpty())
walkBridge(null,null);
else {
for (Entry<Integer, String> entry: vlanmap.entrySet()) {
String community = getPeer().getReadCommunity();
LOG.debug("run: cisco vlan collection setting peer community: {} with VLAN {}",
community, entry.getKey());
getPeer().setReadCommunity(community + "@" + entry.getKey());
walkBridge(entry.getKey(), entry.getValue());
getPeer().setReadCommunity(community);
}
}

m_linkd.getQueryManager().reconcileBridge(getNodeId(), now);
LOG.debug("run: collecting: {}", getPeer());
}

private Map<Integer,String> getVtpVlanMap() {

final Map<Integer,String> vlanmap = new HashMap<Integer, String>();
String trackerName = "vtpVersion";
final CiscoVtpTracker vtpStatus = new CiscoVtpTracker();
Expand All @@ -100,25 +119,26 @@ protected void runCollection() {
if (walker.timedOut()) {
LOG.info("run:Aborting Bridge Linkd node scan : Agent timed out while scanning the {} table",
trackerName);
return;
return vlanmap;
} else if (walker.failed()) {
LOG.info("run:Aborting Bridge Linkd node scan : Agent failed while scanning the {} table: {}",
trackerName, walker.getErrorMessage());
return;
return vlanmap;
}
} catch (final InterruptedException e) {
LOG.error("run: Bridge Linkd node collection interrupted, exiting", e);
return;
return vlanmap;
}

if (vtpStatus.getVtpVersion() == null) {
LOG.info("cisco vtp mib not supported, on: {}",
LOG.info("run: cisco vtp mib not supported, on: {}",
str(getPeer().getAddress()));
return;
return vlanmap;
}
LOG.info("cisco vtp mib supported, on: {}", str(getPeer()

LOG.info("run: cisco vtp mib supported, on: {}", str(getPeer()
.getAddress()));
LOG.info("walking cisco vtp, on: {}", str(getPeer()
LOG.info("run: walking cisco vtp, on: {}", str(getPeer()
.getAddress()));

trackerName = "ciscoVtpVlan";
Expand All @@ -139,32 +159,14 @@ public void processCiscoVtpVlanRow(final CiscoVtpVlanRow row) {
if (walker.timedOut()) {
LOG.info("run:Aborting Bridge Linkd node scan : Agent timed out while scanning the {} table",
trackerName);
return;
} else if (walker.failed()) {
LOG.info("run:Aborting Bridge Linkd node scan : Agent failed while scanning the {} table: {}",
trackerName, walker.getErrorMessage());
return;
}
} catch (final InterruptedException e) {
LOG.error("run: Bridge Linkd node collection interrupted, exiting",e);
return;
}

if (vlanmap.isEmpty())
walkBridge(null,null);
else {
for (Entry<Integer, String> entry: vlanmap.entrySet()) {
String community = getPeer().getReadCommunity();
LOG.debug("run: cisco vlan collection setting peer community: {} with VLAN {}",
community, entry.getKey());
getPeer().setReadCommunity(community + "@" + entry.getKey());
walkBridge(entry.getKey(), entry.getValue());
getPeer().setReadCommunity(community);
}
}

m_linkd.getQueryManager().reconcileBridge(getNodeId(), now);

return vlanmap;
}

protected void walkBridge(Integer vlan, String vlanname) {
Expand Down Expand Up @@ -234,11 +236,11 @@ protected void walkBridge(Integer vlan, String vlanname) {
} else {
walkSpanningTree(bridge.getBaseBridgeAddress(),vlan);
}
walkDot1DTpFdp(vlan);
walkDot1QTpFdp();
walkDot1dTpFdp(vlan);
walkDot1qTpFdp();
}

private void walkDot1DTpFdp(final Integer vlan) {
private void walkDot1dTpFdp(final Integer vlan) {
String trackerName = "dot1dTbFdbPortTable";

Dot1dTpFdbTableTracker stpPortTableTracker = new Dot1dTpFdbTableTracker() {
Expand Down Expand Up @@ -273,7 +275,7 @@ public void processDot1dTpFdbRow(final Dot1dTpFdbRow row) {
}
}

private void walkDot1QTpFdp() {
private void walkDot1qTpFdp() {

String trackerName = "dot1qTbFdbPortTable";

Expand Down

0 comments on commit 473aaf3

Please sign in to comment.