use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions 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.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method buildTunnelsToExternalEndPoint.
public List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(Collection<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
if (null != cfgDpnList) {
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
for (DPNTEPsInfo teps : cfgDpnList) {
// CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
String interfaceName = firstEndPt.getInterfaceName();
String tunTypeStr = tunType.getName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunTypeStr);
char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue();
boolean useOfTunnel = ItmUtils.falseIfNull(firstEndPt.isOptionOfTunnel());
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(firstEndPt, itmConfig);
String subnetMaskStr = String.valueOf(subnetMaskArray);
SubnetUtils utils = new SubnetUtils(subnetMaskStr);
String dcGwyIpStr = String.valueOf(extIp.getValue());
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = utils.getInfo().isInRange(dcGwyIpStr) ? gatewayIpObj : firstEndPt.getGwIpAddress();
LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}," + " 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"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false, false, ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
// update external_tunnel_list ds
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(), String.valueOf(extIp.getValue()), tunType, trunkInterfaceName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
}
return Collections.singletonList(transaction.submit());
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.
the class ItmInternalTunnelAddWorker method createTunnelInterface.
private void createTunnelInterface(TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName, String parentInterfaceName) {
String gateway = srcte.getIpAddress().getIpv4Address() != null ? "0.0.0.0" : "::";
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance(gateway);
IpAddress gwyIpAddress = srcte.getSubnetMask().equals(dstte.getSubnetMask()) ? gatewayIpObj : srcte.getGwIpAddress();
LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", trunkInterfaceName, srcte.getInterfaceName(), srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress);
boolean useOfTunnel = ItmUtils.falseIfNull(srcte.isOptionOfTunnel());
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(srcte, itmCfg);
Boolean isMonitorEnabled = tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) ? false : isTunnelMonitoringEnabled;
Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, srcte.getVLANID(), true, isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
ITMBatchingUtils.update(trunkIdentifier, iface, ITMBatchingUtils.EntityType.DEFAULT_CONFIG);
ItmUtils.ITM_CACHE.addInterface(iface);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.
the class ItmUtils method buildTunnelInterface.
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName, List<TunnelOptions> tunnelOptions) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).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);
if (monitorInterval != null) {
monitoringInterval = monitorInterval.longValue();
}
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).setTunnelOptions(tunnelOptions).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions in project genius by opendaylight.
the class SouthboundUtils method addTunnelPortToBridge.
private void addTunnelPortToBridge(IfTunnel ifTunnel, InstanceIdentifier<?> bridgeIid, Interface iface, String portName) {
LOG.debug("adding tunnel port {} to bridge {}", portName, bridgeIid);
Class<? extends InterfaceTypeBase> type = TUNNEL_TYPE_MAP.get(ifTunnel.getTunnelInterfaceType());
if (type == null) {
LOG.warn("Unknown Tunnel Type obtained while creating interface: {}", iface);
return;
}
int vlanId = 0;
IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
vlanId = ifL2vlan.getVlanId().getValue();
}
Map<String, String> options = Maps.newHashMap();
// Options common to any kind of tunnel
if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow())) {
options.put(TUNNEL_OPTIONS_LOCAL_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress localIp = ifTunnel.getTunnelSource();
options.put(TUNNEL_OPTIONS_LOCAL_IP, String.valueOf(localIp.getValue()));
}
if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow())) {
options.put(TUNNEL_OPTIONS_REMOTE_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress remoteIp = ifTunnel.getTunnelDestination();
options.put(TUNNEL_OPTIONS_REMOTE_IP, String.valueOf(remoteIp.getValue()));
}
// Specific options for each type of tunnel
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeMplsOverGre.class)) {
options.put(TUNNEL_OPTIONS_PKT_TYPE, TUNNEL_OPTIONS_VALUE_LEGACY_L3);
} else {
options.put(TUNNEL_OPTIONS_KEY, TUNNEL_OPTIONS_VALUE_FLOW);
}
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlanGpe.class)) {
options.put(TUNNEL_OPTIONS_EXTS, TUNNEL_OPTIONS_VALUE_GPE);
options.put(TUNNEL_OPTIONS_NSI, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSP, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC1, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC2, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC3, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC4, TUNNEL_OPTIONS_VALUE_FLOW);
// VxLAN-GPE interfaces will not use the default UDP port to avoid
// problems with other meshes
options.put(TUNNEL_OPTIONS_DESTINATION_PORT, TUNNEL_OPTIONS_VALUE_GPE_DESTINATION_PORT);
}
if (ifTunnel.getTunnelOptions() != null) {
for (TunnelOptions tunOpt : ifTunnel.getTunnelOptions()) {
options.putIfAbsent(tunOpt.getTunnelOption(), tunOpt.getValue());
}
}
addTerminationPoint(bridgeIid, portName, vlanId, type, options, ifTunnel);
}
Aggregations