Search in sources :

Example 61 with Ipv4

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.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());
}
Also used : InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) LispAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress) NoAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress) Inet4Address(java.net.Inet4Address) Inet6Address(java.net.Inet6Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyValueAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Example 62 with Ipv4

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.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);
}
Also used : InOrder(org.mockito.InOrder) MapRegisterCacheKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey) AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) Test(org.junit.Test)

Example 63 with Ipv4

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.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);
}
Also used : RemoveMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput) Test(org.junit.Test)

Example 64 with Ipv4

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.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);
}
Also used : Interface2(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4)

Example 65 with Ipv4

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.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));
    }
}
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)

Aggregations

Test (org.junit.Test)89 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)35 ArrayList (java.util.ArrayList)32 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)23 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)22 ByteBuf (io.netty.buffer.ByteBuf)21 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)19 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)18 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)17 BigInteger (java.math.BigInteger)16 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)15 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)14 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)14 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)14 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)12 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)11 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)11 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)11 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)10 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)10