Search in sources :

Example 1 with SingleTransactionDataBroker

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;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) PortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)

Example 2 with SingleTransactionDataBroker

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;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)

Example 3 with SingleTransactionDataBroker

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));
}
Also used : SouthboundUtils(org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) TestInterfaceManager(org.opendaylight.genius.testutils.TestInterfaceManager) LockManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService) IdHelper(org.opendaylight.netvirt.elanmanager.tests.utils.IdHelper) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) NeutronvpnManagerImpl(org.opendaylight.netvirt.neutronvpn.NeutronvpnManagerImpl) InterfaceMetaUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) MdsalUtils(org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) BatchingUtils(org.opendaylight.genius.interfacemanager.renderer.ovs.utilities.BatchingUtils) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) INeutronVpnManager(org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) OsgiService(org.ops4j.pax.cdi.api.OsgiService) MDSALManager(org.opendaylight.genius.mdsalutil.internal.MDSALManager) ItmRpcTestImpl(org.opendaylight.genius.testutils.itm.ItmRpcTestImpl) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) ElanConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfigBuilder) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) EntityOwnershipService(org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService) DataImportBootReady(org.opendaylight.daexim.DataImportBootReady) DiagStatusService(org.opendaylight.infrautils.diagstatus.DiagStatusService) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager)

Example 4 with SingleTransactionDataBroker

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();
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Before(org.junit.Before)

Example 5 with SingleTransactionDataBroker

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);
}
Also used : DataBrokerTestModule(org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule) DataBrokerFailuresImpl(org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Before(org.junit.Before)

Aggregations

SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)9 Before (org.junit.Before)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports)2 PortKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 ArrayList (java.util.ArrayList)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 DataBrokerTestModule (org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule)1 DataImportBootReady (org.opendaylight.daexim.DataImportBootReady)1 DataBrokerFailuresImpl (org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl)1 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)1 InterfaceMetaUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils)1 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)1 BatchingUtils (org.opendaylight.genius.interfacemanager.renderer.ovs.utilities.BatchingUtils)1 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)1 MDSALManager (org.opendaylight.genius.mdsalutil.internal.MDSALManager)1