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();
}
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());
}
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));
}
}
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());
}
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);
}
Aggregations