use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class SouthboundUtils method addTerminationPoint.
private void addTerminationPoint(InstanceIdentifier<?> bridgeIid, String portName, int vlanId, Class<? extends InterfaceTypeBase> type, Map<String, String> options, IfTunnel ifTunnel) {
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(portName);
if (type != null) {
tpAugmentationBuilder.setInterfaceType(type);
}
if (options != null) {
List<Options> optionsList = new ArrayList<>();
for (Map.Entry<String, String> entry : options.entrySet()) {
OptionsBuilder optionsBuilder = new OptionsBuilder();
optionsBuilder.setKey(new OptionsKey(entry.getKey()));
optionsBuilder.setOption(entry.getKey());
optionsBuilder.setValue(entry.getValue());
optionsList.add(optionsBuilder.build());
}
tpAugmentationBuilder.setOptions(optionsList);
}
if (vlanId != 0) {
tpAugmentationBuilder.setVlanMode(OvsdbPortInterfaceAttributes.VlanMode.Access);
tpAugmentationBuilder.setVlanTag(new VlanId(vlanId));
}
if (bfdMonitoringEnabled(ifTunnel)) {
if (isOfTunnel(ifTunnel)) {
LOG.warn("BFD Monitoring not supported for OFTunnels");
} else {
List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
tpAugmentationBuilder.setInterfaceBfd(bfdParams);
}
}
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
batchingUtils.write(tpIid, tpBuilder.build(), BatchingUtils.EntityType.TOPOLOGY_CONFIG);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class SouthboundUtils method updateBfdParamtersForTerminationPoint.
// Update is allowed only for tunnel monitoring attributes
public static void updateBfdParamtersForTerminationPoint(InstanceIdentifier<?> bridgeIid, IfTunnel ifTunnel, String portName, WriteTransaction transaction) {
InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
if (isOfTunnel(ifTunnel)) {
LOG.warn("BFD monitoring not supported for OFTunnels. Skipping BFD parameters for {}", portName);
return;
}
LOG.debug("update bfd parameters for interface {}", tpIid);
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
tpAugmentationBuilder.setInterfaceBfd(bfdParams);
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
transaction.merge(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build(), true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class InterfaceManagerTestUtil method buildTunnelInterface.
static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, String remoteIpStr, String localIpStr) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
IpAddress remoteIp = new IpAddress(Ipv4Address.getDefaultInstance(remoteIpStr));
IpAddress localIp = new IpAddress(Ipv4Address.getDefaultInstance(localIpStr));
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(localIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(true).setMonitorEnabled(false).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class IfmCLIUtil method showVxlanOutput.
static void showVxlanOutput(Interface iface, InterfaceInfo interfaceInfo, CommandSession session) {
StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb);
session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT_LINE1, iface.getName(), iface.getDescription() == null ? UNSET : iface.getDescription()));
sb.setLength(0);
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT, new String(ifTunnel.getTunnelSource().getValue()), new String(ifTunnel.getTunnelDestination().getValue()), ifTunnel.getTunnelGateway() == null ? UNSET : new String(ifTunnel.getTunnelGateway().getValue()), interfaceInfo == null ? InterfaceInfo.InterfaceAdminState.DISABLED : interfaceInfo.getAdminState()));
sb.setLength(0);
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT + "\n", interfaceInfo == null ? InterfaceOpState.DOWN : interfaceInfo.getOpState(), String.format("%s/%s", parentRefs.getDatapathNodeIdentifier(), iface.getName()), interfaceInfo == null ? UNSET : interfaceInfo.getInterfaceTag(), ""));
fmt.close();
}
Aggregations