use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmUtils method constructVtepConfigSchema.
public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId, String subnetMask, String gatewayIp, String transportZone, String tunnelType, List<BigInteger> dpnIds, String excludeIpFilter) {
IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
Class<? extends TunnelTypeBase> tunType;
if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
tunType = TunnelTypeVxlan.class;
} else {
tunType = TunnelTypeGre.class;
}
VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName).setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj).setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds)).setExcludeIpFilter(excludeIpFilter);
return schemaBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method wireUp.
// for tunnels from OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "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, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true);
ItmUtils.ITM_CACHE.addInterface(extTunnelIf);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase 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.TunnelTypeBase 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.TunnelTypeBase in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getTunnelType.
@Override
public ListenableFuture<GetTunnelTypeOutput> getTunnelType(GetTunnelTypeInput input) {
String interfaceName = input.getIntfName();
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
Interface interfaceInfo = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo == null) {
throw new IllegalArgumentException(String.format("Retrieval of Tunnel Type for the key {%s} failed due to missing Interface in Config DataStore", interfaceName));
}
if (Tunnel.class.equals(interfaceInfo.getType())) {
IfTunnel tnl = interfaceInfo.getAugmentation(IfTunnel.class);
Class<? extends TunnelTypeBase> tunType = tnl.getTunnelInterfaceType();
return Futures.immediateFuture(new GetTunnelTypeOutputBuilder().setTunnelType(tunType).build());
} else {
throw new IllegalArgumentException("Retrieval of interface type failed for key: " + interfaceName);
}
}
Aggregations