use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class TransportZoneListener method createDPNTepInfoFromNotHosted.
private List<DPNTEPsInfo> createDPNTepInfoFromNotHosted(TransportZone tzNew) {
Map<BigInteger, List<TunnelEndPoints>> mapNotHostedDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> notHostedDpnTepInfo = new ArrayList<>();
String newZoneName = tzNew.getZoneName();
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(newZoneName);
Class<? extends TunnelTypeBase> tunnelType = tzNew.getTunnelType();
TepsInNotHostedTransportZone tepsInNotHostedTransportZone = getNotHostedTransportZone(newZoneName).get();
if (tepsInNotHostedTransportZone == null) {
return notHostedDpnTepInfo;
}
List<UnknownVteps> unVtepsLst = tepsInNotHostedTransportZone.getUnknownVteps();
List<Vteps> vtepsList = new ArrayList<>();
if (unVtepsLst != null && !unVtepsLst.isEmpty()) {
for (UnknownVteps vteps : unVtepsLst) {
BigInteger dpnID = vteps.getDpnId();
String port = ITMConstants.DUMMY_PORT;
int vlanID = ITMConstants.DUMMY_VLANID;
IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
IpAddress ipAddress = vteps.getIpAddress();
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapNotHostedDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
tunnelEndPointsList.add(tunnelEndPoints);
} else {
tunnelEndPointsList = new ArrayList<>();
tunnelEndPointsList.add(tunnelEndPoints);
mapNotHostedDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
Vteps newVtep = createVtepFromUnKnownVteps(dpnID, ipAddress, ITMConstants.DUMMY_PORT);
vtepsList.add(newVtep);
// Enqueue 'remove TEP from TepsNotHosted list' operation
// into DataStoreJobCoordinator
ItmTepsNotHostedRemoveWorker removeWorker = new ItmTepsNotHostedRemoveWorker(newZoneName, ipAddress, dpnID, dataBroker);
jobCoordinator.enqueueJob(newZoneName, removeWorker);
}
}
// Enqueue 'add TEP received from southbound OVSDB into ITM config DS' operation
// into DataStoreJobCoordinator
ItmTepsNotHostedMoveWorker moveWorker = new ItmTepsNotHostedMoveWorker(vtepsList, newZoneName, dataBroker);
jobCoordinator.enqueueJob(newZoneName, moveWorker);
if (mapNotHostedDPNToTunnelEndpt.size() > 0) {
for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapNotHostedDPNToTunnelEndpt.entrySet()) {
DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
notHostedDpnTepInfo.add(newDpnTepsInfo);
}
}
return notHostedDpnTepInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class TransportZoneListener method add.
@Override
public void add(@Nonnull TransportZone transportZone) {
LOG.debug("Received Transport Zone Add Event: {}", transportZone);
List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
List<HwVtep> hwVtepList = createhWVteps(transportZone);
opDpnList.addAll(getDPNTepInfoFromNotHosted(transportZone));
LOG.trace("Add: Operational dpnTepInfo - Before invoking ItmManager {}", opDpnList);
if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
LOG.trace("Add: Invoking ItmManager with DPN List {} ", opDpnList);
LOG.trace("Add: Invoking ItmManager with hwVtep List {} ", hwVtepList);
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class TransportZoneListener method update.
@Override
public void update(@Nonnull TransportZone originalTransportZone, @Nonnull TransportZone updatedTransportZone) {
LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone, updatedTransportZone);
List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
oldDpnTepsListcopy.addAll(oldDpnTepsList);
LOG.trace("oldcopy0 {}", oldDpnTepsListcopy);
List<DPNTEPsInfo> newDpnTepsListcopy = new ArrayList<>();
newDpnTepsListcopy.addAll(newDpnTepsList);
LOG.trace("newcopy0 {}", newDpnTepsListcopy);
oldDpnTepsList.removeAll(newDpnTepsListcopy);
newDpnTepsList.removeAll(oldDpnTepsListcopy);
LOG.trace("oldDpnTepsList {}", oldDpnTepsList);
LOG.trace("newDpnTepsList {}", newDpnTepsList);
LOG.trace("oldcopy {}", oldDpnTepsListcopy);
LOG.trace("newcopy {}", newDpnTepsListcopy);
LOG.trace("oldcopy Size {}", oldDpnTepsList.size());
LOG.trace("newcopy Size {}", newDpnTepsList.size());
if (!newDpnTepsList.isEmpty()) {
LOG.trace("Adding TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
}
if (!oldDpnTepsList.isEmpty()) {
LOG.trace("Removing TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
}
List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
List<HwVtep> oldHwListcopy = new ArrayList<>();
oldHwListcopy.addAll(oldHwList);
LOG.trace("oldHwListcopy0 {}", oldHwListcopy);
List<HwVtep> newHwListcopy = new ArrayList<>();
newHwListcopy.addAll(newHwList);
LOG.trace("newHwListcopy0 {}", newHwListcopy);
oldHwList.removeAll(newHwListcopy);
newHwList.removeAll(oldHwListcopy);
LOG.trace("oldHwList {}", oldHwList);
LOG.trace("newHwList {}", newHwList);
LOG.trace("oldHwListcopy {}", oldHwListcopy);
LOG.trace("newHwListcopy {}", newHwListcopy);
if (!newHwList.isEmpty()) {
LOG.trace("Adding HW TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(Collections.emptyList(), newHwList, dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
}
if (!oldHwList.isEmpty()) {
LOG.trace("Removing HW TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method deleteTunnelsInTransportZone.
private static void deleteTunnelsInTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints srcTep, List<HwVtep> cfgdhwVteps, DataBroker dataBroker, WriteTransaction writeTransaction) {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone tzone = transportZoneOptional.get();
// do we need to check tunnel type?
if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
for (Subnets sub : tzone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
// OVS-TOR-OVS
deleteTrunksOvsTor(dataBroker, dpn.getDPNID(), srcTep.getInterfaceName(), srcTep.getIpAddress(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), tzone.getTunnelType(), writeTransaction);
}
}
}
}
if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
for (HwVtep hwVtep : cfgdhwVteps) {
deleteTrunksOvsTor(dataBroker, dpn.getDPNID(), srcTep.getInterfaceName(), srcTep.getIpAddress(), hwVtep.getTopoId(), hwVtep.getNodeId(), hwVtep.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method deleteTunnels.
public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, Collection<DPNTEPsInfo> dpnTepsList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
LOG.trace(" Delete Tunnels towards DC Gateway with Ip {}", extIp);
if (dpnTepsList == null || dpnTepsList.isEmpty()) {
LOG.debug("no vtep to delete");
return Collections.emptyList();
}
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
for (DPNTEPsInfo teps : dpnTepsList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
String interfaceName = firstEndPt.getInterfaceName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, path);
LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
// Release the Ids for the trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
}
return Collections.singletonList(writeTransaction.submit());
}
Aggregations