use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class VpnUtil method unbindService.
static void unbindService(DataBroker dataBroker, final String vpnInterfaceName, boolean isInterfaceStateDown, JobCoordinator jobCoordinator) {
if (!isInterfaceStateDown) {
jobCoordinator.enqueueJob(vpnInterfaceName, () -> {
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
writeTxn.delete(LogicalDatastoreType.CONFIGURATION, InterfaceUtils.buildServiceId(vpnInterfaceName, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)));
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(writeTxn.submit());
return futures;
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class VpnUtil method delete.
public static <T extends DataObject> void delete(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, FutureCallback<Void> callback) {
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.delete(datastoreType, path);
Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkListener method setInError.
protected void setInError(final InstanceIdentifier<InterVpnLinkState> vpnLinkStateIid, final InterVpnLinkState vpnLinkState, String errorMsg) {
LOG.error("Setting InterVpnLink {} in error. Reason: {}", vpnLinkState.getInterVpnLinkName(), errorMsg);
// Setting InterVPNLink in error state in MDSAL
InterVpnLinkState vpnLinkErrorState = new InterVpnLinkStateBuilder(vpnLinkState).setState(InterVpnLinkState.State.Error).setErrorDescription(errorMsg).build();
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.CONFIGURATION, vpnLinkStateIid, vpnLinkErrorState, WriteTransaction.CREATE_MISSING_PARENTS);
tx.submit();
// Sending out an error Notification
InterVpnLinkCreationErrorMessage errMsg = new InterVpnLinkCreationErrorMessageBuilder().setErrorMessage(errorMsg).build();
InterVpnLinkCreationError notif = new InterVpnLinkCreationErrorBuilder().setInterVpnLinkCreationErrorMessage(errMsg).build();
final ListenableFuture<?> eventFuture = this.notificationsService.offerNotification(notif);
Futures.addCallback(eventFuture, new FutureCallback<Object>() {
@Override
public void onFailure(Throwable error) {
LOG.warn("Error when sending notification about InterVpnLink creation issue. InterVpnLink name={} " + "state={}.", vpnLinkState.getInterVpnLinkName(), vpnLinkState, error);
}
@Override
public void onSuccess(Object arg) {
LOG.trace("Error notification for InterVpnLink successfully sent. VpnLinkName={} state={}", vpnLinkState.getInterVpnLinkName(), vpnLinkState);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkNodeAddTask method updateInterVpnLinkState.
private ListenableFuture<Void> updateInterVpnLinkState(InterVpnLinkState interVpnLinkState, List<BigInteger> firstDpnList, List<BigInteger> secondDpnList) {
FirstEndpointState firstEndPointState = new FirstEndpointStateBuilder(interVpnLinkState.getFirstEndpointState()).setDpId(firstDpnList).build();
SecondEndpointState secondEndPointState = new SecondEndpointStateBuilder(interVpnLinkState.getSecondEndpointState()).setDpId(secondDpnList).build();
InterVpnLinkState newInterVpnLinkState = new InterVpnLinkStateBuilder(interVpnLinkState).setState(InterVpnLinkState.State.Active).setFirstEndpointState(firstEndPointState).setSecondEndpointState(secondEndPointState).build();
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(interVpnLinkState.getInterVpnLinkName()), newInterVpnLinkState, true);
return tx.submit();
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkLocatorTest method setUp.
@Before
public void setUp() throws Exception {
dataBroker = getDataBroker();
// Creating both empty containers: InterVpnLinks and InterVpnLinkStates
WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(InterVpnLinks.class).build(), new InterVpnLinksBuilder().setInterVpnLink(Collections.emptyList()).build(), true);
writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(InterVpnLinkStates.class).build(), new InterVpnLinkStatesBuilder().setInterVpnLinkState(Collections.emptyList()).build(), true);
writeTx.submit().checkedGet();
interVpnLinkCache = new InterVpnLinkCacheImpl(dataBroker);
interVpnLinkCache.initialFeed();
// Prepare
populateL3Vpns(dataBroker, L3VpnTestCatalog.ALL_VPNS);
InterVpnLinkTestCatalog.populateIvpnLinks(dataBroker, ALL_IVPN_LINKS);
for (InterVpnLinkDataComposite ivl : ALL_IVPN_LINKS) {
interVpnLinkCache.addInterVpnLinkToCaches(ivl.getInterVpnLinkConfig());
interVpnLinkCache.addInterVpnLinkStateToCaches(ivl.getInterVpnLinkState());
}
// SUT
sut = new InterVpnLinkLocator(dataBroker, interVpnLinkCache);
}
Aggregations