Search in sources :

Example 11 with AuthenticationKey

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

the class MappingSystem method restoreDaoFromDatastore.

/**
 * Restore all mappings and keys from mdsal datastore.
 */
private void restoreDaoFromDatastore() {
    List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
    List<Mapping> mappings = dsbe.getAllMappings(LogicalDatastoreType.CONFIGURATION);
    /*
         * XXX By default, the operational datastore is not persisted to disk, either at run-time, or on shutdown,
         * so the following will have no effect (getLastUpdateTimestamp() will fail, since it's reading from
         * the operational datastore, and even if it didn't getAllMappings() will fail anyway). According to rovarga it
         * should be possible to turn on persistence for the operational datastore editing
         * etc/opendaylight/karaf/05-clustering.xml, by setting <persistence>true</persistence>. At the time of writing
         * the below code block that didn't seem to work though.
         */
    Long lastUpdateTimestamp = dsbe.getLastUpdateTimestamp();
    if (lastUpdateTimestamp != null && System.currentTimeMillis() - lastUpdateTimestamp > ConfigIni.getInstance().getRegistrationValiditySb()) {
        LOG.warn("Restore threshold passed, not restoring operational datastore into DAO");
    } else {
        mappings.addAll(dsbe.getAllMappings(LogicalDatastoreType.OPERATIONAL));
    }
    dsbe.removeLastUpdateTimestamp();
    LOG.info("Restoring {} mappings and {} keys from datastore into DAO", mappings.size(), authKeys.size());
    for (Mapping mapping : mappings) {
        addMapping(mapping.getOrigin(), mapping.getMappingRecord().getEid(), new MappingData(mapping.getMappingRecord()));
    }
    for (AuthenticationKey authKey : authKeys) {
        addAuthenticationKey(authKey.getEid(), authKey.getMappingAuthkey());
    }
}
Also used : AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)

Example 12 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 convertToBinaryIfNecessary.

private static AuthenticationKey convertToBinaryIfNecessary(AuthenticationKey authKey) {
    Eid originalEid = authKey.getEid();
    if (LispAddressUtil.addressNeedsConversionToBinary(originalEid.getAddress())) {
        AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder(authKey);
        akb.setEid(LispAddressUtil.convertToBinary(originalEid));
        return akb.build();
    }
    return authKey;
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)

Example 13 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 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);
            mapSystem.removeAuthenticationKey(convertedAuthKey.getEid());
        } 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);
            mapSystem.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
        } 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 14 with AuthenticationKey

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

the class DSBEInputUtil method toAuthenticationKey.

public static AuthenticationKey toAuthenticationKey(Eid key, MappingAuthkey authKey) {
    AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
    akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
    akb.setEid(key);
    akb.setMappingAuthkey(authKey);
    return akb.build();
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)

Example 15 with AuthenticationKey

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

the class RPCInputConvertorUtil method toAuthenticationKey.

private static AuthenticationKey toAuthenticationKey(Eid address, MappingAuthkey key) {
    AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
    akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(address)));
    akb.setEid(address);
    if (key != null) {
        akb.setMappingAuthkey(key);
    }
    return akb.build();
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)

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