use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.
the class ElanUtils method updateOperationalDataStore.
/**
* Updates the Elan information in the Operational DS. It also updates the
* ElanInstance in the Config DS by setting the adquired elanTag.
*
* @param idManager
* the id manager
* @param elanInstanceAdded
* the elan instance added
* @param elanInterfaces
* the elan interfaces
* @param tx
* transaction
*
* @return the updated ELAN instance.
*/
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, WriteTransaction tx) {
String elanInstanceName = elanInstanceAdded.getElanInstanceName();
Long elanTag = elanInstanceAdded.getElanTag();
if (elanTag == null || elanTag == 0L) {
elanTag = retrieveNewElanTag(idManager, elanInstanceName);
}
Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).setKey(new ElanKey(elanInstanceName)).build();
// Add the ElanState in the elan-state operational data-store
tx.put(LogicalDatastoreType.OPERATIONAL, getElanInstanceOperationalDataPath(elanInstanceName), elanInfo, WriteTransaction.CREATE_MISSING_PARENTS);
// Add the ElanMacTable in the elan-mac-table operational data-store
MacTable elanMacTable = new MacTableBuilder().setKey(new MacTableKey(elanInstanceName)).build();
tx.put(LogicalDatastoreType.OPERATIONAL, getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).setKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
long etreeLeafTag = -1;
if (isEtreeInstance(elanInstanceAdded)) {
etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
elanTagNameBuilder.addAugmentation(EtreeLeafTagName.class, etreeLeafTagName);
addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, tx);
}
ElanTagName elanTagName = elanTagNameBuilder.build();
// Add the ElanTag to ElanName in the elan-tag-name Operational
// data-store
tx.put(LogicalDatastoreType.OPERATIONAL, getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
// Updates the ElanInstance Config DS by setting the just acquired
// elanTag
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Long.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).setKey(elanInstanceAdded.getKey()).setElanTag(elanTag);
if (isEtreeInstance(elanInstanceAdded)) {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
elanInstanceBuilder.addAugmentation(EtreeInstance.class, etreeInstance);
}
ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
tx.merge(LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag, WriteTransaction.CREATE_MISSING_PARENTS);
return elanInstanceWithTag;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.
the class NeutronFlowClassifierListener method update.
/**
* Method updates the original SfcFlowClassifier to the update SfcFlowClassifier.
* Both are identified by same InstanceIdentifier.
*
* @param updatedSfcFlowClassifier - changed SfcFlowClassifier (contain updates)
*/
@Override
public void update(SfcFlowClassifier updatedSfcFlowClassifier) {
Acl aclFlowClassifier = FlowClassifierTranslator.buildAcl(updatedSfcFlowClassifier);
sfcMdsalHelper.updateAclFlowClassifier(aclFlowClassifier);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.
the class VrfEntryListener method update.
@Override
// originalRoutePath is a little dicey - safest to keep the checking even if not needed.
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
protected void update(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update) {
Preconditions.checkNotNull(update, "VrfEntry should not be null or empty.");
final String rd = identifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
LOG.debug("UPDATE: Updating Fib Entries to rd {} prefix {} route-paths {} origin {} old-origin {}", rd, update.getDestPrefix(), update.getRoutePaths(), update.getOrigin(), original.getOrigin());
// Handle BGP Routes first
if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.BGP) {
bgpRouteVrfEntryHandler.updateFlows(identifier, original, update, rd);
LOG.info("UPDATE: Updated BGP advertised Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
return;
}
if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.STATIC) {
List<RoutePaths> originalRoutePath = original.getRoutePaths();
List<RoutePaths> updateRoutePath = update.getRoutePaths();
LOG.info("UPDATE: Original route-path {} update route-path {} ", originalRoutePath, updateRoutePath);
// Updates need to be handled for extraroute even if original vrf entry route path is null or
// updated vrf entry route path is null. This can happen during tunnel events.
Optional<VpnInstanceOpDataEntry> optVpnInstance = fibUtil.getVpnInstanceOpData(rd);
List<String> usedRds = new ArrayList<>();
if (optVpnInstance.isPresent()) {
usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, optVpnInstance.get().getVpnId(), update.getDestPrefix());
}
// has nexthop , route needs to be created on remote Dpns
if (originalRoutePath == null || originalRoutePath.isEmpty() && updateRoutePath != null && !updateRoutePath.isEmpty() && usedRds.isEmpty()) {
// TODO(vivek): Though ugly, Not handling this code now, as each
// tep add event will invoke flow addition
LOG.trace("Original VRF entry NH is null for destprefix {}. And the prefix is not an extra route." + " This event is IGNORED here.", update.getDestPrefix());
return;
}
// has nexthop empty'ed out, route needs to be removed from remote Dpns
if (updateRoutePath == null || updateRoutePath.isEmpty() && originalRoutePath != null && !originalRoutePath.isEmpty() && usedRds.isEmpty()) {
LOG.trace("Original VRF entry had valid NH for destprefix {}. And the prefix is not an extra route." + "This event is IGNORED here.", update.getDestPrefix());
return;
}
// Update the used rds and vpntoextraroute containers only for the deleted nextHops.
List<String> nextHopsRemoved = FibHelper.getNextHopListFromRoutePaths(original);
nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
nextHopsRemoved.parallelStream().forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(writeOperTxn, nextHopRemoved, rd, update.getDestPrefix()));
CheckedFuture<Void, TransactionCommitFailedException> operFuture = writeOperTxn.submit();
try {
operFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception encountered while submitting operational future for update vrfentry {}", update, e);
}
createFibEntries(identifier, update);
LOG.info("UPDATE: Updated static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
return;
}
// Handle all other routes only on a cluster reboot
if (original.equals(update)) {
// Reboot use-case
createFibEntries(identifier, update);
LOG.info("UPDATE: Updated Non-static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
return;
}
LOG.info("UPDATE: Ignoring update for FIB entry with rd {} prefix {} route-origin {} route-paths {}", rd, update.getDestPrefix(), update.getOrigin(), update.getRoutePaths());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class OvsdbNodeListener method update.
@Override
public void update(@Nonnull Node originalOvsdbNode, Node updatedOvsdbNode) {
String newLocalIp = null;
String oldLocalIp = null;
String tzName = null;
String oldTzName = null;
String oldDpnBridgeName = null;
String newDpnBridgeName = null;
boolean newOfTunnel = false;
boolean isTepInfoUpdated = false;
boolean isTepInfoDeleted = false;
boolean isLocalIpAdded = false;
boolean isLocalIpRemoved = false;
boolean isLocalIpUpdated;
boolean isTzChanged = false;
boolean isDpnBrChanged = false;
LOG.trace("OvsdbNodeListener called for Ovsdb Node ({}) Update.", originalOvsdbNode.getNodeId().getValue());
LOG.trace("Update: originalOvsdbNode: {} updatedOvsdbNode: {}", originalOvsdbNode, updatedOvsdbNode);
// addTep, as TEP would not be added in node add case above
if (isBridgeDpIdAdded(originalOvsdbNode, updatedOvsdbNode)) {
processBridgeUpdate(updatedOvsdbNode);
return;
}
// get OVSDB TEP info from old ovsdb node
OvsdbTepInfo newTepInfoObj = getOvsdbTepInfo(updatedOvsdbNode.getAugmentation(OvsdbNodeAugmentation.class));
// get OVSDB TEP info from new ovsdb node
OvsdbTepInfo oldTepInfoObj = getOvsdbTepInfo(originalOvsdbNode.getAugmentation(OvsdbNodeAugmentation.class));
if (oldTepInfoObj == null && newTepInfoObj == null) {
LOG.trace("Tep Info is not received in old and new Ovsdb Nodes.");
return;
}
if (oldTepInfoObj != null && newTepInfoObj == null) {
isTepInfoDeleted = true;
LOG.trace("Tep Info is deleted from Ovsdb node: {}", originalOvsdbNode.getNodeId().getValue());
}
// store TEP info required parameters
if (newTepInfoObj != null) {
tzName = newTepInfoObj.getTzName();
newLocalIp = newTepInfoObj.getLocalIp();
newDpnBridgeName = newTepInfoObj.getBrName();
newOfTunnel = newTepInfoObj.getOfTunnel();
}
if (oldTepInfoObj != null) {
oldLocalIp = oldTepInfoObj.getLocalIp();
oldDpnBridgeName = oldTepInfoObj.getBrName();
oldTzName = oldTepInfoObj.getTzName();
}
// handle case when TEP parameters are not configured from switch side
if (newLocalIp == null && oldLocalIp == null) {
LOG.trace("TEP info Local IP parameters are not specified in old and new Ovsdb Nodes.");
return;
}
if (!isTepInfoDeleted) {
isLocalIpRemoved = isLocalIpRemoved(oldLocalIp, newLocalIp);
isLocalIpAdded = isLocalIpAdded(oldLocalIp, newLocalIp);
isLocalIpUpdated = isLocalIpUpdated(oldLocalIp, newLocalIp);
if (isLocalIpUpdated) {
LOG.info("Local IP cannot be updated. First delete the Local IP and then add again.");
return;
}
if (isLocalIpAdded || isLocalIpRemoved) {
isTepInfoUpdated = true;
}
if (isTzUpdated(oldTzName, tzName)) {
isTepInfoUpdated = true;
if (oldLocalIp != null && newLocalIp != null) {
isTzChanged = true;
LOG.trace("tzname is changed from {} to {} for Local IP: {}", oldTzName, tzName, newLocalIp);
}
}
if (isDpnUpdated(oldDpnBridgeName, newDpnBridgeName)) {
isTepInfoUpdated = true;
if (oldLocalIp != null && newLocalIp != null) {
isDpnBrChanged = true;
LOG.trace("dpn-br-name is changed from {} to {} for Local IP: {}", oldDpnBridgeName, newDpnBridgeName, newLocalIp);
}
}
if (!isTepInfoUpdated) {
LOG.trace("No updates in the TEP Info parameters. Nothing to do.");
return;
}
}
String strOldDpnId;
String strNewDpnId;
// handle TEP-remove in remove case, TZ change case, Bridge change case
if (isTepInfoDeleted || isLocalIpRemoved || isTzChanged || isDpnBrChanged) {
// if flag is OFF, then no need to add TEP into ITM config DS.
if (oldTzName == null || oldTzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be removed from {} when def-tz-enabled flag is false.", oldLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
oldTzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
strOldDpnId = ItmUtils.getBridgeDpid(updatedOvsdbNode, oldDpnBridgeName, dataBroker);
if (strOldDpnId == null || strOldDpnId.isEmpty()) {
LOG.error("TEP {} cannot be deleted. DPID for bridge {} is NULL.", oldLocalIp, oldDpnBridgeName);
return;
}
// remove TEP
LOG.trace("Update case: Removing TEP-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}", oldLocalIp, oldTzName, oldDpnBridgeName, strOldDpnId);
// Enqueue 'remove TEP from TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(oldLocalIp, new OvsdbTepRemoveWorker(oldLocalIp, strOldDpnId, oldTzName, dataBroker));
}
// handle TEP-add in add case, TZ change case, Bridge change case
if (isLocalIpAdded || isTzChanged || isDpnBrChanged) {
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
// get Datapath ID for bridge
strNewDpnId = ItmUtils.getBridgeDpid(updatedOvsdbNode, newDpnBridgeName, dataBroker);
if (strNewDpnId == null || strNewDpnId.isEmpty()) {
LOG.error("TEP {} cannot be added. DPID for bridge {} is NULL.", newLocalIp, newDpnBridgeName);
return;
}
LOG.trace("Update case: Adding TEP-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel: {}", newLocalIp, tzName, newDpnBridgeName, strNewDpnId, newOfTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strNewDpnId, tzName, newOfTunnel, dataBroker));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class AlivenessMonitorUtils method handleTunnelMonitorUpdates.
public void handleTunnelMonitorUpdates(Interface interfaceOld, Interface interfaceNew) {
String interfaceName = interfaceNew.getName();
IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
if (!lldpMonitoringEnabled(ifTunnelNew)) {
return;
}
LOG.debug("handling tunnel monitoring updates for interface {}", interfaceName);
stopLLDPMonitoring(ifTunnelNew, interfaceOld.getName());
if (ifTunnelNew.isMonitorEnabled()) {
startLLDPMonitoring(ifTunnelNew, interfaceName);
// Delete old profile from Aliveness Manager
IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
if (!ifTunnelNew.getMonitorInterval().equals(ifTunnelOld.getMonitorInterval())) {
LOG.debug("deleting older monitor profile for interface {}", interfaceName);
long profileId = allocateProfile(FAILURE_THRESHOLD, ifTunnelOld.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp);
MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
Future<RpcResult<Void>> future = alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Delete monitor profile {}", interfaceName);
}
}
}
Aggregations