use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State 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.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project netvirt by opendaylight.
the class DhcpInterfaceEventListener method update.
@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
// We're only interested in Vlan and Tunnel ports
if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
return;
}
if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
LOG.trace("Interface operstatus {} is same", update.getOperStatus());
return;
}
if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
LOG.trace("New/old interface state is unknown not handling");
return;
}
List<String> ofportIds = update.getLowerLayerIf();
if (ofportIds == null || ofportIds.isEmpty()) {
return;
}
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
String interfaceName = update.getName();
DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project controller by opendaylight.
the class ClusterAdminRpcService method changeMemberVotingStatesForShard.
@Override
public Future<RpcResult<Void>> changeMemberVotingStatesForShard(ChangeMemberVotingStatesForShardInput input) {
final String shardName = input.getShardName();
if (Strings.isNullOrEmpty(shardName)) {
return newFailedRpcResultFuture("A valid shard name must be specified");
}
DataStoreType dataStoreType = input.getDataStoreType();
if (dataStoreType == null) {
return newFailedRpcResultFuture("A valid DataStoreType must be specified");
}
List<MemberVotingState> memberVotingStates = input.getMemberVotingState();
if (memberVotingStates == null || memberVotingStates.isEmpty()) {
return newFailedRpcResultFuture("No member voting state input was specified");
}
ChangeShardMembersVotingStatus changeVotingStatus = toChangeShardMembersVotingStatus(shardName, memberVotingStates);
LOG.info("Change member voting states for shard {}: {}", shardName, changeVotingStatus.getMeberVotingStatusMap());
final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, changeVotingStatus);
Futures.addCallback(future, new FutureCallback<Success>() {
@Override
public void onSuccess(Success success) {
LOG.info("Successfully changed member voting states for shard {}", shardName);
returnFuture.set(newSuccessfulResult());
}
@Override
public void onFailure(Throwable failure) {
onMessageFailure(String.format("Failed to change member voting states for shard %s", shardName), returnFuture, failure);
}
}, MoreExecutors.directExecutor());
return returnFuture;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class IncrementalSynchronizationProcedureTest method testStateSynchronizationPerformed.
@Test
public void testStateSynchronizationPerformed() throws Exception {
PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
this.listener.onSessionUp(session);
// report LSP + LSP-DB version number
final Pcrpt pcRpt = getPcrpt(1L, "test");
this.listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
this.listener.onSessionDown(session, new IllegalArgumentException());
this.listener = (Stateful07TopologySessionListener) getSessionListener();
// session up - expect sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
this.listener.onSessionUp(session);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - IncrementalSync state
assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
// check reported LSP - persisted from previous session
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
// report LSP2 + LSP-DB version number 2
final Pcrpt pcRpt2 = getPcrpt(2L, "testsecond");
this.listener.onMessage(session, pcRpt2);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
// check reported LSP is not empty
assertEquals(2, pcc.getReportedLsp().size());
return pcc;
});
// sync rpt + LSP-DB
final Pcrpt syncMsg = getSyncPcrt();
this.listener.onMessage(session, syncMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is empty, LSP state from previous session was purged
assertEquals(2, pcc.getReportedLsp().size());
return pcc;
});
// report LSP3 + LSP-DB version number 4
final Pcrpt pcRpt3 = getPcrpt(3L, "testthird");
this.listener.onMessage(session, pcRpt3);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
assertEquals(3, pcc.getReportedLsp().size());
return pcc;
});
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class PCEPTriggeredReSynchronizationProcedureTest method testTriggeredResynchronization.
@Test
public void testTriggeredResynchronization() throws Exception {
// session up - sync skipped (LSP-DBs match)
this.session = getPCEPSession(getOpen(), getOpen());
this.listener.onSessionUp(this.session);
// report LSP + LSP-DB version number
final Pcrpt pcRpt = getPcrt();
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
assertFalse(pcc.getReportedLsp().isEmpty());
return pcc;
});
// PCEP Trigger Full Resync
this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).build());
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(PccSyncState.PcepTriggeredResync, pcc.getStateSync());
return pcc;
});
// end of sync
final Pcrpt syncMsg = getSyncMsg();
this.listener.onMessage(this.session, syncMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
return pcc;
});
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(1, pcc.getReportedLsp().size());
return pcc;
});
// Trigger Full Resync
this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).build());
this.listener.onMessage(this.session, pcRpt);
// end of sync
this.listener.onMessage(this.session, syncMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is not empty, Stale LSP state were purged
assertEquals(1, pcc.getReportedLsp().size());
return pcc;
});
}
Aggregations