Search in sources :

Example 26 with Mapping

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

the class PortDataProcessor method delete.

@Override
public void delete(Port port) {
    // TODO if port ips existed in MapServer, delete them. Else, log error.
    LOG.info("Neutron Port Deleted: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
    LOG.debug("Neutron Port Deleted : " + port.toString());
    List<FixedIps> fixedIPs = port.getFixedIps();
    if (fixedIPs != null && fixedIPs.size() > 0) {
        Eid eidAddress;
        for (FixedIps ip : fixedIPs) {
            // TODO Add check/support for IPv6.
            // Get subnet for this port, based on v4 or v6 decide address
            // iana code.
            eidAddress = LispAddressUtil.asIpv4PrefixEid(ip.getIpAddress().getIpv4Address().getValue() + "/32");
            lispNeutronService.getMappingDbService().removeMapping(LispUtil.buildRemoveMappingInput(eidAddress));
            LOG.info("Neutron Port mapping deleted from lisp: " + " Port Fixed IP: " + ip + "Port host IP: ");
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Example 27 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping 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 28 with Mapping

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

the class MappingServiceIntegrationTest method test14SBpositiveToSBmoreSpecific.

/*
     * Mapping change: adding a more specific southbound mapping overlapping a less specific one
     * Support status: SUPPORTED
     * Description: When a more specific SB mapping is added, the subscribers of the overlapping less specific existing
     *              SB mapping are notified.
     */
private void test14SBpositiveToSBmoreSpecific() {
    cleanUP();
    allowNullAuthenticationForAllIPv4(1L);
    insertSBMappings(false, 1L, "192.168.0.0/16");
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    Eid expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
    registerSBMapping(1L, "192.168.254.0/24", "10.10.10.10");
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.254.1/32"));
    expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.254.0/24");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 29 with Mapping

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

the class MappingServiceIntegrationTest method timedOutMappingRecord.

private void timedOutMappingRecord() {
    cleanUP();
    mapService.setMappingMerge(true);
    // mapping expires after 1 second
    ConfigIni.getInstance().setRegistrationValiditySb(1000L);
    final Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32", new InstanceIdType(10L));
    final MappingRecord mappingRecord = MappingServiceIntegrationTestUtil.getDefaultMappingRecordBuilder(eid).setRecordTtl(1000).build();
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    mapService.addMapping(MappingOrigin.Southbound, eid, MappingServiceIntegrationTestUtil.DEFAULT_SITE_ID, new MappingData(mappingRecord, System.currentTimeMillis()));
    sleepForSeconds(2);
    MappingRecord resultRecord = (MappingRecord) mapService.getMapping(MappingOrigin.Southbound, eid);
    assertNull(resultRecord);
    ConfigIni.getInstance().setRegistrationValiditySb(ConfigIni.getInstance().getDefaultRegistrationValiditySb());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) InstanceIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 30 with Mapping

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

the class MappingServiceIntegrationTest method registerSBMapping.

private void registerSBMapping(long iid, String prefix, String locator) {
    LOG.debug("Registering Southbound mapping in VNI {} for prefix {}, locator {}" + " via simulated Map-Register a.k.a. handleMapRegister()", iid, prefix, locator);
    Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid(iid, prefix);
    Rloc rloc = LispAddressUtil.asIpv4Rloc(locator);
    MapRegister mr = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid, rloc).build();
    lms.handleMapRegister(mr);
    sleepForMilliseconds(100);
    MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)34 Test (org.junit.Test)32 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)32 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)26 ArrayList (java.util.ArrayList)21 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)16 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)14 BigInteger (java.math.BigInteger)13 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)11 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)11 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)10 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)8 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)8 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)8 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)8 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)8