use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class ElanServiceProvider method updateExternalElanNetworks.
@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
return;
}
List<ElanInstance> elanInstances = getElanInstances();
if (elanInstances == null || elanInstances.isEmpty()) {
LOG.trace("No ELAN instances found");
return;
}
LOG.debug("updateExternalElanNetworks, orig bridge {} . updated bridge {}", origNode, updatedNode);
Map<String, String> origProviderMappping = getMapFromOtherConfig(origNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
Map<String, String> updatedProviderMappping = getMapFromOtherConfig(updatedNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
boolean hasDatapathIdOnOrigNode = bridgeMgr.hasDatapathID(origNode);
boolean hasDatapathIdOnUpdatedNode = bridgeMgr.hasDatapathID(updatedNode);
BigInteger origDpnID = bridgeMgr.getDatapathId(origNode);
for (ElanInstance elanInstance : elanInstances) {
String physicalNetworkName = elanInstance.getPhysicalNetworkName();
boolean createExternalElanNw = true;
if (physicalNetworkName != null) {
String origPortName = origProviderMappping.get(physicalNetworkName);
String updatedPortName = updatedProviderMappping.get(physicalNetworkName);
/**
* for internal vlan network, vlan provider interface creation should be
* triggered only if there is existing vlan provider intf indicating presence
* of VM ports on the DPN
*/
if (hasDatapathIdOnOrigNode && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
String externalIntf = getExternalElanInterface(elanInstance.getElanInstanceName(), origDpnID);
if (externalIntf == null) {
createExternalElanNw = false;
}
}
if (hasPortNameRemoved(origPortName, updatedPortName)) {
deleteExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(origNode, physicalNetworkName));
}
if (createExternalElanNw && (hasPortNameUpdated(origPortName, updatedPortName) || hasDatapathIdAdded(hasDatapathIdOnOrigNode, hasDatapathIdOnUpdatedNode))) {
createExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(updatedNode, physicalNetworkName));
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class VpnManagerImpl method createIdPool.
private void createIdPool() {
CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.VPN_IDPOOL_NAME).setLow(VpnConstants.VPN_IDPOOL_LOW).setHigh(VpnConstants.VPN_IDPOOL_HIGH).build();
try {
Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
if (result != null && result.get().isSuccessful()) {
LOG.info("Created IdPool for VPN Service");
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to create idPool for VPN Service", e);
}
// Now an IdPool for InterVpnLink endpoint's pseudo ports
CreateIdPoolInput createPseudoLporTagPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.PSEUDO_LPORT_TAG_ID_POOL_NAME).setLow(VpnConstants.LOWER_PSEUDO_LPORT_TAG).setHigh(VpnConstants.UPPER_PSEUDO_LPORT_TAG).build();
try {
Future<RpcResult<Void>> result = idManager.createIdPool(createPseudoLporTagPool);
if (result.get().isSuccessful()) {
LOG.debug("Created IdPool for Pseudo Port tags");
} else {
Collection<RpcError> errors = result.get().getErrors();
StringBuilder errMsg = new StringBuilder();
for (RpcError err : errors) {
errMsg.append(err.getMessage()).append("\n");
}
LOG.error("IdPool creation for PseudoPort tags failed. Reasons: {}", errMsg);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to create idPool for Pseudo Port tags", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class OpenFlow13Provider method createIngressClassifierFilterVxgpeNshFlow.
/*
* Ingress Classifier Filter Vxgpe NSH flow:
* Only allows Non-NSH packets to proceed in the classifier
* Match on ethertype and resubmit to SFC (we don't resubmit to
* dispatcher since it is still not used for tunnel ports)
*/
public Flow createIngressClassifierFilterVxgpeNshFlow(NodeId nodeId) {
MatchBuilder match = new MatchBuilder();
OpenFlow13Utils.addMatchEthNsh(match);
List<Action> actionList = new ArrayList<>();
actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.SFC_TRANSPORT_INGRESS_TABLE, actionList.size()));
InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
String flowIdStr = INGRESS_CLASSIFIER_FILTER_VXGPENSH_FLOW_NAME + nodeId.getValue();
return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE, INGRESS_CLASSIFIER_FILTER_TUN_NSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE, INGRESS_CLASSIFIER_FILTER_VXGPENSH_FLOW_NAME, flowIdStr, match, isb).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method hndlTepAddForDnatInEachRtr.
private void hndlTepAddForDnatInEachRtr(RoutersList router, long routerId, String nextHopIp, BigInteger tepAddedDpnId, ProviderTypes extNwProvType, WriteTransaction writeFlowInvTx) {
// DNAT : Advertise the new route to the floating IP having the new TEP IP as the next hop IP
final String routerName = router.getRouter();
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("hndlTepAddForDnatInEachRtr : DNAT -> Could not read Router Ports data object with id: {} " + "from DNAT FloatinIpInfo", routerName);
return;
}
RouterPorts routerPorts = optRouterPorts.get();
Uuid extNwId = routerPorts.getExternalNetworkId();
final String vpnName = NatUtil.getAssociatedVPN(dataBroker, extNwId);
if (vpnName == null) {
LOG.info("hndlTepAddForDnatInEachRtr : DNAT -> No External VPN associated with ext nw {} for router {}", extNwId, routerName);
return;
}
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
if (extNwProvType == null) {
return;
}
String gwMacAddress = null;
long l3Vni = 0;
if (extNwProvType == ProviderTypes.VXLAN) {
// Get the External Gateway MAC Address which is Router gateway MAC address for SNAT
gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
if (gwMacAddress != null) {
LOG.debug("hndlTepAddForDnatInEachRtr : External GwMAC address {} found for External Router ID {}", gwMacAddress, routerId);
} else {
LOG.error("hndlTepAddForDnatInEachRtr : No External GwMAC address found for External Router ID {}", routerId);
return;
}
// get l3Vni value for external VPN
l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
LOG.debug("hndlTepAddForDnatInEachRtr : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue to installing " + "NAT flows", vpnName, rd);
l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
}
}
List<Ports> interfaces = routerPorts.getPorts();
for (Ports port : interfaces) {
// Get the DPN on which this interface resides
final String interfaceName = port.getPortName();
final BigInteger fipCfgdDpnId = NatUtil.getDpnForInterface(interfaceService, interfaceName);
if (fipCfgdDpnId.equals(BigInteger.ZERO)) {
LOG.info("hndlTepAddForDnatInEachRtr : DNAT->Skip processing Floating ip configuration for the port {}," + "since no DPN present for it", interfaceName);
continue;
}
if (!fipCfgdDpnId.equals(tepAddedDpnId)) {
LOG.debug("hndlTepAddForDnatInEachRtr : DNAT -> TEP added DPN {} is not the DPN {} which has the " + "floating IP configured for the port: {}", tepAddedDpnId, fipCfgdDpnId, interfaceName);
continue;
}
List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
final String internalIp = intExtPortMap.getInternalIp();
final String externalIp = intExtPortMap.getExternalIp();
LOG.debug("hndlTepAddForDnatInEachRtr : DNAT -> Advertising the FIB route to the floating IP {} " + "configured for the port: {}", externalIp, interfaceName);
long serviceId = 0;
String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
if (extNwProvType == ProviderTypes.VXLAN) {
LOG.debug("hndlTepAddForDnatInEachRtr : DNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
NatEvpnUtil.addRoutesForVxLanProvType(dataBroker, bgpManager, fibManager, vpnName, rd, externalIp, nextHopIp, l3Vni, interfaceName, gwMacAddress, writeFlowInvTx, RouteOrigin.STATIC, fipCfgdDpnId);
serviceId = l3Vni;
} else {
long label = floatingIPListener.getOperationalIpMapping(routerName, interfaceName, internalIp);
if (label == NatConstants.INVALID_ID) {
LOG.error("hndlTepAddForDnatInEachRtr : DNAT -> Unable to advertise to the DC GW since label " + "is invalid");
return;
}
LOG.debug("hndlTepAddForDnatInEachRtr : DNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
long l3vni = 0;
if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
l3vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, l3vni).longValue();
}
NatUtil.addPrefixToBGP(dataBroker, bgpManager, fibManager, vpnName, rd, null, fibExternalIp, nextHopIp, null, null, label, l3vni, RouteOrigin.STATIC, fipCfgdDpnId);
serviceId = label;
}
// Install custom FIB routes (Table 21 -> Push MPLS label to Tunnel port
List<Instruction> customInstructions = new ArrayList<>();
customInstructions.add(new InstructionGotoTable(NwConstants.PDNAT_TABLE).buildInstruction(0));
CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(fipCfgdDpnId).setInstruction(customInstructions).setIpAddress(fibExternalIp).setServiceId(serviceId).setInstruction(customInstructions).build();
Future<RpcResult<Void>> future = fibRpcService.createFibEntry(input);
ListenableFuture<RpcResult<Void>> listenableFuture = JdkFutureAdapters.listenInPoolThread(future);
Futures.addCallback(listenableFuture, new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("hndlTepAddForDnatInEachRtr : DNAT -> Error in generate label or fib install process", error);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("hndlTepAddForDnatInEachRtr : DNAT -> Successfully installed custom FIB routes " + "for prefix {}", externalIp);
} else {
LOG.error("hndlTepAddForDnatInEachRtr : DNAT -> Error in rpc call to create custom Fib " + "entries for prefix {} in DPN {}, {}", externalIp, fipCfgdDpnId, result.getErrors());
}
}
}, MoreExecutors.directExecutor());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class NatTunnelInterfaceStateListener method hndlTepDelForDnatInEachRtr.
private void hndlTepDelForDnatInEachRtr(RoutersList router, long routerId, BigInteger tepDeletedDpnId, ProviderTypes extNwProvType) {
// DNAT : Withdraw the routes from the BGP
String routerName = router.getRouter();
LOG.debug("hndlTepDelForDnatInEachRtr : DNAT -> Trying to clear routes to the Floating IP " + "associated to the router {}", routerName);
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("hndlTepDelForDnatInEachRtr : DNAT -> Could not read Router Ports data object with id: {} " + "from DNAT FloatingIpInfo", routerName);
return;
}
RouterPorts routerPorts = optRouterPorts.get();
Uuid extNwId = routerPorts.getExternalNetworkId();
final String vpnName = NatUtil.getAssociatedVPN(dataBroker, extNwId);
if (vpnName == null) {
LOG.error("hndlTepDelForDnatInEachRtr : DNAT -> No External VPN associated with Ext N/W {} for Router {}", extNwId, routerName);
return;
}
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
if (extNwProvType == null) {
return;
}
long l3Vni = 0;
if (extNwProvType == ProviderTypes.VXLAN) {
// get l3Vni value for external VPN
l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
LOG.debug("hndlTepDelForDnatInEachRtr : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue to installing " + "NAT flows", vpnName, rd);
l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, vpnName, routerId).longValue();
}
}
List<Ports> interfaces = routerPorts.getPorts();
for (Ports port : interfaces) {
// Get the DPN on which this interface resides
String interfaceName = port.getPortName();
BigInteger fipCfgdDpnId = NatUtil.getDpnForInterface(interfaceService, interfaceName);
if (fipCfgdDpnId.equals(BigInteger.ZERO)) {
LOG.info("hndlTepDelForDnatInEachRtr : DNAT -> Abort processing Floating ip configuration. " + "No DPN for port : {}", interfaceName);
continue;
}
if (!fipCfgdDpnId.equals(tepDeletedDpnId)) {
LOG.info("hndlTepDelForDnatInEachRtr : DNAT -> TEP deleted DPN {} is not the DPN {} which has the " + "floating IP configured for the port: {}", tepDeletedDpnId, fipCfgdDpnId, interfaceName);
continue;
}
List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
String internalIp = intExtPortMap.getInternalIp();
String externalIp = intExtPortMap.getExternalIp();
externalIp = NatUtil.validateAndAddNetworkMask(externalIp);
LOG.debug("hndlTepDelForDnatInEachRtr : DNAT -> Withdrawing the FIB route to the floating IP {} " + "configured for the port: {}", externalIp, interfaceName);
NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, externalIp, vpnName, LOG);
long serviceId = 0;
if (extNwProvType == ProviderTypes.VXLAN) {
serviceId = l3Vni;
} else {
long label = floatingIPListener.getOperationalIpMapping(routerName, interfaceName, internalIp);
if (label == NatConstants.INVALID_ID) {
LOG.error("hndlTepDelForDnatInEachRtr : DNAT -> Unable to remove the table 21 entry pushing the" + " MPLS label to the tunnel since label is invalid");
return;
}
serviceId = label;
}
RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(fipCfgdDpnId).setIpAddress(externalIp).setServiceId(serviceId).setIpAddressSource(RemoveFibEntryInput.IpAddressSource.FloatingIP).build();
Future<RpcResult<Void>> future = fibRpcService.removeFibEntry(input);
ListenableFuture<RpcResult<Void>> listenableFuture = JdkFutureAdapters.listenInPoolThread(future);
Futures.addCallback(listenableFuture, new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("hndlTepDelForDnatInEachRtr : DNAT -> Error in removing the table 21 entry pushing " + "the MPLS label to the tunnel since label is invalid ", error);
}
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.info("hndlTepDelForDnatInEachRtr : DNAT -> Successfully removed the entry pushing the " + "MPLS label to the tunnel");
} else {
LOG.error("hndlTepDelForDnatInEachRtr : DNAT -> Error in fib rpc call to remove the table " + "21 entry pushing the MPLS label to the tunnnel due to {}", result.getErrors());
}
}
}, MoreExecutors.directExecutor());
}
}
}
Aggregations