Search in sources :

Example 1 with AddKeyInput

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

the class LispUtil method buildAddKeyInput.

public static AddKeyInput buildAddKeyInput(Eid eid, String net) {
    AddKeyInputBuilder kib = new AddKeyInputBuilder();
    kib.setEid(eid).setMappingAuthkey(new MappingAuthkeyBuilder().setKeyString(net).setKeyType(1).build());
    return kib.build();
}
Also used : MappingAuthkeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder)

Example 2 with AddKeyInput

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

the class SubnetDataProcessorTest method createTest.

/**
 * Tests {@link SubnetDataProcessor#create} method.
 */
@Test
public void createTest() throws ExecutionException, InterruptedException {
    final MappingAuthkey mappingAuthkey = new MappingAuthkeyBuilder().setKeyString(UUID_STRING).setKeyType(1).build();
    final AddKeyInput addKeyInput = new AddKeyInputBuilder().setEid(EID).setMappingAuthkey(mappingAuthkey).build();
    commonStubbing();
    Mockito.when(odlMappingserviceServiceMock.addKey(addKeyInput)).thenReturn(future);
    subnetDataProcessor.create(subnet);
    assertEquals(true, rpcResult.isSuccessful());
}
Also used : AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) MappingAuthkeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder) Test(org.junit.Test)

Example 3 with AddKeyInput

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

the class SubnetDataProcessor method create.

/**
 * Method adds the newly created subnet as an EID prefix to the
 * MappingService. The subnet's network UUID is used as the key for this EID
 * prefix.
 */
@Override
public void create(Subnet subnet) {
    // TODO update for multi-tenancy
    LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
    LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
    // Determine the IANA code for the subnet IP version
    // Default is set to IPv4 for neutron subnets
    final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
    try {
        final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
        if (lfmdb == null) {
            LOG.debug("lfmdb is null!!!");
            return;
        }
        final AddKeyInput addKeyInput = LispUtil.buildAddKeyInput(eid, subnet.getUuid().getValue());
        final Future<RpcResult<Void>> result = lfmdb.addKey(addKeyInput);
        final Boolean isSuccessful = result.get().isSuccessful();
        if (isSuccessful) {
            LOG.debug("Neutron Subnet Added to MapServer : Subnet name: " + subnet.getName() + " EID Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
        }
        LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Adding new subnet to lisp service mapping service failed. Subnet : " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) OdlMappingserviceService(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with AddKeyInput

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

the class MappingService method addKey.

@Override
public Future<RpcResult<Void>> addKey(AddKeyInput input) {
    Preconditions.checkNotNull(input, "add-key RPC input must be not null!");
    LOG.trace("RPC received to add the following key: " + input.toString());
    RpcResultBuilder<Void> rpcResultBuilder;
    MappingAuthkey key = mappingSystem.getAuthenticationKey(convertToBinaryIfNecessary(input.getEid()));
    if (key != null) {
        String message = "Key already exists! Please use update-key if you want to change it.";
        rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.PROTOCOL, DATA_EXISTS_TAG, message);
        return Futures.immediateFuture(rpcResultBuilder.build());
    }
    dsbe.addAuthenticationKey(RPCInputConvertorUtil.toAuthenticationKey(input));
    rpcResultBuilder = RpcResultBuilder.success();
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)

Example 5 with AddKeyInput

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

the class LispUtilTest method buildAddKeyInputTest.

/**
 * Tests {@link LispUtil#buildAddKeyInput} method.
 */
@Test
public void buildAddKeyInputTest() {
    final AddKeyInput expectedResult = new AddKeyInputBuilder().setEid(EID).setMappingAuthkey(new MappingAuthkeyBuilder().setKeyString(KEY).setKeyType(1).build()).build();
    final AddKeyInput result = LispUtil.buildAddKeyInput(EID, KEY);
    assertEquals(expectedResult, result);
}
Also used : AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) MappingAuthkeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder) Test(org.junit.Test)

Aggregations

AddKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput)5 AddKeyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder)5 Test (org.junit.Test)4 MappingAuthkeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder)4 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 ExecutionException (java.util.concurrent.ExecutionException)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1 OdlMappingserviceService (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1