use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project cxf by apache.
the class DestinationSequenceTest method testEqualsAndHashCode.
@Test
public void testEqualsAndHashCode() {
DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
DestinationSequence otherSeq = null;
assertFalse(seq.equals(otherSeq));
otherSeq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
assertEquals(seq, otherSeq);
assertEquals(seq.hashCode(), otherSeq.hashCode());
Identifier otherId = factory.createIdentifier();
otherId.setValue("otherSeq");
otherSeq = new DestinationSequence(otherId, ref, destination, ProtocolVariation.RM10WSA200408);
assertFalse(seq.equals(otherSeq));
assertNotEquals(seq.hashCode(), otherSeq.hashCode());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project cxf by apache.
the class ManagedRMManagerTest method createTestSourceSequence.
private SourceSequence createTestSourceSequence(Source source, String sid, EndpointReferenceType to, ProtocolVariation protocol, long[] acked) {
Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
identifier.setValue(sid);
SourceSequence ss = new SourceSequence(identifier, protocol);
ss.setSource(source);
ss.setTarget(to);
List<SequenceAcknowledgement.AcknowledgementRange> ranges = ss.getAcknowledgement().getAcknowledgementRange();
for (int i = 0; i < acked.length; i += 2) {
ranges.add(createAcknowledgementRange(acked[i], acked[i + 1]));
}
return ss;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method createFlows.
void createFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
LOG.info("Initiating creation of Evpn Flows");
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(vrfTableKey.getRouteDistinguisher()).get();
Uint32 vpnId = vpnInstance.getVpnId();
checkNotNull(vpnInstance, "Vpn Instance not available %s", vrfTableKey.getRouteDistinguisher());
checkNotNull(vpnId, "Vpn Instance with rd %s has null vpnId!", vpnInstance.getVrfId());
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.CONNECTED) {
SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
final Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap = vpnInstance.nonnullVpnToDpnList();
final long elanTag = subnetRoute.getElantag().toJava();
LOG.trace("SubnetRoute augmented vrfentry found for rd {} prefix {} with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
if (keyVpnToDpnListMap != null) {
jobCoordinator.enqueueJob("FIB-" + rd + "-" + vrfEntry.getDestPrefix(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (final VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
vrfEntryListener.installSubnetRouteInFib(curDpn.getDpnId(), elanTag, rd, vpnId, vrfEntry, tx);
}
}
})));
}
return;
}
Prefixes localNextHopInfo = getFibUtil().getPrefixToInterface(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
List<Uint64> localDpnId = new ArrayList<>();
boolean isNatPrefix = false;
if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
LOG.info("NAT Prefix {} with vpnId {} rd {}. Skip local dpn {} FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, localNextHopInfo.getDpnId());
localDpnId.add(localNextHopInfo.getDpnId());
isNatPrefix = true;
} else {
localDpnId = createLocalEvpnFlows(vpnInstance.getVpnId(), rd, vrfEntry, localNextHopInfo);
}
createRemoteEvpnFlows(rd, vrfEntry, vpnInstance, localDpnId, vrfTableKey, isNatPrefix);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnInterfaceManager method advertiseAdjacenciesForVpnToBgp.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void advertiseAdjacenciesForVpnToBgp(final String rd, Uint64 dpnId, final InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String vpnName, String interfaceName) {
if (rd == null) {
LOG.error("advertiseAdjacenciesForVpnFromBgp: Unable to recover rd for interface {} on dpn {} in vpn {}", interfaceName, dpnId, vpnName);
return;
} else {
if (rd.equals(vpnName)) {
LOG.info("advertiseAdjacenciesForVpnFromBgp: Ignoring BGP advertisement for interface {} on dpn {}" + " as it is in internal vpn{} with rd {}", interfaceName, dpnId, vpnName, rd);
return;
}
}
LOG.info("advertiseAdjacenciesForVpnToBgp: Advertising interface {} on dpn {} in vpn {} with rd {} ", interfaceName, dpnId, vpnName, rd);
String nextHopIp = InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, dpnId);
if (nextHopIp == null) {
LOG.error("advertiseAdjacenciesForVpnToBgp: NextHop for interface {} on dpn {} is null," + " returning from advertising route with rd {} vpn {} to bgp", interfaceName, dpnId, rd, vpnName);
return;
}
try {
// Read NextHops
InstanceIdentifier<AdjacenciesOp> path = identifier.augmentation(AdjacenciesOp.class);
Optional<AdjacenciesOp> adjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, path);
if (adjacencies.isPresent()) {
Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.get().getAdjacency();
if (nextHopsMap != null && !nextHopsMap.isEmpty()) {
LOG.debug("advertiseAdjacenciesForVpnToBgp: NextHops are {} for interface {} on dpn {} for vpn {}" + " rd {}", nextHopsMap, interfaceName, dpnId, vpnName, rd);
VpnInstanceOpDataEntry vpnInstanceOpData = vpnUtil.getVpnInstanceOpData(rd);
Uint32 l3vni = vpnInstanceOpData.getL3vni();
VrfEntry.EncapType encapType = VpnUtil.isL3VpnOverVxLan(l3vni) ? VrfEntry.EncapType.Vxlan : VrfEntry.EncapType.Mplsgre;
for (Adjacency nextHop : nextHopsMap.values()) {
if (nextHop.getAdjacencyType() == AdjacencyType.ExtraRoute) {
continue;
}
String gatewayMac = null;
Uint32 label = Uint32.ZERO;
if (VpnUtil.isL3VpnOverVxLan(l3vni)) {
final VpnPortipToPort gwPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnInstanceOpData.getVpnInstanceName(), nextHop.getIpAddress());
gatewayMac = arpResponderHandler.getGatewayMacAddressForInterface(gwPort, interfaceName).get();
} else {
label = nextHop.getLabel();
}
try {
LOG.info("VPN ADVERTISE: advertiseAdjacenciesForVpnToBgp: Adding Fib Entry rd {} prefix {}" + " nexthop {} label {}", rd, nextHop.getIpAddress(), nextHopIp, label);
bgpManager.advertisePrefix(rd, nextHop.getMacAddress(), nextHop.getIpAddress(), nextHopIp, encapType, label, l3vni, Uint32.ZERO, /*l2vni*/
gatewayMac);
LOG.info("VPN ADVERTISE: advertiseAdjacenciesForVpnToBgp: Added Fib Entry rd {} prefix {}" + " nexthop {} label {} for interface {} on dpn {} for vpn {}", rd, nextHop.getIpAddress(), nextHopIp, label, interfaceName, dpnId, vpnName);
} catch (Exception e) {
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to advertise prefix {} in vpn {}" + " with rd {} for interface {} on dpn {}", nextHop.getIpAddress(), vpnName, rd, interfaceName, dpnId, e);
}
}
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("advertiseAdjacenciesForVpnToBgp: Failed to read data store for interface {} dpn {} nexthop {}" + "vpn {} rd {}", interfaceName, dpnId, nextHopIp, vpnName, rd);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Identifier in project netvirt by opendaylight.
the class VpnInterfaceManager method removeAdjacenciesFromVpn.
private void removeAdjacenciesFromVpn(final Uint64 dpnId, final int lportTag, final String interfaceName, final String vpnName, final Uint32 vpnId, String gwMac, TypedWriteTransaction<Configuration> writeConfigTxn, TypedWriteTransaction<Operational> writeOperTxn, TypedReadWriteTransaction<Configuration> writeInvTxn) throws ExecutionException, InterruptedException {
// Read NextHops
try {
InstanceIdentifier<VpnInterfaceOpDataEntry> identifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
Optional<VpnInterfaceOpDataEntry> vpnInterfaceOpDataEnteryOptional = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, identifier);
boolean isNonPrimaryAdjIp = false;
String primaryRd = vpnUtil.getVpnRd(vpnName);
LOG.info("removeAdjacenciesFromVpn: For interface {} on dpn {} RD recovered for vpn {} as rd {}", interfaceName, dpnId, vpnName, primaryRd);
if (!vpnInterfaceOpDataEnteryOptional.isPresent()) {
LOG.error("removeAdjacenciesFromVpn: VpnInterfaceOpDataEntry-Oper DS is absent for Interface {} " + "on vpn {} dpn {}", interfaceName, vpnName, dpnId);
return;
}
AdjacenciesOp adjacencies = vpnInterfaceOpDataEnteryOptional.get().augmentation(AdjacenciesOp.class);
if (adjacencies != null && adjacencies.getAdjacency() != null) {
Map<AdjacencyKey, Adjacency> nextHopsMap = adjacencies.nonnullAdjacency();
LOG.info("removeAdjacenciesFromVpn: NextHops for interface {} on dpn {} for vpn {} are {}", interfaceName, dpnId, vpnName, nextHopsMap);
for (Adjacency nextHop : nextHopsMap.values()) {
if (nextHop.isPhysNetworkFunc()) {
LOG.info("removeAdjacenciesFromVpn: Removing PNF FIB entry rd {} prefix {}", nextHop.getSubnetId().getValue(), nextHop.getIpAddress());
fibManager.removeFibEntry(nextHop.getSubnetId().getValue(), nextHop.getIpAddress(), null, null);
} else {
String rd = nextHop.getVrfId();
List<String> nhList;
if (nextHop.getAdjacencyType() != AdjacencyType.PrimaryAdjacency) {
nhList = getNextHopForNonPrimaryAdjacency(nextHop, vpnName, dpnId, interfaceName);
isNonPrimaryAdjIp = Boolean.TRUE;
} else {
// This is a primary adjacency
nhList = nextHop.getNextHopIpList() != null ? nextHop.getNextHopIpList() : emptyList();
removeGwMacAndArpResponderFlows(nextHop, vpnId, dpnId, lportTag, gwMac, vpnInterfaceOpDataEnteryOptional.get().getGatewayIpAddress(), interfaceName, writeInvTxn);
isNonPrimaryAdjIp = Boolean.FALSE;
}
if (!nhList.isEmpty()) {
if (Objects.equals(primaryRd, vpnName)) {
// this is an internal vpn - the rd is assigned to the vpn instance name;
// remove from FIB directly
nhList.forEach(removeAdjacencyFromInternalVpn(nextHop, vpnName, interfaceName, dpnId, writeConfigTxn, writeOperTxn));
} else {
removeAdjacencyFromBgpvpn(nextHop, nhList, vpnName, primaryRd, dpnId, rd, interfaceName, isNonPrimaryAdjIp, writeConfigTxn, writeOperTxn);
}
} else {
LOG.error("removeAdjacenciesFromVpn: nextHop empty for ip {} rd {} adjacencyType {}" + " interface {}", nextHop.getIpAddress(), rd, nextHop.getAdjacencyType().toString(), interfaceName);
bgpManager.withdrawPrefixIfPresent(rd, nextHop.getIpAddress());
fibManager.removeFibEntry(primaryRd, nextHop.getIpAddress(), null, writeConfigTxn);
}
}
String ip = nextHop.getIpAddress().split("/")[0];
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, ip);
if (vpnVipToPort != null && vpnVipToPort.getPortName().equals(interfaceName)) {
vpnUtil.removeLearntVpnVipToPort(vpnName, ip, null);
LOG.info("removeAdjacenciesFromVpn: VpnInterfaceManager removed LearntVpnVipToPort entry" + " for Interface {} ip {} on dpn {} for vpn {}", vpnVipToPort.getPortName(), ip, dpnId, vpnName);
}
// Remove the MIP-IP from VpnPortIpToPort.
if (isNonPrimaryAdjIp) {
VpnPortipToPort persistedIp = vpnUtil.getVpnPortipToPort(vpnName, ip);
if (persistedIp != null && persistedIp.isLearntIp() && persistedIp.getPortName().equals(interfaceName)) {
VpnUtil.removeVpnPortFixedIpToPort(dataBroker, vpnName, ip, null);
LOG.info("removeAdjacenciesFromVpn: Learnt-IP: {} interface {} of vpn {} removed " + "from VpnPortipToPort", persistedIp.getPortFixedip(), persistedIp.getPortName(), vpnName);
}
}
VpnPortipToPort vpnPortipToPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnName, ip);
if (vpnPortipToPort != null) {
VpnUtil.removeVpnPortFixedIpToPort(dataBroker, vpnName, ip, null);
LOG.info("removeAdjacenciesFromVpn: VpnInterfaceManager removed vpnPortipToPort entry for " + "Interface {} ip {} on dpn {} for vpn {}", vpnPortipToPort.getPortName(), ip, dpnId, vpnName);
}
}
} else {
// this vpn interface has no more adjacency left, so clean up the vpn interface from Operational DS
LOG.info("removeAdjacenciesFromVpn: Vpn Interface {} on vpn {} dpn {} has no adjacencies." + " Removing it.", interfaceName, vpnName, dpnId);
writeOperTxn.delete(identifier);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("removeAdjacenciesFromVpn: Failed to read data store for interface {} dpn {} vpn {}", interfaceName, dpnId, vpnName);
}
}
Aggregations