Search in sources :

Example 21 with Mapping

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

the class MeterStatsResponseConvertorTest method testToSALMeterStatsList.

@Test
public /**
 * Test of basic mapping functionality of {@link MeterStatsResponseConvertor#convert(java.util.List)}
 */
void testToSALMeterStatsList() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    List<MeterStats> meterStatsList = meterStatsListOptional.orElse(Collections.emptyList());
    assertEquals(PRESET_COUNT, meterStatsList.size());
    int cnt = 0;
    for (MeterStats meterStats : meterStatsList) {
        assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getKey().getMeterId());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
        assertEquals(new Long(1000 * cnt), meterStats.getDuration().getNanosecond().getValue());
        assertEquals(new Long(10 * cnt), meterStats.getDuration().getSecond().getValue());
        assertEquals(new Long(cnt), meterStats.getFlowCount().getValue());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
        assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size());
        int bandStatCount = 0;
        for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) {
            assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getByteBandCount().getValue());
            assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue());
            bandStatCount++;
        }
        assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getMeterId());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getPacketInCount().getValue());
        cnt++;
    }
}
Also used : MeterStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey) BandStat(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 22 with Mapping

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

the class Stringifier method getString.

public static String getString(MappingRecord mapping, int indentation) {
    final String indent = getSpacesAsString(indentation);
    StringBuilder mrsb = new StringBuilder(indent);
    // Main information, EID prefix and TTL (for now)
    mrsb.append(LispAddressStringifier.getString(mapping.getEid()));
    mrsb.append(", TTL: ");
    mrsb.append(mapping.getRecordTtl().toString());
    mrsb.append(NEW_LINE);
    // Locator records
    // Regular indentation for the mapping record
    mrsb.append(indent);
    // Extra indentation for locator records
    mrsb.append(indent);
    if (mapping.getLocatorRecord() == null || mapping.getLocatorRecord().isEmpty()) {
        // We only print the action for negative mappings (0 locator records)
        mrsb.append("-> Negative entry, action: ");
        mrsb.append(mapping.getAction().getName());
    } else {
        mrsb.append("-> Locator                                         State     Pri/Wgt");
        mrsb.append(NEW_LINE);
        mrsb.append(indent);
        boolean first = true;
        for (LocatorRecord record : mapping.getLocatorRecord()) {
            if (first) {
                first = false;
            } else {
                mrsb.append(NEW_LINE);
                mrsb.append(indent);
            }
            mrsb.append(getString(record, indentation + 3));
        }
    }
    return mrsb.toString();
}
Also used : LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 23 with Mapping

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

the class AuthKeyDb method getAuthenticationKey.

/*
     * Retrieves authentication key from the database. As opposed to the mapping cache, Source/Dest keys are treated as
     * exact match keys here, and a two level longest prefix match is NOT performed.
     */
@Override
public MappingAuthkey getAuthenticationKey(Eid eid) {
    ILispDAO table = getVniTable(eid);
    if (table == null) {
        return null;
    }
    if (MaskUtil.isMaskable(eid.getAddress()) && !(eid.getAddress() instanceof SourceDestKey)) {
        return getAuthKeyLpm(eid, table);
    } else {
        Eid key = MaskUtil.normalize(eid);
        Object password = table.getSpecific(key, SubKeys.AUTH_KEY);
        if (password != null && password instanceof MappingAuthkey) {
            return (MappingAuthkey) password;
        } else {
            LOG.warn("Failed to find password!");
            return null;
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Example 24 with Mapping

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

@Override
public void update(Port port) {
    final String hostId = port.getAugmentation(PortBindingExtension.class).getHostId();
    if (hostId == null) {
        LOG.error("Updating port to lisp mapping service failed. Port does not have a HostID. Port: {}", port.toString());
        return;
    }
    List<FixedIps> fixedIPs = port.getFixedIps();
    if (fixedIPs != null && fixedIPs.size() > 0) {
        Eid eidAddress;
        for (FixedIps ip : fixedIPs) {
            eidAddress = getEid(port, ip);
            PortData portData = new PortData(port.getUuid().getValue(), eidAddress);
            hostInformationManager.addHostRelatedInfo(hostId, portData);
        }
    }
    LOG.info("Neutron Port updated: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
    LOG.debug("Neutron Port Updated : " + port.toString());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) PortData(org.opendaylight.lispflowmapping.neutron.mappingmanager.PortData) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

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