use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class LinkHandler method isLinkValid.
/**
* Checks validity of link. Examples of invalid links include
* indirect-links, links between ports on the same switch, and more.
*
* @param link the link to be processed
* @return true if valid link
*/
boolean isLinkValid(Link link) {
if (link.type() != Link.Type.DIRECT) {
// NOTE: A DIRECT link might be transiently marked as INDIRECT
// if BDDP is received before LLDP. We can safely ignore that
// until the LLDP is received and the link is marked as DIRECT.
log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.", link.src(), link.dst(), link.type());
return false;
}
DeviceId srcId = link.src().deviceId();
DeviceId dstId = link.dst().deviceId();
if (srcId.equals(dstId)) {
log.warn("Links between ports on the same switch are not " + "allowed .. ignoring link {}", link);
return false;
}
DeviceConfiguration devConfig = srManager.deviceConfiguration;
if (devConfig == null) {
log.warn("Cannot check validity of link without device config");
return true;
}
try {
/*if (!devConfig.isEdgeDevice(srcId)
&& !devConfig.isEdgeDevice(dstId)) {
// ignore links between spines
// XXX revisit when handling multi-stage fabrics
log.warn("Links between spines not allowed...ignoring "
+ "link {}", link);
return false;
}*/
if (devConfig.isEdgeDevice(srcId) && devConfig.isEdgeDevice(dstId)) {
// one pair-link
if (devConfig.getPairDeviceId(srcId).equals(dstId) && devConfig.getPairLocalPort(srcId).equals(link.src().port()) && devConfig.getPairLocalPort(dstId).equals(link.dst().port())) {
// found pair link - allow it
return true;
} else {
log.warn("Links between leaves other than pair-links are " + "not allowed...ignoring link {}", link);
return false;
}
}
} catch (DeviceConfigNotFoundException e) {
// We still want to count the links in seenLinks even though there
// is no config. So we let it return true
log.warn("Could not check validity of link {} as subtending devices " + "are not yet configured", link);
}
return true;
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class LinkHandler method checkUplinksForHost.
/**
* Administratively disables the host location switchport if the edge device
* has no viable uplinks. The caller needs to determine if such behavior is
* desired for the single or dual-homed host.
*
* @param loc the host location
*/
void checkUplinksForHost(HostLocation loc) {
// Topology has only a single pair of leaves
if (srManager.getInfraDeviceIds().isEmpty()) {
log.debug("No spine configured. Not disabling access port for {}", loc);
return;
}
// If the device does not have a pair device - return
if (getPairDeviceIdOrNull(loc.deviceId()) == null) {
log.info("Device {} does not have pair device " + "not disabling access port", loc.deviceId());
return;
}
// Verify link validity
try {
for (Link l : srManager.linkService.getDeviceLinks(loc.deviceId())) {
if (srManager.deviceConfiguration.isEdgeDevice(l.dst().deviceId()) || l.state() == Link.State.INACTIVE) {
continue;
}
// found valid uplink - so, nothing to do
return;
}
} catch (DeviceConfigNotFoundException e) {
log.warn("Could not check for valid uplinks due to missing device" + "config " + e.getMessage());
return;
}
log.warn("Host location {} has no valid uplinks disabling port", loc);
srManager.deviceAdminService.changePortState(loc.deviceId(), loc.port(), false);
Set<PortNumber> p = downedPortStore.get(loc.deviceId());
if (p == null) {
p = Sets.newHashSet(loc.port());
} else {
p.add(loc.port());
}
downedPortStore.put(loc.deviceId(), p);
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class ArpHandler method isArpForRouter.
private boolean isArpForRouter(NeighbourMessageContext pkt) {
Ip4Address targetProtocolAddress = pkt.target().getIp4Address();
Set<IpAddress> gatewayIpAddresses = null;
try {
if (targetProtocolAddress.equals(config.getRouterIpv4(pkt.inPort().deviceId()))) {
return true;
}
gatewayIpAddresses = config.getPortIPs(pkt.inPort().deviceId());
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting check for router IP in processing arp");
}
if (gatewayIpAddresses != null && gatewayIpAddresses.contains(targetProtocolAddress)) {
return true;
}
return false;
}
Aggregations