@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public static String generateOfTunnelName(Uint64 dpId, IfTunnel ifTunnel) {
- String sourceKey = ifTunnel.getTunnelSource().stringValue();
- String remoteKey = ifTunnel.getTunnelDestination().stringValue();
+ final String sourceKey;
if (ifTunnel.isTunnelSourceIpFlow() != null) {
sourceKey = "flow";
+ } else {
+ sourceKey = ifTunnel.getTunnelSource().stringValue();
}
+ final String remoteKey;
if (ifTunnel.isTunnelRemoteIpFlow() != null) {
remoteKey = "flow";
+ } else {
+ remoteKey = ifTunnel.getTunnelDestination().stringValue();
}
String tunnelNameKey = dpId.toString() + sourceKey + remoteKey;
String uuidStr = UUID.nameUUIDFromBytes(tunnelNameKey.getBytes()).toString().substring(0, 12).replace("-", "");
- return String.format("%s%s", "tun", uuidStr);
+ return "tun" + uuidStr;
}
public static boolean isOfTunnel(IfTunnel ifTunnel) {
NwConstants.DEFAULT_EGRESS_SERVICE_INDEX);
BoundServices
serviceInfo =
- getBoundServices(String.format("%s.%s", "default", interfaceName),
+ getBoundServices(defaultInterfaceName(interfaceName),
ServiceIndex.getIndex(NwConstants.DEFAULT_EGRESS_SERVICE_NAME,
NwConstants.DEFAULT_EGRESS_SERVICE_INDEX),
priority, NwConstants.EGRESS_DISPATCHER_TABLE_COOKIE, instructions);
NwConstants.DEFAULT_EGRESS_SERVICE_INDEX);
BoundServices
serviceInfo =
- getBoundServices(String.format("%s.%s", "default", interfaceName),
+ getBoundServices(defaultInterfaceName(interfaceName),
ServiceIndex.getIndex(NwConstants.DEFAULT_EGRESS_SERVICE_NAME,
NwConstants.DEFAULT_EGRESS_SERVICE_INDEX),
priority, NwConstants.EGRESS_DISPATCHER_TABLE_COOKIE, instructions);
IfmUtil.bindService(tx, interfaceName, serviceInfo, ServiceModeEgress.class);
}
+ private static String defaultInterfaceName(final String interfaceName) {
+ return "default." + interfaceName;
+ }
+
public static void removeIngressFlow(String interfaceName, Uint64 dpId, ManagedNewTransactionRunner txRunner,
List<ListenableFuture<Void>> futures) {
if (dpId == null) {
}
public static String getFlowRef(short tableId, Uint64 dpnId, String infName) {
- return String.format("%d:%s:%s", tableId, dpnId, infName);
+ return tableId + ":" + dpnId + ":" + infName;
}
private static String getFlowRef(Uint64 dpnId, short tableId, String iface, short currentServiceIndex) {
public class ItmExternalTunnelAddWorker {
private static final Logger LOG = LoggerFactory.getLogger(ItmExternalTunnelAddWorker.class);
+ private static final IpAddress GATEWAY_IP_OBJ = IpAddressBuilder.getDefaultInstance("0.0.0.0");
private final ItmConfig itmConfig;
private final DPNTEPsInfoCache dpnTEPsInfoCache;
+ " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName,
interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress);
Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName,
- String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"),
+ trunkInterface(ItmUtils.convertTunnelTypetoString(tunType)),
true, tunType, firstEndPt.getIpAddress(), extIp, false, false,
ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
+ "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
dstIp, gwyIpAddress);
Interface hwTunnelIf = ItmUtils.buildHwTunnelInterface(tunnelIfName,
- String.format("%s %s", tunType.getName(), "Trunk Interface"), true, topoId, srcNodeid, tunType, srcIp,
+ trunkInterface(tunType), true, topoId, srcNodeid, tunType, srcIp,
dstIp, gwyIpAddress, monitorEnabled, monitorProtocol, monitorInterval);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class)
.child(Interface.class, new InterfaceKey(tunnelIfName)).build();
Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval,
Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
TypedWriteTransaction<Configuration> tx) {
- IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
- IpAddress gwyIpAddress = gatewayIpObj;
+
+ IpAddress gwyIpAddress = GATEWAY_IP_OBJ;
String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
String tunTypeStr = tunType.getName();
+ "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
dstIp, gwyIpAddress);
Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName,
- String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp,
+ trunkInterface(tunType), true, tunType, srcIp, dstIp,
false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class,
new InterfaceKey(tunnelIfName)).build();
return true;
}
+ private static String trunkInterface(Class<? extends TunnelTypeBase> tunType) {
+ return trunkInterface(tunType.getName());
+ }
+
+ private static String trunkInterface(String tunType) {
+ return tunType + " Trunk Interface";
+ }
+
@SuppressFBWarnings("RV_CHECK_FOR_POSITIVE_INDEXOF")
static String getExternalTunnelKey(String nodeid) {
final int index = nodeid.indexOf("physicalswitch");
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(srcte, itmCfg);
Boolean isMonitorEnabled = !tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) && isTunnelMonitoringEnabled;
Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName,
- String.format("%s %s",ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"),
+ trunkInterfaceDecription(ItmUtils.convertTunnelTypetoString(tunType)),
true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), true,
isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
ItmUtils.ITM_CACHE.addInterface(iface);
}
+ private static String trunkInterfaceDecription(String type) {
+ return type + " Trunk Interface";
+ }
+
private static void createInternalTunnel(TypedWriteTransaction<Configuration> tx, Uint64 srcDpnId,
Uint64 dstDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName) {
InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class)
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(srcte, itmCfg);
Boolean isMonitorEnabled = !tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) && isTunnelMonitoringEnabled;
Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName,
- String.format("%s %s",ItmUtils.convertTunnelTypetoString(srcte.getTunnelType()), "Trunk Interface"),
+ trunkInterfaceDecription(ItmUtils.convertTunnelTypetoString(srcte.getTunnelType())),
true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), true,
isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
LOG.debug("Trunk Interface builder - {} ", iface);
public final class ItmUtils {
private static final Logger LOG = LoggerFactory.getLogger(ItmUtils.class);
-
+ private static final String ITM_LLDP_FLOW_ENTRY = "ITM Flow Entry ::" + ITMConstants.LLDP_SERVICE_ID;
private static final String TUNNEL = "tun";
private static final IpPrefix DUMMY_IP_PREFIX = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
private static final long DEFAULT_MONITORING_INTERVAL = 100L;
//ITM cleanup:portname and vlanId are removed, causes change in generated
//interface name: This has upgrade impact
public static String getInterfaceName(final Uint64 datapathid, final String portName, final Integer vlanId) {
- return String.format("%s:%s:%s", datapathid, portName, vlanId);
+ return datapathid + ":" + portName + ":" + vlanId;
}
public static String getTrunkInterfaceName(String parentInterfaceName,
} else {
tunnelTypeStr = ITMConstants.TUNNEL_TYPE_VXLAN;
}
- String trunkInterfaceName = String.format("%s:%s:%s:%s", parentInterfaceName, localHostName,
- remoteHostName, tunnelTypeStr);
+ String trunkInterfaceName = trunkInterfaceName(parentInterfaceName, localHostName, remoteHostName,
+ tunnelTypeStr);
LOG.trace("trunk interface name is {}", trunkInterfaceName);
- trunkInterfaceName = String.format("%s%s", TUNNEL, getUniqueIdString(trunkInterfaceName));
- return trunkInterfaceName;
+ return TUNNEL + getUniqueIdString(trunkInterfaceName);
}
public static void releaseIdForTrunkInterfaceName(String parentInterfaceName,
} else {
tunnelTypeStr = ITMConstants.TUNNEL_TYPE_VXLAN;
}
- String trunkInterfaceName = String.format("%s:%s:%s:%s", parentInterfaceName, localHostName,
- remoteHostName, tunnelTypeStr);
- LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName(parentInterfaceName, localHostName,
+ remoteHostName, tunnelTypeStr));
+ }
+ }
+
+ private static String trunkInterfaceName(String parentInterfaceName, String localHostName, String remoteHostName,
+ String tunnelType) {
+ return parentInterfaceName + ":" + localHostName + ":" + remoteHostName + ":" + tunnelType;
}
public static String getLogicalTunnelGroupName(Uint64 srcDpnId, Uint64 destDpnId) {
- String tunnelTypeStr = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
- String groupName = String.format("%s:%s:%s", srcDpnId.toString(), destDpnId.toString(), tunnelTypeStr);
+ String groupName = srcDpnId + ":" + destDpnId + ":" + ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
LOG.trace("logical tunnel group name is {}", groupName);
- groupName = String.format("%s%s", TUNNEL, getUniqueIdString(groupName));
- return groupName;
+ return TUNNEL + getUniqueIdString(groupName);
}
public static InetAddress getInetAddressFromIpAddress(IpAddress ip) {
FlowEntity terminatingServiceTableFlowEntity = MDSALUtil
.buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE,
getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
- 5, String.format("%s:%d","ITM Flow Entry :", ITMConstants.LLDP_SERVICE_ID), 0, 0,
+ 5, ITM_LLDP_FLOW_ENTRY, 0, 0,
COOKIE_ITM_LLD, mkMatches, mkInstructions);
mdsalManager.addFlow(tx, terminatingServiceTableFlowEntity);
} catch (Exception e) {
}
public static String getHwParentIf(String topoId, String srcNodeid) {
- return String.format("%s:%s", topoId, srcNodeid);
+ return topoId + ":" + srcNodeid;
}
/**
}
public static String generateOfPortName(Uint64 dpId, String tunnelType) {
- String trunkInterfaceName = String.format("%s:%s", dpId.toString(), tunnelType);
- String uuidStr = UUID.nameUUIDFromBytes(trunkInterfaceName.getBytes(StandardCharsets.UTF_8)).toString()
+ String trunkInterfaceName = dpId + ":" + tunnelType;
+ return "of" + UUID.nameUUIDFromBytes(trunkInterfaceName.getBytes(StandardCharsets.UTF_8)).toString()
.substring(0, 12).replace("-", "");
- return String.format("%s%s", "of", uuidStr);
}
}
Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE,
getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, serviceId), 5,
- String.format("%s:%d", "ITM Flow Entry ", serviceId), 0, 0,
+ "ITM Flow Entry :" + serviceId, 0, 0,
Uint64.fromLongBits(ITMConstants.COOKIE_ITM.longValue() + serviceId.toJava()), mkMatches,
input.getInstruction());