use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method getTargetSubnetForPacketOut.
// return only the first VPN subnetopdataentry
private static SubnetOpDataEntry getTargetSubnetForPacketOut(DataBroker broker, long elanTag, int ipAddress) {
ElanTagName elanInfo = VpnUtil.getElanInfoByElanTag(broker, elanTag);
if (elanInfo == null) {
LOG.error("{} getTargetDpnForPacketOut: Unable to retrieve ElanInfo for elanTag {}", LOGGING_PREFIX, elanTag);
return null;
}
Optional<NetworkMap> optionalNetworkMap = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, VpnUtil.buildNetworkMapIdentifier(new Uuid(elanInfo.getName())));
if (!optionalNetworkMap.isPresent()) {
LOG.debug("{} getTargetDpnForPacketOut: No network map found for elan info {}", LOGGING_PREFIX, elanInfo.getName());
return null;
}
List<Uuid> subnetList = optionalNetworkMap.get().getSubnetIdList();
LOG.debug("{} getTargetDpnForPacketOut: Obtained subnetList as {} for network {}", LOGGING_PREFIX, subnetList, elanInfo.getName());
for (Uuid subnetId : subnetList) {
String vpnName = null;
Subnetmap sn = VpnUtil.getSubnetmapFromItsUuid(broker, subnetId);
if (sn != null && sn.getVpnId() != null) {
vpnName = sn.getVpnId().getValue();
}
if (vpnName == null) {
continue;
}
Optional<SubnetOpDataEntry> optionalSubs;
optionalSubs = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, VpnUtil.buildSubnetOpDataEntryInstanceIdentifier(subnetId));
if (!optionalSubs.isPresent()) {
continue;
}
SubnetOpDataEntry subOpEntry = optionalSubs.get();
if (subOpEntry.getNhDpnId() != null) {
LOG.trace("{} getTargetDpnForPacketOut: Viewing Subnet {}", LOGGING_PREFIX, subnetId.getValue());
boolean match = NWUtil.isIpInSubnet(ipAddress, subOpEntry.getSubnetCidr());
LOG.trace("{} getTargetDpnForPacketOut: Viewing Subnet {} matching {}", LOGGING_PREFIX, subnetId.getValue(), match);
if (match) {
return subOpEntry;
}
}
}
return null;
}
Aggregations