use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class TransportZoneListener method createhWVteps.
private List<HwVtep> createhWVteps(TransportZone transportZone) {
List<HwVtep> hwVtepsList = new ArrayList<>();
String zoneName = transportZone.getZoneName();
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", zoneName);
@Nullable Map<DeviceVtepsKey, DeviceVteps> deviceVtepsList = transportZone.getDeviceVteps();
if (deviceVtepsList != null) {
for (DeviceVteps vteps : deviceVtepsList.values()) {
String topologyId = vteps.getTopologyId();
String nodeId = vteps.getNodeId();
IpAddress ipAddress = vteps.getIpAddress();
LOG.trace("topo-id: {}, node-id: {}, ipAddress: {}", topologyId, nodeId, ipAddress);
HwVtep hwVtep = ItmUtils.createHwVtepObject(topologyId, nodeId, ipAddress, tunnelType, transportZone);
LOG.trace("Adding new HwVtep {} info ", hwVtep.getHwIp());
hwVtepsList.add(hwVtep);
}
}
LOG.trace("returning hwvteplist {}", hwVtepsList);
return hwVtepsList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class TransportZoneListener method remove.
@Override
public void remove(@NonNull InstanceIdentifier<TransportZone> instanceIdentifier, @NonNull TransportZone transportZone) {
LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
boolean allowTunnelDeletion;
if (interfaceManager.isItmOfTunnelsEnabled()) {
Map<OfDpnTepKey, OfDpnTep> dpnTepMap = createOfTepInfo(transportZone);
if (!dpnTepMap.isEmpty()) {
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmOfPortRemoveWorker(dpnTepMap, itmOfTunnelDeleteWorker));
} else {
EVENT_LOGGER.debug("DPN List in TZ is empty");
}
} else {
// due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
if (ITMConstants.DEFAULT_TRANSPORT_ZONE.equalsIgnoreCase(transportZone.getZoneName())) {
// Get TunnelTypeBase object for tunnel-type configured in config file
Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
if (!itmConfig.isDefTzEnabled() || !Objects.equals(transportZone.getTunnelType(), tunType)) {
allowTunnelDeletion = true;
} else {
// this is case when def-tz removal request is from Northbound.
allowTunnelDeletion = false;
LOG.error("Deletion of {} is an incorrect usage", ITMConstants.DEFAULT_TRANSPORT_ZONE);
}
} else {
allowTunnelDeletion = true;
}
if (allowTunnelDeletion) {
// TODO : DPList code can be refactor with new specific class
// which implement TransportZoneValidator
EVENT_LOGGER.debug("ITM-Transportzone,TunnelDeletion {}", transportZone.getZoneName());
List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
List<HwVtep> hwVtepList = createhWVteps(transportZone);
LOG.trace("Delete: Invoking deleteTunnels in ItmManager with DpnList {}", opDpnList);
if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
Map<UnknownVtepsKey, UnknownVteps> unknownVteps = convertVtepListToUnknownVtepList(transportZone.getVteps());
LOG.trace("Moving Transport Zone {} to tepsInNotHostedTransportZone Oper Ds.", transportZone.getZoneName());
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepsNotHostedAddWorker(unknownVteps, transportZone.getZoneName(), dataBroker, txRunner));
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport 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);
EVENT_LOGGER.debug("ITM-Transportzone,ADD {}", transportZone.getZoneName());
if (interfaceManager.isItmOfTunnelsEnabled()) {
Map<OfDpnTepKey, OfDpnTep> dpnTepMap = createOfTepInfo(transportZone);
if (!dpnTepMap.isEmpty()) {
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmOfPortAddWorker(dpnTepMap, itmOfTunnelAddWorker));
} else {
EVENT_LOGGER.debug("DPN List in TZ is empty");
}
} else {
List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
// avoiding adding duplicates from nothosted to new dpnlist.
List<DPNTEPsInfo> duplicateFound = new ArrayList<>();
List<DPNTEPsInfo> notHostedDpnList = getDPNTepInfoFromNotHosted(transportZone, opDpnList);
for (DPNTEPsInfo notHostedDPN : notHostedDpnList) {
for (DPNTEPsInfo newlyAddedDPN : opDpnList) {
if (newlyAddedDPN.getDPNID().compareTo(notHostedDPN.getDPNID()) == 0 || newlyAddedDPN.getTunnelEndPoints().get(0).getIpAddress().equals(notHostedDPN.getTunnelEndPoints().get(0).getIpAddress())) {
duplicateFound.add(notHostedDPN);
}
}
}
notHostedDpnList.removeAll(duplicateFound);
opDpnList.addAll(notHostedDpnList);
List<HwVtep> hwVtepList = createhWVteps(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, itmInternalTunnelAddWorker, externalTunnelAddWorker));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class TransportZoneListener method update.
@Override
public void update(@NonNull InstanceIdentifier<TransportZone> instanceIdentifier, @NonNull TransportZone originalTransportZone, @NonNull TransportZone updatedTransportZone) {
LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone, updatedTransportZone);
EVENT_LOGGER.debug("ITM-Transportzone,UPDATE {}", updatedTransportZone.getZoneName());
if (interfaceManager.isItmOfTunnelsEnabled()) {
updateTransportZone(originalTransportZone, updatedTransportZone);
} else {
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());
boolean equalLists = newDpnTepsList.size() == oldDpnTepsList.size() && newDpnTepsList.containsAll(oldDpnTepsList);
LOG.trace("Is List Duplicate {} ", equalLists);
if (!newDpnTepsList.isEmpty() && !equalLists) {
LOG.trace("Adding TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager, itmInternalTunnelAddWorker, externalTunnelAddWorker));
}
if (!oldDpnTepsList.isEmpty() && !equalLists) {
LOG.trace("Removing TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
}
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, itmInternalTunnelAddWorker, externalTunnelAddWorker));
}
if (!oldHwList.isEmpty()) {
LOG.trace("Removing HW TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmUtils method deleteTransportZoneFromConfigDS.
/**
* Deletes the transport zone from Configuration datastore.
*
* @param tzName transport zone name
* @param dataBroker data broker handle to perform operations on datastore
*/
public static void deleteTransportZoneFromConfigDS(String tzName, DataBroker dataBroker) {
// check whether transport-zone exists in config DS.
TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZoneFromConfigDS != null) {
// it exists, delete default-TZ now
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
LOG.debug("Removing {} transport-zone from config DS.", tzName);
try {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
} catch (TransactionCommitFailedException e) {
LOG.error("deleteTransportZoneFromConfigDS failed. {} could not be deleted.", tzName, e);
}
}
}
Aggregations