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 InterVpnLinkUtil method updateInterVpnLinkState.
/**
* Updates inter-VPN link state.
*
* @param broker dataBroker service reference
* @param vpnLinkName The name of the InterVpnLink
* @param state Sets the state of the InterVpnLink to Active or Error
* @param newFirstEndpointState Updates the lportTag and/or DPNs of the 1st endpoint of the InterVpnLink
* @param newSecondEndpointState Updates the lportTag and/or DPNs of the 2nd endpoint of the InterVpnLink
* @param interVpnLinkCache the InterVpnLinkCache
*/
public static void updateInterVpnLinkState(DataBroker broker, String vpnLinkName, InterVpnLinkState.State state, FirstEndpointState newFirstEndpointState, SecondEndpointState newSecondEndpointState, InterVpnLinkCache interVpnLinkCache) {
Optional<InterVpnLinkState> optOldVpnLinkState = getInterVpnLinkState(broker, vpnLinkName);
if (optOldVpnLinkState.isPresent()) {
InterVpnLinkState newVpnLinkState = new InterVpnLinkStateBuilder(optOldVpnLinkState.get()).setState(state).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).build();
VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newVpnLinkState);
interVpnLinkCache.addInterVpnLinkStateToCaches(newVpnLinkState);
} else {
InterVpnLinkState newIVpnLinkState = new InterVpnLinkStateBuilder().setKey(new InterVpnLinkStateKey(vpnLinkName)).setInterVpnLinkName(vpnLinkName).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).setState(InterVpnLinkState.State.Active).build();
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newIVpnLinkState);
interVpnLinkCache.addInterVpnLinkStateToCaches(newIVpnLinkState);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project openflowplugin by opendaylight.
the class SyncReactorImpl method syncup.
@Override
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> nodeIdent, final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(nodeIdent);
FlowCapableNode configTree = syncupEntry.getAfter();
FlowCapableNode operationalTree = syncupEntry.getBefore();
final SyncCrudCounters counters = new SyncCrudCounters();
/**
* instructions:
* - extract diff changes and prepare change steps in safe order
* - optimization: decide if updates needed
* - execute chosen implementation (e.g. conventional API, bulk API, flat bulk API)
* - recommended order follows:
* reconciliation strategy - phase 1: - add/update missing objects in following order:
* - table features - groups (reordered) - meters - flows
* reconciliation strategy - phase 2: - remove redundant objects in following order:
* - flows - meters - groups (reordered)
*/
final List<ItemSyncBox<Group>> groupsToAddOrUpdate = extractGroupsToAddOrUpdate(nodeId, configTree, operationalTree);
final ItemSyncBox<Meter> metersToAddOrUpdate = extractMetersToAddOrUpdate(nodeId, configTree, operationalTree);
final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate = extractFlowsToAddOrUpdate(nodeId, configTree, operationalTree);
final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove = extractFlowsToRemove(nodeId, configTree, operationalTree);
final ItemSyncBox<Meter> metersToRemove = extractMetersToRemove(nodeId, configTree, operationalTree);
final List<ItemSyncBox<Group>> groupsToRemove = extractGroupsToRemove(nodeId, configTree, operationalTree);
final SynchronizationDiffInput input = new SynchronizationDiffInput(nodeIdent, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
final ListenableFuture<RpcResult<Void>> bootstrapResultFuture = RpcResultBuilder.<Void>success().buildFuture();
final ListenableFuture<RpcResult<Void>> resultVehicle = syncPlanPushStrategy.executeSyncStrategy(bootstrapResultFuture, input, counters);
return Futures.transform(resultVehicle, input1 -> {
if (input1 == null) {
return false;
}
if (LOG.isDebugEnabled()) {
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
LOG.debug("Syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, " + "meter={}/{}/{}, errors={}", nodeId.getValue(), flowCrudCounts.getAdded(), flowCrudCounts.getUpdated(), flowCrudCounts.getRemoved(), groupCrudCounts.getAdded(), groupCrudCounts.getUpdated(), groupCrudCounts.getRemoved(), meterCrudCounts.getAdded(), meterCrudCounts.getUpdated(), meterCrudCounts.getRemoved(), Arrays.toString(input1.getErrors().toArray()));
}
return input1.isSuccessful();
}, MoreExecutors.directExecutor());
}
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 operTx
* transaction
*
* @return the updated ELAN instance.
*/
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx) {
String elanInstanceName = elanInstanceAdded.getElanInstanceName();
Uint32 elanTag = elanInstanceAdded.getElanTag();
if (elanTag == null || elanTag.longValue() == 0L) {
elanTag = retrieveNewElanTag(idManager, elanInstanceName);
}
if (elanTag.longValue() == 0L) {
LOG.error("ELAN tag creation failed for elan instance {}. Not updating the ELAN DS. " + "Recreate network for recovery", elanInstanceName);
return null;
}
Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).withKey(new ElanKey(elanInstanceName)).build();
// Add the ElanState in the elan-state operational data-store
operTx.mergeParentStructurePut(getElanInstanceOperationalDataPath(elanInstanceName), elanInfo);
// Add the ElanMacTable in the elan-mac-table operational data-store
MacTable elanMacTable = new MacTableBuilder().withKey(new MacTableKey(elanInstanceName)).build();
operTx.mergeParentStructurePut(getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable);
ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).withKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
Uint32 etreeLeafTag = Uint32.valueOf(0L);
if (isEtreeInstance(elanInstanceAdded)) {
etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
elanTagNameBuilder.addAugmentation(etreeLeafTagName);
addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, operTx);
}
ElanTagName elanTagName = elanTagNameBuilder.build();
// Add the ElanTag to ElanName in the elan-tag-name Operational
// data-store
operTx.put(getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
// Updates the ElanInstance Config DS by setting the just acquired
// elanTag
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceAdded).setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Uint32.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).withKey(elanInstanceAdded.key()).setElanTag(elanTag);
if (isEtreeInstance(elanInstanceAdded)) {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
elanInstanceBuilder.addAugmentation(etreeInstance);
}
ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
LOG.trace("Updated elan Operational DS for elan: {} with elanTag: {} and interfaces: {}", elanInstanceName, elanTag, elanInterfaces);
confTx.mergeParentStructureMerge(ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag);
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 ElanServiceChainHandler method programElanScfPipeline.
/**
* Programs the needed flows for sending traffic to the SCF pipeline when
* it is comming from an L2-GW (ELAN) and also for handing over that
* traffic from SCF to ELAN when the packets does not match any Service
* Chain.
*
* @param elanName Name of the ELAN to be considered
* @param tableId Table id, in the SCF Pipeline, to which the traffic must
* go to.
* @param scfTag Tag of the ServiceChain
* @param elanLportTag LPortTag of the ElanPseudoPort that participates in
* the ServiceChain
* @param addOrRemove States if the flows must be created or removed
*/
public void programElanScfPipeline(String elanName, short tableId, long scfTag, int elanLportTag, int addOrRemove) {
LOG.info("programElanScfPipeline: elanName={} scfTag={} elanLportTag={} addOrRemove={}", elanName, scfTag, elanLportTag, addOrRemove);
// There are 3 rules to be considered:
// 1. LportDispatcher To Scf. Matches on elanPseudoPort + SI=1. Goes to DL Subscriber table
// 2. LportDispatcher From Scf. Matches on elanPseudoPort + SI=3. Goes to ELAN DMAC
// 3. ExtTunnelTable From L2GwDevice. Matches on VNI + SI=1. Sets ElanPseudoPort tag and goes
// to LportDispatcher table.
// And these rules must be programmed in all the Elan footprint
// Find the ElanInstance
Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
if (!elanInstance.isPresent()) {
LOG.debug("Could not find an Elan Instance with name={}", elanName);
return;
}
Collection<BigInteger> elanDpnsOpc = ElanServiceChainUtils.getElanDpnsByName(broker, elanName);
if (elanDpnsOpc.isEmpty()) {
LOG.debug("Could not find any DPN related to Elan {}", elanName);
return;
}
// updates map which stores relationship between elan and elanLPortTag and scfTag
ElanServiceChainUtils.updateElanToLportTagMap(broker, elanName, elanLportTag, scfTag, addOrRemove);
Long vni = elanInstance.get().getSegmentationId();
if (vni == null) {
LOG.warn("There is no VNI for elan {}. VNI is mandatory. Returning", elanName);
return;
}
int elanTag = elanInstance.get().getElanTag().intValue();
LOG.debug("elanName={} -> vni={} elanTag={}", elanName, vni, elanTag);
// Program ExtTunnelTable.
for (BigInteger dpnId : elanDpnsOpc) {
ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, tableId, scfTag, addOrRemove);
ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, addOrRemove);
ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, addOrRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method serializeUpdate.
protected void serializeUpdate(final Updates update, final ByteBuf buffer) {
serializeObject(update.getSrp(), buffer);
serializeObject(update.getLsp(), buffer);
final Path p = update.getPath();
if (p != null) {
serializeObject(p.getEro(), buffer);
serializeObject(p.getLspa(), buffer);
serializeObject(p.getBandwidth(), buffer);
serializeObject(p.getReoptimizationBandwidth(), buffer);
if (p.getMetrics() != null) {
for (final Metrics m : p.getMetrics()) {
serializeObject(m.getMetric(), buffer);
}
}
serializeObject(p.getIro(), buffer);
}
}
Aggregations