use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path 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.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path in project genius by opendaylight.
the class InterfacemgrProvider method getPortsOnBridgeByType.
/**
* Get all termination points by type on a given DPN.
*
* @param dpnId
* Datapath Node Identifier
*
* @return If the data at the supplied path exists, returns a Map where key is interfaceType
* and value is list of termination points of given type
*/
@Override
public Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> getPortsOnBridgeByType(BigInteger dpnId) {
Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> portMap;
portMap = new ConcurrentHashMap<>();
List<TerminationPoint> ovsPorts = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
if (ovsPorts != null) {
for (TerminationPoint ovsPort : ovsPorts) {
OvsdbTerminationPointAugmentation portAug = ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (portAug != null && portAug.getInterfaceType() != null) {
portMap.computeIfAbsent(portAug.getInterfaceType(), k -> new ArrayList<>()).add(portAug);
}
}
}
return portMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path in project genius by opendaylight.
the class TepCommandHelper method buildTeps.
@SuppressWarnings("checkstyle:IllegalCatch")
public void buildTeps() {
TransportZones transportZonesBuilt = null;
TransportZone transportZone = null;
try {
LOG.debug("no of teps added {}", CHECK);
if (transportZonesHashMap != null && !transportZonesHashMap.isEmpty()) {
transportZoneArrayList = new ArrayList<>();
for (Entry<String, Map<SubnetObject, List<Vteps>>> mapEntry : transportZonesHashMap.entrySet()) {
String tz = mapEntry.getKey();
LOG.debug("transportZonesHashMap {}", tz);
subnetList = new ArrayList<>();
Map<SubnetObject, List<Vteps>> subVtepMapTemp = mapEntry.getValue();
for (Entry<SubnetObject, List<Vteps>> entry : subVtepMapTemp.entrySet()) {
SubnetObject subOb = entry.getKey();
LOG.debug("subnets {}", subOb.get_prefix());
List<Vteps> vtepList = entry.getValue();
Subnets subnet = new SubnetsBuilder().setGatewayIp(subOb.get_gatewayIp()).setKey(subOb.get_key()).setPrefix(subOb.get_prefix()).setVlanId(subOb.get_vlanId()).setVteps(vtepList).build();
subnetList.add(subnet);
LOG.debug("vteps {}", vtepList);
}
InstanceIdentifier<TransportZone> transportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tz)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, transportZonePath, dataBroker);
LOG.debug("read container from DS");
if (transportZoneOptional.isPresent()) {
TransportZone tzoneFromDs = transportZoneOptional.get();
LOG.debug("read tzone container {}", tzoneFromDs);
if (tzoneFromDs.getTunnelType() == null || tzoneFromDs.getTunnelType().equals(TunnelTypeVxlan.class)) {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
} else if (tzoneFromDs.getTunnelType().equals(TunnelTypeGre.class)) {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeGre.class).setSubnets(subnetList).setZoneName(tz).build();
}
} else {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
}
LOG.debug("tzone object {}", transportZone);
transportZoneArrayList.add(transportZone);
}
transportZonesBuilt = new TransportZonesBuilder().setTransportZone(transportZoneArrayList).build();
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
LOG.debug("InstanceIdentifier {}", path);
ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, transportZonesBuilt, dataBroker, ItmUtils.DEFAULT_CALLBACK);
LOG.debug("wrote to Config DS {}", transportZonesBuilt);
transportZonesHashMap.clear();
transportZoneArrayList.clear();
subnetList.clear();
LOG.debug("Everything cleared");
} else {
LOG.debug("NO vteps were configured");
}
} catch (RuntimeException e) {
LOG.error("Error building TEPs", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path in project genius by opendaylight.
the class TepCommandHelper method configureTunnelMonitorInterval.
public void configureTunnelMonitorInterval(int interval) {
InstanceIdentifier<TunnelMonitorInterval> path = InstanceIdentifier.builder(TunnelMonitorInterval.class).build();
Optional<TunnelMonitorInterval> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (!storedTunnelMonitor.isPresent() || storedTunnelMonitor.get().getInterval() != interval) {
TunnelMonitorInterval tunnelMonitor = new TunnelMonitorIntervalBuilder().setInterval(interval).build();
ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tunnelMonitor, dataBroker, ItmUtils.DEFAULT_CALLBACK);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path in project genius by opendaylight.
the class DpnTepStateCache method added.
@Override
protected void added(InstanceIdentifier<DpnsTeps> path, DpnsTeps dpnsTeps) {
for (RemoteDpns remoteDpns : dpnsTeps.getRemoteDpns()) {
final String dpn = getDpnId(dpnsTeps.getSourceDpnId(), remoteDpns.getDestinationDpnId());
DpnTepInterfaceInfo value = new DpnTepInterfaceInfoBuilder().setTunnelName(remoteDpns.getTunnelName()).setGroupId(dpnsTeps.getGroupId()).setIsMonitoringEnabled(remoteDpns.isMonitoringEnabled()).setIsMonitoringEnabled(remoteDpns.isInternal()).setTunnelType(dpnsTeps.getTunnelType()).build();
dpnTepInterfaceMap.put(dpn, value);
addTunnelEndPointInfoToCache(remoteDpns.getTunnelName(), dpnsTeps.getSourceDpnId().toString(), remoteDpns.getDestinationDpnId().toString());
}
}
Aggregations