use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.
the class NeutronUtils method writePortStatus.
private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
Uuid uuidObj = new Uuid(uuid);
PortBuilder portBuilder = new PortBuilder();
portBuilder.setUuid(uuidObj);
portBuilder.setStatus(portStatus);
InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
try {
if (create) {
tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
} else {
tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
}
} catch (TransactionCommitFailedException e) {
LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
return false;
}
return true;
}
use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.
the class NeutronUtils method deletePortStatus.
/**
* Delete a Neutron Port status entry from the operational data store.
* @param uuid The uuid of the Neutron port
* @param dataBroker DataBroker instance
* @return true if transaction submitted successfully
*/
public static boolean deletePortStatus(String uuid, DataBroker dataBroker) {
Uuid uuidObj = new Uuid(uuid);
InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
try {
tx.syncDelete(LogicalDatastoreType.OPERATIONAL, iid);
} catch (TransactionCommitFailedException e) {
LOG.error("deletePortStatus: failed neutron port status delete", e);
return false;
}
return true;
}
use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.
the class ElanServiceTestModule method configureBindings.
@Override
protected void configureBindings() {
DataBroker dataBroker = DataBrokerTestModule.dataBroker();
bind(EntityOwnershipService.class).toInstance(Mockito.mock(EntityOwnershipService.class));
bind(INeutronVpnManager.class).toInstance(Mockito.mock(NeutronvpnManagerImpl.class));
IVpnManager ivpnManager = Mockito.mock(VpnManagerTestImpl.class, CALLS_REAL_METHODS);
bind(IMdsalApiManager.class).toInstance(new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)));
// Bindings for external services to "real" implementations
bind(LockManagerService.class).to(LockManagerServiceImpl.class);
bind(ElanConfig.class).toInstance(new ElanConfigBuilder().setIntBridgeGenMac(true).setTempSmacLearnTimeout(10).build());
// Bindings of all listeners (which are not directly referenced in the code)
// This is required to be explicit here, because these are referenced neither from src/main nor src/test
// and we, intentionally, don't use "classpath scanning for auto-discovery"
// so this list must kept, manually, in line with the rc/main/resources/org/opendaylight/blueprint/*.xml
// and target/generated-resources/org/opendaylight/blueprint/autowire.xml
// bind(ElanGroupListener.class);
// TODO complete this list!!! after Gerrit which adds @Inject to all listeners
// Bindings to test infra (fakes & mocks)
TestInterfaceManager obj = TestInterfaceManager.newInstance(dataBroker);
ItmRpcService itmRpcService = new ItmRpcTestImpl();
bind(DataBroker.class).toInstance(dataBroker);
bind(DataBroker.class).annotatedWith(OsgiService.class).toInstance(dataBroker);
bind(IdManagerService.class).toInstance(Mockito.mock(IdHelper.class, CALLS_REAL_METHODS));
bind(IInterfaceManager.class).toInstance(obj);
bind(TestInterfaceManager.class).toInstance(obj);
InterfaceMetaUtils interfaceMetaUtils = new InterfaceMetaUtils(dataBroker, Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), Mockito.mock(BatchingUtils.class));
InterfaceManagerCommonUtils interfaceManagerCommonUtils = new InterfaceManagerCommonUtils(dataBroker, new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)), Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), interfaceMetaUtils, Mockito.mock(BatchingUtils.class));
bind(OdlInterfaceRpcService.class).toInstance(ElanEgressActionsHelper.newInstance(interfaceManagerCommonUtils));
SingleTransactionDataBroker singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
bind(SingleTransactionDataBroker.class).toInstance(singleTransactionDataBroker);
IBgpManager ibgpManager = BgpManagerTestImpl.newInstance(singleTransactionDataBroker);
bind(ItmRpcService.class).toInstance(itmRpcService);
bind(ItmRpcTestImpl.class).toInstance((ItmRpcTestImpl) itmRpcService);
bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {
});
bind(DiagStatusService.class).toInstance(Mockito.mock(DiagStatusService.class));
bind(IVpnManager.class).toInstance(ivpnManager);
bind(IBgpManager.class).toInstance(ibgpManager);
bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {
});
bind(IElanService.class).to(ElanServiceProvider.class);
MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
bind(MdsalUtils.class).toInstance(mdsalUtils);
bind(SouthboundUtils.class).toInstance(new SouthboundUtils(mdsalUtils));
}
use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method start.
@Before
public void start() throws InterruptedException, TransactionCommitFailedException {
db = new SingleTransactionDataBroker(dataBroker);
// Create the bridge and make sure it is ready
setupAndAssertBridgeCreation();
}
use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method beforeTest.
@Before
public void beforeTest() {
testableDataBroker = new DataBrokerFailuresImpl(new DataBrokerTestModule(true).getDataBroker());
managedNewTransactionRunner = createManagedNewTransactionRunnerToTest(testableDataBroker);
singleTransactionDataBroker = new SingleTransactionDataBroker(testableDataBroker);
}
Aggregations