Search in sources :

Example 1 with AuthenticationKey

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

the class LispSouthboundPlugin method restoreDaoFromDatastore.

/**
 * Restore all keys from MDSAL datastore.
 */
public void restoreDaoFromDatastore() {
    final List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
    LOG.info("Restoring {} keys from datastore into southbound DAO", authKeys.size());
    for (AuthenticationKey authKey : authKeys) {
        final Eid key = authKey.getEid();
        final MappingAuthkey mappingAuthkey = authKey.getMappingAuthkey();
        LOG.debug("Adding authentication key '{}' with key-ID {} for {}", mappingAuthkey.getKeyString(), mappingAuthkey.getKeyType(), LispAddressStringifier.getString(key));
        akdb.addAuthenticationKey(key, mappingAuthkey);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)

Example 2 with AuthenticationKey

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

the class AuthenticationKeyDataListener method onDataTreeChanged.

@Override
public synchronized void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
    for (DataTreeModification<AuthenticationKey> change : changes) {
        final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
        if (ModificationType.DELETE == mod.getModificationType()) {
            final AuthenticationKey authKey = mod.getDataBefore();
            LOG.trace("Received deleted data");
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", authKey);
            final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
            akdb.removeAuthenticationKey(convertedAuthKey.getEid());
            updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
        } else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
            if (ModificationType.WRITE == mod.getModificationType()) {
                LOG.trace("Received created data");
            } else {
                LOG.trace("Received updated data");
            }
            // Process newly created or updated authentication keys
            final AuthenticationKey authKey = mod.getDataAfter();
            LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
            LOG.trace("Value: {}", authKey);
            final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
            akdb.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
            updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
        } else {
            LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
        }
    }
}
Also used : AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)

Example 3 with AuthenticationKey

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

the class MappingSystemTest method restoreDaoFromDatastoreTest.

/**
 * Tests {@link MappingSystem#restoreDaoFromDatastore} method.
 */
@Test
public void restoreDaoFromDatastoreTest() {
    final Mapping mapping_1 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_1).build()).build();
    final Mapping mapping_2 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
    final MappingAuthkey mappingAuthkey_1 = MAPPING_AUTHKEY_BUILDER.build();
    final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_1).setEid(EID_IPV4_1).build();
    final MappingAuthkey mappingAuthkey_2 = MAPPING_AUTHKEY_BUILDER.setKeyString("pass-2").build();
    final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_2).setEid(EID_IPV4_2).build();
    final List<Mapping> mappings = Lists.newArrayList(mapping_1, mapping_2);
    final List<AuthenticationKey> authenticationKeys = Lists.newArrayList(authenticationKey_1, authenticationKey_2);
    Mockito.when(dsbeMock.getLastUpdateTimestamp()).thenReturn(System.currentTimeMillis());
    Mockito.when(dsbeMock.getAllMappings(LogicalDatastoreType.CONFIGURATION)).thenReturn(mappings);
    Mockito.when(dsbeMock.getAllAuthenticationKeys()).thenReturn(authenticationKeys);
    Mockito.when(tableMapMock.get(MappingOrigin.Northbound)).thenReturn(pmcMock);
    mappingSystem.initialize();
    ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_1), captor.capture());
    assertEquals(captor.getValue().getRecord(), mapping_1.getMappingRecord());
    Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_2), captor.capture());
    assertEquals(captor.getValue().getRecord(), mapping_2.getMappingRecord());
    Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_1, mappingAuthkey_1);
    Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_2, mappingAuthkey_2);
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with AuthenticationKey

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

the class AuthenticationKeyDataListenerTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    DataBroker dataBrokerMock = Mockito.mock(DataBroker.class);
    iMappingSystemMock = Mockito.mock(IMappingSystem.class);
    authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBrokerMock, iMappingSystemMock);
    final InstanceIdentifier<AuthenticationKey> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
    final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
    change_del = Mockito.mock(DataTreeModification.class);
    change_subtreeModified = Mockito.mock(DataTreeModification.class);
    change_write = Mockito.mock(DataTreeModification.class);
    mod_del = Mockito.mock(DataObjectModification.class);
    mod_subtreeModified = Mockito.mock(DataObjectModification.class);
    mod_write = Mockito.mock(DataObjectModification.class);
    Mockito.when(change_del.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_del.getRootNode()).thenReturn(mod_del);
    Mockito.when(change_subtreeModified.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
    Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
    Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
    Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
    Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) IMappingSystem(org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Before(org.junit.Before)

Example 5 with AuthenticationKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey 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)

Aggregations

AuthenticationKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)12 AuthenticationKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)6 Test (org.junit.Test)5 AuthenticationKeyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)3 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)3 VirtualNetworkIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier)3 DataObjectModification (org.opendaylight.controller.md.sal.binding.api.DataObjectModification)2 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)2 VniUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.VniUri)2 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)1 IMappingSystem (org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem)1