Search in sources :

Example 1 with MappingDatabase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.

the class DataStoreBackEnd method getAllAuthenticationKeys.

public List<AuthenticationKey> getAllAuthenticationKeys() {
    LOG.debug("MD-SAL: Get all authentication keys from datastore");
    List<AuthenticationKey> authKeys = new ArrayList<AuthenticationKey>();
    MappingDatabase mdb = readTransaction(DATABASE_ROOT, LogicalDatastoreType.CONFIGURATION);
    if (mdb != null && mdb.getVirtualNetworkIdentifier() != null) {
        for (VirtualNetworkIdentifier id : mdb.getVirtualNetworkIdentifier()) {
            List<AuthenticationKey> keys = id.getAuthenticationKey();
            if (keys != null) {
                authKeys.addAll(keys);
            }
        }
    }
    return authKeys;
}
Also used : MappingDatabase(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) VirtualNetworkIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier) ArrayList(java.util.ArrayList)

Example 2 with MappingDatabase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.

the class DataStoreBackEnd method getAllMappings.

public List<Mapping> getAllMappings(LogicalDatastoreType logicalDataStore) {
    LOG.debug("MD-SAL: Get all mappings from {} datastore", logicalDataStore == LogicalDatastoreType.CONFIGURATION ? "config" : "operational");
    List<Mapping> mappings = new ArrayList<Mapping>();
    MappingDatabase mdb = readTransaction(DATABASE_ROOT, logicalDataStore);
    if (mdb != null && mdb.getVirtualNetworkIdentifier() != null) {
        for (VirtualNetworkIdentifier id : mdb.getVirtualNetworkIdentifier()) {
            List<Mapping> ms = id.getMapping();
            if (ms != null) {
                mappings.addAll(ms);
            }
        }
    }
    return mappings;
}
Also used : MappingDatabase(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase) VirtualNetworkIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier) ArrayList(java.util.ArrayList) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) XtrIdMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)

Example 3 with MappingDatabase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.

the class DataStoreBackEndTest method getAllMappingsTest.

/**
 * Tests {@link DataStoreBackEnd#getAllMappings} method.
 */
@Test
@SuppressWarnings("unchecked")
public void getAllMappingsTest() throws ReadFailedException {
    final ReadOnlyTransaction rTxMock = Mockito.mock(ReadOnlyTransaction.class);
    final CheckedFuture<Optional<MappingDatabase>, ReadFailedException> readFutureMock = Mockito.mock(CheckedFuture.class);
    final Optional<MappingDatabase> optionalMock = Mockito.mock(Optional.class);
    Mockito.when(txChainMock.newReadOnlyTransaction()).thenReturn(rTxMock);
    Mockito.when(rTxMock.read(LogicalDatastoreType.CONFIGURATION, DATABASE_ROOT)).thenReturn(readFutureMock);
    Mockito.when(rTxMock.read(LogicalDatastoreType.OPERATIONAL, DATABASE_ROOT)).thenReturn(readFutureMock);
    Mockito.when(readFutureMock.checkedGet()).thenReturn(optionalMock);
    Mockito.when(optionalMock.isPresent()).thenReturn(true);
    Mockito.when(optionalMock.get()).thenReturn(getDefaultMappingDatabase().build());
    assertEquals(8, dataStoreBackEnd.getAllMappings().size());
    Mockito.verify(optionalMock, Mockito.times(2)).get();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) MappingDatabase(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase) Optional(com.google.common.base.Optional) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with MappingDatabase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.

the class DataStoreBackEndTest method getAllAuthenticationKeysTest.

/**
 * Tests {@link DataStoreBackEnd#getAllAuthenticationKeys} method.
 */
@Test
@SuppressWarnings("unchecked")
public void getAllAuthenticationKeysTest() throws ReadFailedException {
    final ReadOnlyTransaction rTxMock = Mockito.mock(ReadOnlyTransaction.class);
    final CheckedFuture<Optional<MappingDatabase>, ReadFailedException> readFutureMock = Mockito.mock(CheckedFuture.class);
    final Optional<MappingDatabase> optionalMock = Mockito.mock(Optional.class);
    Mockito.when(txChainMock.newReadOnlyTransaction()).thenReturn(rTxMock);
    Mockito.when(rTxMock.read(LogicalDatastoreType.CONFIGURATION, DATABASE_ROOT)).thenReturn(readFutureMock);
    Mockito.when(readFutureMock.checkedGet()).thenReturn(optionalMock);
    Mockito.when(optionalMock.isPresent()).thenReturn(true);
    Mockito.when(optionalMock.get()).thenReturn(getDefaultMappingDatabase().build());
    assertEquals(4, dataStoreBackEnd.getAllAuthenticationKeys().size());
    Mockito.verify(optionalMock).get();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) MappingDatabase(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase) Optional(com.google.common.base.Optional) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

MappingDatabase (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase)4 Optional (com.google.common.base.Optional)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 VirtualNetworkIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 AuthenticationKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)1 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)1 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)1