use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4MatchTest.
@Test
public void buildIpv4MatchTest() {
AceIpv4Builder aceIpv4 = new AceIpv4Builder();
aceIpv4.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
aceIpv4.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv4.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv4Match l3 = (Ipv4Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv4Destination().getValue().toString(), IPV4_DST_STR);
assertEquals(l3.getIpv4Source().getValue().toString(), IPV4_SRC_STR);
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv6MatchTest.
@Test
public void buildIpv6MatchTest() {
AceIpv6Builder aceIpv6 = new AceIpv6Builder();
aceIpv6.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
aceIpv6.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv6.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv6Match l3 = (Ipv6Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv6Destination().getValue().toString(), IPV6_DST_STR);
assertEquals(l3.getIpv6Source().getValue().toString(), IPV6_SRC_STR);
// There should be an IPv6 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV6));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project netvirt by opendaylight.
the class AclMatchesTest method buildEthMatchTest.
@Test
public void buildEthMatchTest() {
AceEthBuilder aceEthBuilder = new AceEthBuilder();
aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceEthBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The ethernet match should be there with src/dst values
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetSource().getAddress().getValue(), MAC_SRC_STR);
assertEquals(ethMatch.getEthernetDestination().getAddress().getValue(), MAC_DST_STR);
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer3Match());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method handleTepDelForAllRtrs.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private boolean handleTepDelForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp, String destTepIp, WriteTransaction writeFlowInvTx) {
LOG.trace("handleTepDelForAllRtrs : TEP DEL ----- for EXTERNAL/HWVTEP ITM Tunnel,TYPE {},State is UP b/w SRC IP" + " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
// When tunnel EP is deleted on a DPN , VPN gets two deletion event.
// One for a DPN on which tunnel EP was deleted and another for other-end DPN.
// Handle only the DPN on which it was deleted , ignore other event.
// DPN on which TEP is deleted , endpoint IP will be null.
String endpointIpForDPN = null;
try {
endpointIpForDPN = NatUtil.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
} catch (Exception e) {
/* this dpn does not have the VTEP */
LOG.error("handleTepDelForAllRtrs : DPN {} does not have the VTEP", srcDpnId);
endpointIpForDPN = null;
}
if (endpointIpForDPN != null) {
LOG.trace("handleTepDelForAllRtrs : Ignore TEP DELETE event received for DPN {} VTEP IP {} since its " + "the other end DPN w.r.t the delted TEP", srcDpnId, srcTepIp);
return false;
}
List<RoutersList> routersList = null;
InstanceIdentifier<DpnRoutersList> dpnRoutersListId = NatUtil.getDpnRoutersId(srcDpnId);
Optional<DpnRoutersList> optionalRouterDpnList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListId);
if (optionalRouterDpnList.isPresent()) {
routersList = optionalRouterDpnList.get().getRoutersList();
} else {
LOG.warn("handleTepDelForAllRtrs : RouterDpnList is empty for DPN {}.Hence ignoring TEP DEL event " + "for the ITM TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
if (routersList == null) {
LOG.error("handleTepDelForAllRtrs : DPN {} does not have the Routers presence", srcDpnId);
return false;
}
for (RoutersList router : routersList) {
String routerName = router.getRouter();
LOG.debug("handleTepDelForAllRtrs : TEP DEL : DNAT -> Withdrawing routes for router {} ", routerName);
long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("handleTepDelForAllRtrs :Invalid ROUTER-ID {} returned for routerName {}", routerId, routerName);
return false;
}
Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
if (extNwProvType == null) {
return false;
}
hndlTepDelForDnatInEachRtr(router, routerId, srcDpnId, extNwProvType);
LOG.debug("handleTepDelForAllRtrs : TEP DEL : SNAT -> Withdrawing and Advertising routes for router {} ", router.getRouter());
hndlTepDelForSnatInEachRtr(router, routerId, srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName, extNwProvType, writeFlowInvTx);
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method hndlTepAddForAllRtrs.
private boolean hndlTepAddForAllRtrs(BigInteger srcDpnId, String tunnelType, String tunnelName, String srcTepIp, String destTepIp, WriteTransaction writeFlowInvTx) {
LOG.trace("hndlTepAddForAllRtrs: TEP ADD ----- for EXTERNAL/HWVTEP ITM Tunnel, TYPE {} ,State is UP b/w SRC IP" + " : {} and DEST IP: {}", fibManager.getTransportTypeStr(tunnelType), srcTepIp, destTepIp);
InstanceIdentifier<DpnRoutersList> dpnRoutersListId = NatUtil.getDpnRoutersId(srcDpnId);
Optional<DpnRoutersList> optionalRouterDpnList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListId);
if (!optionalRouterDpnList.isPresent()) {
LOG.info("hndlTepAddForAllRtrs : RouterDpnList model is empty for DPN {}. Hence ignoring TEP add event " + "for the ITM TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
List<RoutersList> routersList = optionalRouterDpnList.get().getRoutersList();
if (routersList == null) {
LOG.debug("hndlTepAddForAllRtrs : Ignoring TEP add for the DPN {} since no routers are associated" + " for the DPN having the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and" + "TUNNEL NAME {} ", srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
return false;
}
String nextHopIp = NatUtil.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
for (RoutersList router : routersList) {
String routerName = router.getRouter();
long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddForAllRtrs :Invalid ROUTER-ID {} returned for routerName {}", routerId, routerName);
return false;
}
LOG.debug("hndlTepAddForAllRtrs : TEP ADD : DNAT -> Advertising routes for router {} ", routerName);
Uuid externalNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, externalNetworkId);
if (extNwProvType == null) {
return false;
}
hndlTepAddForDnatInEachRtr(router, routerId, nextHopIp, srcDpnId, extNwProvType, writeFlowInvTx);
LOG.debug("hndlTepAddForAllRtrs : TEP ADD : SNAT -> Advertising routes for router {} ", routerName);
hndlTepAddForSnatInEachRtr(router, routerId, srcDpnId, tunnelType, srcTepIp, destTepIp, tunnelName, nextHopIp, extNwProvType, writeFlowInvTx);
}
return true;
}
Aggregations