use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints in project netvirt by opendaylight.
the class TunnelEndPointChangeListener method add.
@Override
protected void add(InstanceIdentifier<TunnelEndPoints> key, TunnelEndPoints tep) {
BigInteger dpnId = key.firstIdentifierOf(DPNTEPsInfo.class).firstKeyOf(DPNTEPsInfo.class).getDPNID();
if (BigInteger.ZERO.equals(dpnId)) {
LOG.warn("add: Invalid DPN id for TEP {}", tep.getInterfaceName());
return;
}
List<VpnInstance> vpnInstances = VpnHelper.getAllVpnInstances(broker);
if (vpnInstances == null || vpnInstances.isEmpty()) {
LOG.warn("add: dpnId: {}: tep: {}: No VPN instances defined", dpnId, tep.getInterfaceName());
return;
}
for (VpnInstance vpnInstance : vpnInstances) {
final String vpnName = vpnInstance.getVpnInstanceName();
final long vpnId = VpnUtil.getVpnId(broker, vpnName);
LOG.info("add: Handling TEP {} add for VPN instance {}", tep.getInterfaceName(), vpnName);
final String primaryRd = VpnUtil.getPrimaryRd(broker, vpnName);
if (!VpnUtil.isVpnPendingDelete(broker, primaryRd)) {
List<VpnInterfaces> vpnInterfaces = VpnUtil.getDpnVpnInterfaces(broker, vpnInstance, dpnId);
if (vpnInterfaces != null) {
for (VpnInterfaces vpnInterface : vpnInterfaces) {
String vpnInterfaceName = vpnInterface.getInterfaceName();
jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterfaceName, () -> {
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(broker, vpnInterfaceName);
if (interfaceState == null) {
LOG.debug("add: Cannot retrieve interfaceState for vpnInterfaceName {}, " + "cannot generate lPortTag and process adjacencies", vpnInterfaceName);
return Collections.emptyList();
}
final int lPortTag = interfaceState.getIfIndex();
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState)))))));
LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}", tep.getInterfaceName(), vpnName, vpnInterfaceName);
return futures;
});
}
}
} else {
LOG.error("add: Ignoring addition of tunnel interface {} dpn {} for vpnInstance {} with primaryRd {}," + " as the VPN is already marked for deletion", tep.getInterfaceName(), dpnId, vpnName, primaryRd);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints in project genius by opendaylight.
the class ItmManagerRpcService method getDpnEndpointIps.
@Override
public Future<RpcResult<GetDpnEndpointIpsOutput>> getDpnEndpointIps(GetDpnEndpointIpsInput input) {
BigInteger srcDpn = input.getSourceDpid();
RpcResultBuilder<GetDpnEndpointIpsOutput> resultBld = RpcResultBuilder.failed();
InstanceIdentifier<DPNTEPsInfo> tunnelInfoId = InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(srcDpn)).build();
Optional<DPNTEPsInfo> tunnelInfo = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tunnelInfoId, dataBroker);
if (!tunnelInfo.isPresent()) {
LOG.error("tunnelInfo is not present");
return Futures.immediateFuture(resultBld.build());
}
List<TunnelEndPoints> tunnelEndPointList = tunnelInfo.get().getTunnelEndPoints();
if (tunnelEndPointList == null || tunnelEndPointList.isEmpty()) {
LOG.error("tunnelEndPointList is null or empty");
return Futures.immediateFuture(resultBld.build());
}
List<IpAddress> nexthopIpList = new ArrayList<>();
tunnelEndPointList.forEach(tunnelEndPoint -> nexthopIpList.add(tunnelEndPoint.getIpAddress()));
GetDpnEndpointIpsOutputBuilder output = new GetDpnEndpointIpsOutputBuilder().setNexthopipList(nexthopIpList);
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
return Futures.immediateFuture(resultBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints in project genius by opendaylight.
the class TransportZoneListener method createDPNTepInfo.
private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
List<Subnets> subnetsList = transportZone.getSubnets();
if (subnetsList != null) {
for (Subnets subnet : subnetsList) {
IpPrefix ipPrefix = subnet.getPrefix();
IpAddress gatewayIP = subnet.getGatewayIp();
int vlanID = subnet.getVlanId();
LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
List<Vteps> vtepsList = subnet.getVteps();
if (vtepsList != null && !vtepsList.isEmpty()) {
for (Vteps vteps : vtepsList) {
BigInteger dpnID = vteps.getDpnId();
String port = vteps.getPortname();
IpAddress ipAddress = vteps.getIpAddress();
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
tunnelEndPointsList.add(tunnelEndPoints);
} else {
LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
tunnelEndPointsList = new ArrayList<>();
tunnelEndPointsList.add(tunnelEndPoints);
mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
}
}
}
}
if (!mapDPNToTunnelEndpt.isEmpty()) {
LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
dpnTepInfo.add(newDpnTepsInfo);
}
}
return dpnTepInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints in project genius by opendaylight.
the class ItmUtils method buildTunnelOptions.
public static List<TunnelOptions> buildTunnelOptions(TunnelEndPoints tep, ItmConfig itmConfig) {
List<TunnelOptions> tunOptions = new ArrayList<>();
String tos = tep.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
/* populate tos option only if its not default value of 0 */
if (tos != null && !tos.equals("0")) {
TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
optionsBuilder.setKey(new TunnelOptionsKey("tos"));
optionsBuilder.setTunnelOption("tos");
optionsBuilder.setValue(tos);
tunOptions.add(optionsBuilder.build());
}
if (tep.getTunnelType() == TunnelTypeVxlan.class && itmConfig.isGpeExtensionEnabled()) {
TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
optionsBuilder.setKey(new TunnelOptionsKey("exts"));
optionsBuilder.setTunnelOption("exts");
optionsBuilder.setValue("gpe");
tunOptions.add(optionsBuilder.build());
}
return tunOptions.isEmpty() ? null : tunOptions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints in project genius by opendaylight.
the class ItmUtils method removeTransportZoneMembership.
public static List<TzMembership> removeTransportZoneMembership(TunnelEndPoints endPts, List<TzMembership> zones) {
LOG.trace(" RemoveTransportZoneMembership TEPs {}, Membership to be removed {} ", endPts, zones);
List<TzMembership> existingTzList = new ArrayList<>(endPts.getTzMembership());
for (TzMembership membership : zones) {
existingTzList.remove(new TzMembershipBuilder().setZoneName(membership.getZoneName()).build());
}
LOG.debug("Modified Membership List {}", existingTzList);
return existingTzList;
}
Aggregations