import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.SubnetUtils;
import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
import org.opendaylight.genius.itm.api.IITMProvider;
import org.opendaylight.genius.itm.confighelpers.HwVtep;
import org.opendaylight.genius.itm.globals.ITMConstants;
-import org.opendaylight.genius.mdsalutil.*;
+import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionType;
+import org.opendaylight.genius.mdsalutil.FlowEntity;
+import org.opendaylight.genius.mdsalutil.InstructionInfo;
+import org.opendaylight.genius.mdsalutil.InstructionType;
+import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.mdsalutil.MatchFieldType;
+import org.opendaylight.genius.mdsalutil.MatchInfo;
+import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParams;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorInterval;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParams;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepConfigSchemas;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepIpPools;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBfd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.genius.utils.cache.DataStoreCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
public class ItmUtils {
public static final String DUMMY_IP_ADDRESS = "0.0.0.0";
public static final String TUNNEL_TYPE_VXLAN = "VXLAN";
public static final String TUNNEL_TYPE_GRE = "GRE";
- public static final String TUNNEL = "TUNNEL";
+ public static final String TUNNEL = "tun";
public static ItmCache itmCache = new ItmCache();
private static final Logger LOG = LoggerFactory.getLogger(ItmUtils.class);
String trunkInterfaceName = String.format( "%s:%s:%s:%s", parentInterfaceName, localHostName,
remoteHostName, tunnelTypeStr);
LOG.trace("trunk interface name is {}", trunkInterfaceName);
- trunkInterfaceName = String.format("%s:%s", TUNNEL, getUniqueId(idManager, trunkInterfaceName));
+ trunkInterfaceName = String.format("%s%s", TUNNEL, getUniqueIdString(trunkInterfaceName));
return trunkInterfaceName;
}
}
String trunkInterfaceName = String.format("%s:%s:%s:%s", parentInterfaceName, localHostName, remoteHostName, tunnelTypeStr);
LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName );
- releaseId(idManager, trunkInterfaceName) ;
+ //releaseId(idManager, trunkInterfaceName) ;
}
public static InetAddress getInetAddressFromIpAddress(IpAddress ip) {
.setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
+ Long monitoringInterval=null;
if( vlanId > 0) {
IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
builder.addAugmentation(IfL2vlan.class, l2vlan);
}
LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}",monitorProtocol.getName(),monitorInterval);
- Long monitoringInterval = (long)ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL;
- Boolean monitoringEnabled = true;
+
if(monitorInterval!= null)
monitoringInterval = monitorInterval.longValue();
- else {
- if (monitorProtocol.getName().contains("Bfd"))
- monitoringInterval = (long) ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL;
- else
- monitoringInterval = (long) ITMConstants.DEFAULT_MONITOR_INTERVAL;
- }
- LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}",monitorProtocol.getName(),monitorInterval);
-
- if(monitorEnabled!=null )
- monitoringEnabled = monitorEnabled;
+
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(
- gatewayIp).setTunnelSource(localIp)
- .setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(
- monitoringEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).build();
+ gatewayIp).setTunnelSource(localIp)
+ .setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(
+ monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)).setName(
tunnelIfName).setDescription(desc).
setEnabled(enabled).setType(Tunnel.class);
- List<NodeIdentifier> nodeIds = new ArrayList<NodeIdentifier>();
+ List<NodeIdentifier> nodeIds = new ArrayList<>();
NodeIdentifier hWnode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topo_id)).setTopologyId(
topo_id).
setNodeId(node_id).build();
public static List<DPNTEPsInfo> getTunnelMeshInfo(DataBroker dataBroker) {
List<DPNTEPsInfo> dpnTEPs= null ;
+ // Read the Mesh Information from Cache if not read from the DS
+ dpnTEPs = getTunnelMeshInfo() ;
+ if( dpnTEPs != null )
+ return dpnTEPs ;
+
// Read the EndPoint Info from the operational database
InstanceIdentifierBuilder<DpnEndpoints> depBuilder = InstanceIdentifier.builder( DpnEndpoints.class);
InstanceIdentifier<DpnEndpoints> deps = depBuilder.build();
return dpnTEPs ;
}
+ // Reading the Mesh Information from Cache
+ public static List<DPNTEPsInfo> getTunnelMeshInfo(){
+ List<DPNTEPsInfo> dpnTepsInfo = null ;
+ List<Object> values = null ;
+
+ values = DataStoreCache.getValues(ITMConstants.DPN_TEPs_Info_CACHE_NAME);
+ if( values != null ) {
+ dpnTepsInfo = new ArrayList<>() ;
+ for( Object value : values ) {
+ dpnTepsInfo.add((DPNTEPsInfo)value) ;
+ }
+ }
+ return dpnTepsInfo ;
+ }
+
public static int getUniqueId(IdManagerService idManager, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder()
.setPoolName(ITMConstants.ITM_IDPOOL_NAME)
return 0;
}
+ public static String getUniqueIdString(String idKey) {
+ return UUID.nameUUIDFromBytes(idKey.getBytes()).toString().substring(0, 12).replace("-", "");
+ }
+
public static void releaseId(IdManagerService idManager, String idKey) {
ReleaseIdInput idInput =
new ReleaseIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey(idKey).build();
public static List<DPNTEPsInfo> getDPNTEPListFromDPNId(DataBroker dataBroker, List<BigInteger> dpnIds) {
List<DPNTEPsInfo> meshedDpnList = getTunnelMeshInfo(dataBroker) ;
- List<DPNTEPsInfo> cfgDpnList = new ArrayList<DPNTEPsInfo>();
+ List<DPNTEPsInfo> cfgDpnList = new ArrayList<>();
if( null != meshedDpnList) {
for(BigInteger dpnId : dpnIds) {
for( DPNTEPsInfo teps : meshedDpnList ) {
public static void setUpOrRemoveTerminatingServiceTable(BigInteger dpnId, IMdsalApiManager mdsalManager, boolean addFlag) {
String logmsg = ( addFlag == true) ? "Installing" : "Removing";
LOG.trace( logmsg + " PUNT to Controller flow in DPN {} ", dpnId );
- long dpId;
- List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
+ List<ActionInfo> listActionInfo = new ArrayList<>();
listActionInfo.add(new ActionInfo(ActionType.punt_to_controller,
new String[] {}));
try {
- List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+ List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {
BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID) }));
- List<InstructionInfo> mkInstructions = new ArrayList<InstructionInfo>();
+ List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionInfo(InstructionType.apply_actions,
listActionInfo));
}
private static String getFlowRef(long termSvcTable, int svcId) {
- return new StringBuffer().append(termSvcTable).append(svcId).toString();
+ return String.valueOf(termSvcTable) + svcId;
}
public static InstanceIdentifier<VtepConfigSchema> getVtepConfigSchemaIdentifier(String schemaName) {
return InstanceIdentifier.builder(VtepConfigSchemas.class)
if (!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName())
&& schema.getSubnet().equals(existingSchema.getSubnet())) {
String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
- Preconditions.checkArgument(false, new StringBuilder("VTEP schema with subnet [").append(subnetCidr)
- .append("] already exists. Multiple VTEP schemas with same subnet is not allowed.").toString());
+ Preconditions.checkArgument(false, "VTEP schema with subnet [" + subnetCidr +
+ "] already exists. Multiple VTEP schemas with same subnet is not allowed.");
}
}
if (isNotEmpty(getDpnIdList(validSchema.getDpnIds()))) {
getDpnIdList(validSchema.getDpnIds()), existingSchemas);
if (!lstDpns.isEmpty()) {
Preconditions.checkArgument(false,
- new StringBuilder("DPN's ").append(lstDpns).append(" already configured for transport zone ")
- .append(tzone).append(". Only one end point per transport Zone per Dpn is allowed.")
- .toString());
+ "DPN's " + lstDpns + " already configured for transport zone " +
+ tzone + ". Only one end point per transport Zone per Dpn is allowed.");
}
if (schema.getTunnelType().equals(TunnelTypeGre.class)){
validateForSingleGreTep(validSchema.getSchemaName(), getDpnIdList(validSchema.getDpnIds()), existingSchemas);
List<BigInteger> lstConflictingDpns = new ArrayList<>(getDpnIdList(existingSchema.getDpnIds()));
lstConflictingDpns.retainAll(emptyIfNull(lstDpnsForAdd));
if (!lstConflictingDpns.isEmpty()) {
- String errMsg = new StringBuilder("DPN's ").append(lstConflictingDpns)
- .append(" already configured with GRE TEP. Mutiple GRE TEP's on a single DPN are not allowed.")
- .toString();
+ String errMsg = "DPN's " + lstConflictingDpns +
+ " already configured with GRE TEP. Mutiple GRE TEP's on a single DPN are not allowed.";
Preconditions.checkArgument(false, errMsg);
}
}
if (gatewayIp != null) {
String strGatewayIp = String.valueOf(gatewayIp.getValue());
if (!strGatewayIp.equals(ITMConstants.DUMMY_IP_ADDRESS) && !subnetUtils.getInfo().isInRange(strGatewayIp)) {
- Preconditions.checkArgument(false, new StringBuilder("Gateway IP address ").append(strGatewayIp)
- .append(" is not in subnet range ").append(subnetCidr).toString());
+ Preconditions.checkArgument(false, "Gateway IP address " + strGatewayIp +
+ " is not in subnet range " + subnetCidr);
}
}
ItmUtils.getExcludeIpAddresses(schema.getExcludeIpFilter(), subnetUtils.getInfo());
tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
} else {
tunnelType = StringUtils.upperCase(tunnelType);
- String error = new StringBuilder("Invalid tunnel type. Valid values: ")
- .append(ITMConstants.TUNNEL_TYPE_VXLAN).append(" | ").append(ITMConstants.TUNNEL_TYPE_GRE)
- .toString();
+ String error = "Invalid tunnel type. Valid values: " +
+ ITMConstants.TUNNEL_TYPE_VXLAN + " | " + ITMConstants.TUNNEL_TYPE_GRE;
Preconditions.checkArgument(ITMConstants.TUNNEL_TYPE_VXLAN.equals(tunnelType)
|| ITMConstants.TUNNEL_TYPE_GRE.equals(tunnelType), error);
}
String strStartIp = StringUtils.trim(arrIpRange[0]);
String strEndIp = StringUtils.trim(arrIpRange[1]);
Preconditions.checkArgument(InetAddresses.isInetAddress(strStartIp),
- new StringBuilder("Invalid exclude IP filter: invalid IP address value ").append(strStartIp)
- .toString());
+ "Invalid exclude IP filter: invalid IP address value " + strStartIp);
Preconditions.checkArgument(InetAddresses.isInetAddress(strEndIp),
- new StringBuilder("Invalid exclude IP filter: invalid IP address value ").append(strEndIp)
- .toString());
+ "Invalid exclude IP filter: invalid IP address value " + strEndIp);
Preconditions.checkArgument(subnetInfo.isInRange(strStartIp),
- new StringBuilder("Invalid exclude IP filter: IP address [").append(strStartIp)
- .append("] not in subnet range ").append(subnetInfo.getCidrSignature()).toString());
+ "Invalid exclude IP filter: IP address [" + strStartIp +
+ "] not in subnet range " + subnetInfo.getCidrSignature());
Preconditions.checkArgument(subnetInfo.isInRange(strEndIp),
- new StringBuilder("Invalid exclude IP filter: IP address [").append(strEndIp)
- .append("] not in subnet range ").append(subnetInfo.getCidrSignature()).toString());
+ "Invalid exclude IP filter: IP address [" + strEndIp +
+ "] not in subnet range " + subnetInfo.getCidrSignature());
int startIp = subnetInfo.asInteger(strStartIp);
int endIp = subnetInfo.asInteger(strEndIp);
Preconditions.checkArgument(startIp < endIp,
- new StringBuilder("Invalid exclude IP filter: Invalid range [").append(ip).append("] ")
- .toString());
+ "Invalid exclude IP filter: Invalid range [" + ip + "] ");
for (int i = startIp; i <= endIp; i++) {
String ipAddress = ipFormat(toIpArray(i));
validateAndAddIpAddressToList(subnetInfo, lstIpAddress, ipAddress);
String ipAddress) {
String ip = StringUtils.trim(ipAddress);
Preconditions.checkArgument(InetAddresses.isInetAddress(ip),
- new StringBuilder("Invalid exclude IP filter: invalid IP address value ").append(ip).toString());
+ "Invalid exclude IP filter: invalid IP address value " + ip);
Preconditions.checkArgument(subnetInfo.isInRange(ip),
- new StringBuilder("Invalid exclude IP filter: IP address [").append(ip).append("] not in subnet range ")
- .append(subnetInfo.getCidrSignature()).toString());
+ "Invalid exclude IP filter: IP address [" + ip + "] not in subnet range " +
+ subnetInfo.getCidrSignature());
lstIpAddress.add(new IpAddress(ip.toCharArray()));
}
private static int[] toIpArray(int val) {
if ((lstDpnsForAdd == null || lstDpnsForAdd.isEmpty())
&& (lstDpnsForDelete == null || lstDpnsForDelete.isEmpty())) {
Preconditions.checkArgument(false,
- new StringBuilder("DPN ID list for add | delete is null or empty in schema ").append(schemaName)
- .toString());
+ "DPN ID list for add | delete is null or empty in schema " + schemaName);
}
VtepConfigSchema schema = itmProvider.getVtepConfigSchema(schemaName);
if (schema == null) {
- Preconditions.checkArgument(false, new StringBuilder("Specified VTEP Schema [").append(schemaName)
- .append("] doesn't exists!").toString());
+ Preconditions.checkArgument(false, "Specified VTEP Schema [" + schemaName +
+ "] doesn't exists!");
}
List<BigInteger> existingDpnIds = getDpnIdList(schema.getDpnIds());
if (isNotEmpty(lstDpnsForAdd)) {
List<BigInteger> lstAlreadyExistingDpns = new ArrayList<>(existingDpnIds);
lstAlreadyExistingDpns.retainAll(lstDpnsForAdd);
Preconditions.checkArgument(lstAlreadyExistingDpns.isEmpty(),
- new StringBuilder("DPN ID's ").append(lstAlreadyExistingDpns)
- .append(" already exists in VTEP schema [").append(schemaName).append("]").toString());
+ "DPN ID's " + lstAlreadyExistingDpns +
+ " already exists in VTEP schema [" + schemaName + "]");
// }
if (schema.getTunnelType().equals(TunnelTypeGre.class)) {
validateForSingleGreTep(schema.getSchemaName(), lstDpnsForAdd, itmProvider.getAllVtepConfigSchemas());
}
if (isNotEmpty(lstDpnsForDelete)) {
if (existingDpnIds == null || existingDpnIds.isEmpty()) {
- StringBuilder builder = new StringBuilder("DPN ID's ").append(lstDpnsForDelete)
- .append(" specified for delete from VTEP schema [").append(schemaName)
- .append("] are not configured in the schema.");
- Preconditions.checkArgument(false, builder.toString());
+ String builder = "DPN ID's " + lstDpnsForDelete +
+ " specified for delete from VTEP schema [" + schemaName +
+ "] are not configured in the schema.";
+ Preconditions.checkArgument(false, builder);
} else if (!existingDpnIds.containsAll(lstDpnsForDelete)) {
List<BigInteger> lstConflictingDpns = new ArrayList<>(lstDpnsForDelete);
lstConflictingDpns.removeAll(existingDpnIds);
- StringBuilder builder = new StringBuilder("DPN ID's ").append(lstConflictingDpns)
- .append(" specified for delete from VTEP schema [").append(schemaName)
- .append("] are not configured in the schema.");
- Preconditions.checkArgument(false, builder.toString());
+ String builder = "DPN ID's " + lstConflictingDpns +
+ " specified for delete from VTEP schema [" + schemaName +
+ "] are not configured in the schema.";
+ Preconditions.checkArgument(false, builder);
}
}
return schema;
return (subnet == null) ? StringUtils.EMPTY : String.valueOf(subnet.getValue());
}
public static <T> List<T> emptyIfNull(List<T> list) {
- return (list == null) ? Collections.<T> emptyList() : list;
+ return (list == null) ? Collections.emptyList() : list;
}
public static <T> boolean isEmpty(Collection<T> collection) {
return (collection == null || collection.isEmpty()) ? true : false;
}
public static List<BigInteger> getDpnIdList( List<DpnIds> dpnIds ) {
- List<BigInteger> dpnList = new ArrayList<BigInteger>() ;
+ List<BigInteger> dpnList = new ArrayList<>() ;
for( DpnIds dpn : dpnIds) {
dpnList.add(dpn.getDPN()) ;
}
}
public static List<DpnIds> getDpnIdsListFromBigInt( List<BigInteger> dpnIds) {
- List<DpnIds> dpnIdList = new ArrayList<DpnIds>() ;
+ List<DpnIds> dpnIdList = new ArrayList<>() ;
DpnIdsBuilder builder = new DpnIdsBuilder() ;
for( BigInteger dpnId : dpnIds) {
dpnIdList.add(builder.setKey(new DpnIdsKey(dpnId)).setDPN(dpnId).build() );
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> id = idBuilder.build();
return id;
}
- public static Boolean readMonitoringStateFromDS(DataBroker dataBroker) {
+ public static Boolean readMonitoringStateFromCache(DataBroker dataBroker) {
InstanceIdentifier<TunnelMonitorParams> iid = InstanceIdentifier.create(TunnelMonitorParams.class);
- Optional<TunnelMonitorParams> TunnelMonitorParamsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
- iid, dataBroker);
- if(TunnelMonitorParamsOptional.isPresent())
- return TunnelMonitorParamsOptional.get().isEnabled();
- return null;
+ TunnelMonitorParams tunnelMonitorParams = (TunnelMonitorParams) DataStoreCache.get(ITMConstants.ITM_MONIRORING_PARAMS_CACHE_NAME,iid,"MonitorParams",dataBroker,true);
+ if(tunnelMonitorParams!=null)
+ return tunnelMonitorParams.isEnabled();
+ else
+ return ITMConstants.DEFAULT_MONITOR_ENABLED;
}
- public static Integer readMonitorIntervalfromDS(DataBroker dataBroker) {
+ public static Integer readMonitorIntervalfromCache(DataBroker dataBroker) {
InstanceIdentifier<TunnelMonitorInterval> iid = InstanceIdentifier.create(TunnelMonitorInterval.class);
- Optional<TunnelMonitorInterval> tunnelMonitorIOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, iid, dataBroker);
- if(tunnelMonitorIOptional.isPresent())
- return tunnelMonitorIOptional.get().getInterval();
+ TunnelMonitorInterval tunnelMonitorIOptional = (TunnelMonitorInterval)DataStoreCache.get(ITMConstants.ITM_MONIRORING_PARAMS_CACHE_NAME,iid,"Interval",dataBroker,true);
+ if(tunnelMonitorIOptional!=null)
+ return tunnelMonitorIOptional.getInterval();
return null;
}
public static Integer determineMonitorInterval(DataBroker dataBroker) {
- Integer monitorInterval = ItmUtils.readMonitorIntervalfromDS(dataBroker);
+ Integer monitorInterval = ItmUtils.readMonitorIntervalfromCache(dataBroker);
LOG.debug("determineMonitorInterval: monitorInterval from DS = {}", monitorInterval);
if(monitorInterval==null){
- Class<? extends TunnelMonitoringTypeBase> monitoringProtocol = determineMonitorProtocol(dataBroker);
- if(monitoringProtocol.getName().contains("Bfd"))
+ Class<? extends TunnelMonitoringTypeBase> monitorProtocol = determineMonitorProtocol(dataBroker);
+ if(monitorProtocol.isAssignableFrom(TunnelMonitoringTypeBfd.class))
monitorInterval = ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL;
else
monitorInterval = ITMConstants.DEFAULT_MONITOR_INTERVAL;
}
LOG.debug("determineMonitorInterval: monitorInterval = {}", monitorInterval);
+ InstanceIdentifier<TunnelMonitorInterval> iid = InstanceIdentifier.builder(TunnelMonitorInterval.class).build();
+ TunnelMonitorInterval intervalBuilder = new TunnelMonitorIntervalBuilder().setInterval(monitorInterval).build();
+ ItmUtils.asyncUpdate(LogicalDatastoreType.OPERATIONAL,iid, intervalBuilder, dataBroker, ItmUtils.DEFAULT_CALLBACK);
return monitorInterval;
}
public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker, Boolean hwVtepsExist) {
- List<String> tunnels = new ArrayList<String>();
+ List<String> tunnels = new ArrayList<>();
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).
child(TransportZone.class, new TransportZoneKey(tzone)).build();
Optional<TransportZone> tZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
}
public static List<String> getInternalTunnelsofTzone(String tzone, DataBroker dataBroker) {
- List<String> tunnels = new ArrayList<String>();
+ List<String> tunnels = new ArrayList<>();
LOG.trace("Getting internal tunnels of {}",tzone);
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).
child(TransportZone.class, new TransportZoneKey(tzone)).build();
else if( tunType.equals(TunnelTypeGre.class) )
tunnelType = ITMConstants.TUNNEL_TYPE_GRE ;
else if (tunnelType.equals(TunnelTypeMplsOverGre.class))
- tunnelType = ITMConstants.TUNNEL_TYPE_MPLS_OVER_GRE;
+ tunnelType = ITMConstants.TUNNEL_TYPE_MPLSoGRE;
return tunnelType ;
}
return result;
}
- public static Class<? extends TunnelMonitoringTypeBase> readMonitoringProtocolFromDS(DataBroker dataBroker) {
+ public static Class<? extends TunnelMonitoringTypeBase> readMonitoringProtocolFromCache(DataBroker dataBroker) {
InstanceIdentifier<TunnelMonitorParams> iid = InstanceIdentifier.create(TunnelMonitorParams.class);
- Optional<TunnelMonitorParams> TunnelMonitorParamsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
- iid, dataBroker);
- if(TunnelMonitorParamsOptional.isPresent())
- return TunnelMonitorParamsOptional.get().getMonitorProtocol();
+ TunnelMonitorParams tunnelMonitorParams = (TunnelMonitorParams) DataStoreCache.get(ITMConstants.ITM_MONIRORING_PARAMS_CACHE_NAME,iid,"MonitorParams",dataBroker,true);
+ if(tunnelMonitorParams!=null)
+ return tunnelMonitorParams.getMonitorProtocol();
return null;
}
public static Class<? extends TunnelMonitoringTypeBase> determineMonitorProtocol(DataBroker dataBroker) {
- Class<? extends TunnelMonitoringTypeBase> monitoringProtocol = ItmUtils.readMonitoringProtocolFromDS(dataBroker);
+ Class<? extends TunnelMonitoringTypeBase> monitoringProtocol = ItmUtils.readMonitoringProtocolFromCache(dataBroker);
LOG.debug("determineMonitorProtocol: monitorProtocol from DS = {}", monitoringProtocol);
if(monitoringProtocol==null)
monitoringProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
LOG.debug("determineMonitorProtocol: monitorProtocol = {}", monitoringProtocol);
+ Boolean monitorState = ItmUtils.readMonitoringStateFromCache(dataBroker);
+ if(monitorState==null)
+ monitorState = true;
+ LOG.debug("determineMonitorProtocol: monitorState = {}", monitorState);
+ InstanceIdentifier<TunnelMonitorParams> iid = InstanceIdentifier.builder(TunnelMonitorParams.class).build();
+ TunnelMonitorParams protocolBuilder = new TunnelMonitorParamsBuilder().setEnabled(monitorState).setMonitorProtocol(monitoringProtocol).build();
+ ItmUtils.asyncUpdate(LogicalDatastoreType.OPERATIONAL,iid, protocolBuilder, dataBroker, ItmUtils.DEFAULT_CALLBACK);
return monitoringProtocol;
}
+
+ public static List<DcGatewayIp> getDcGatewayIpList(DataBroker broker){
+ InstanceIdentifier<DcGatewayIpList> dcGatewayIpListid = InstanceIdentifier.builder(DcGatewayIpList.class).build();
+ Optional<DcGatewayIpList> dcGatewayIpListConfig = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, dcGatewayIpListid, broker);
+ if(dcGatewayIpListConfig.isPresent()){
+ DcGatewayIpList containerList = dcGatewayIpListConfig.get();
+ if(containerList != null){
+ return (containerList.getDcGatewayIp());
+ }
+ }
+ return null;
+ }
}