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