use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_ipv4.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
* LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
* methods with ipv4 address.
*/
@Test
public void addressFromIpPrefix_ipv4() {
IpPrefix ipv4Prefix = new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv4Prefix);
assertEquals(Ipv4PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(ipv4Prefix);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
assertEquals(IPV4_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address).getIpv4Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method mapRegister_isMappingKeepAliveAndMapNotifyGenerated.
/**
* Tests whether handling of map-register message will generate mapping-keep-alive notification.
*/
@Test
public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException, UnknownHostException {
byte[] eidPrefixAfi = new byte[] { // eid-prefix-afi
0x00, 0x01 };
byte[] eidPrefix = new byte[] { // ipv4 address
0x0a, 0x0a, 0x0a, 0x0a };
// send stream of byte -> map register message
InOrder inOrder = Mockito.inOrder(mockLispSouthboundPlugin);
final MapRegisterCacheKey cacheKey = MapRegisterCacheTestUtil.createMapRegisterCacheKey(eidPrefix);
MapRegisterCacheTestUtil.beforeMapRegisterInvocationValidation(cacheKey, mapRegisterCache);
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
MapRegisterCacheTestUtil.afterMapRegisterInvocationValidation(cacheKey, mapRegisterCache, eidPrefixAfi, eidPrefix);
// sending the same byte stream -> map register second time
captor = ArgumentCaptor.forClass(AddMapping.class);
mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
// mapping-keep-alive message should be generated
MapRegisterCacheTestUtil.afterSecondMapRegisterInvocationValidation(mockLispSouthboundPlugin, eidPrefixAfi, eidPrefix);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class PortDataProcessorTest method deleteTest.
/**
* Tests {@link PortDataProcessor#delete} method.
*/
@Test
public void deleteTest() {
// expected result
final RemoveMappingInput expectedResult = LispUtil.buildRemoveMappingInput(LispAddressUtil.asIpv4PrefixEid(IPV4 + "/32"));
portDataProcessor.delete(portMock);
Mockito.verify(odlMappingserviceServiceMock).removeMapping(expectedResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class VppNodeReader method readIpAddressFromInterface.
private Optional<Ipv4Address> readIpAddressFromInterface(Interface intf, KeyedInstanceIdentifier iiToVpp) {
Interface2 augIntf = intf.getAugmentation(Interface2.class);
if (augIntf == null) {
LOG.debug("Cannot get Interface2 augmentation for intf {}");
return Optional.absent();
}
Ipv4 ipv4 = augIntf.getIpv4();
if (ipv4 == null) {
LOG.debug("Ipv4 address for interface {} on node {} is null!", augIntf, InfoUtil.node(iiToVpp));
return Optional.absent();
}
final List<Address> addresses = ipv4.getAddress();
if (addresses == null || addresses.isEmpty()) {
LOG.debug("Ipv4 addresses list is empty for interface {} on node {}", augIntf, InfoUtil.node(iiToVpp));
return Optional.absent();
}
final Ipv4AddressNoZone ip = addresses.iterator().next().getIp();
if (ip == null) {
LOG.debug("Ipv4AddressNoZone is null for node {}", InfoUtil.node(iiToVpp));
return Optional.absent();
}
LOG.debug("Got ip address {} from interface {} on node {}", ip.getValue(), intf.getName(), InfoUtil.node(iiToVpp));
return Optional.of(ip);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 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));
}
}
Aggregations