diff options
Diffstat (limited to 'lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read')
8 files changed, 520 insertions, 3 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java index 44f5f2dd2..69df09c80 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java @@ -35,6 +35,7 @@ import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.HmacKeyType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MappingId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.LocalMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.LocalMappingsBuilder; @@ -42,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.local.mappings.LocalMappingBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.local.mappings.LocalMappingKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.hmac.key.grouping.HmacKeyBuilder; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -133,6 +135,16 @@ public class LocalMappingCustomizer builder.setLocatorSet(locatorSetContext.getName(details.locatorSetIndex, ctx.getMappingContext())); builder.setKey(new LocalMappingKey(new MappingId(id.firstKeyOf(LocalMapping.class).getId()))); builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid, details.vni)); + + if (details.key != null) { + builder.setHmacKey( + new HmacKeyBuilder() + .setKey(toString(details.key)) + .setKeyType(HmacKeyType.forValue(details.keyId)) + .build()); + } else { + builder.setHmacKey(new HmacKeyBuilder().setKeyType(HmacKeyType.NoKey).build()); + } } private Address getAddressFromDumpDetail(final LispEidTableDetails detail) { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java new file mode 100644 index 000000000..e94bb92f0 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read; + +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterState; +import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterStateReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class MapRegisterCustomizer extends FutureJVppCustomizer + implements InitializingReaderCustomizer<MapRegister, MapRegisterBuilder>, ByteDataTranslator, + JvppReplyConsumer, LispInitPathsMapper { + + public MapRegisterCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public MapRegisterBuilder getBuilder(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier) { + return new MapRegisterBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier, + @Nonnull MapRegisterBuilder mapRegisterBuilder, + @Nonnull ReadContext readContext) throws ReadFailedException { + final ShowLispMapRegisterStateReply read = getReplyForRead(getFutureJVpp() + .showLispMapRegisterState(new ShowLispMapRegisterState()).toCompletableFuture(), instanceIdentifier); + + if (read != null) { + mapRegisterBuilder.setEnabled(byteToBoolean(read.isEnabled)); + } + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull MapRegister mapRegister) { + LispFeatureDataBuilder.class.cast(builder).setMapRegister(mapRegister); + } + + @Nonnull + @Override + public Initialized<? extends DataObject> init(@Nonnull final InstanceIdentifier<MapRegister> instanceIdentifier, + @Nonnull final MapRegister mapRegister, + @Nonnull final ReadContext readContext) { + return Initialized.create(lispFeaturesBasePath().child(MapRegister.class), mapRegister); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java new file mode 100644 index 000000000..9de5b5c68 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read; + +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.vpp.jvpp.core.dto.ShowLispMapRequestMode; +import io.fd.vpp.jvpp.core.dto.ShowLispMapRequestModeReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestModeBuilder; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class MapRequestModeCustomizer extends FutureJVppCustomizer + implements InitializingReaderCustomizer<MapRequestMode, MapRequestModeBuilder>, + JvppReplyConsumer, LispInitPathsMapper { + + public MapRequestModeCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public MapRequestModeBuilder getBuilder(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier) { + return new MapRequestModeBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier, + @Nonnull MapRequestModeBuilder mapRequestModeBuilder, + @Nonnull ReadContext readContext) throws ReadFailedException { + final ShowLispMapRequestModeReply reply = getReplyForRead( + getFutureJVpp().showLispMapRequestMode(new ShowLispMapRequestMode()).toCompletableFuture(), + instanceIdentifier); + + if (reply != null) { + mapRequestModeBuilder.setMode( + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode + .forValue(reply.mode)); + } + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, + @Nonnull MapRequestMode mapRequestMode) { + LispFeatureDataBuilder.class.cast(builder).setMapRequestMode(mapRequestMode); + } + + @Nonnull + @Override + public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier, + @Nonnull MapRequestMode mapRequestMode, + @Nonnull ReadContext readContext) { + return Initialized.create(lispFeaturesBasePath().child(MapRequestMode.class), mapRequestMode); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java new file mode 100644 index 000000000..8e53f265d --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read; + +import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS; + +import com.google.common.base.Optional; +import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; +import io.fd.honeycomb.translate.util.RWUtils; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder; +import io.fd.vpp.jvpp.core.dto.LispMapServerDetails; +import io.fd.vpp.jvpp.core.dto.LispMapServerDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.LispMapServerDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServers; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServersBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerKey; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class MapServerCustomizer extends FutureJVppCustomizer + implements InitializingListReaderCustomizer<MapServer, MapServerKey, MapServerBuilder>, JvppReplyConsumer, + AddressTranslator { + + private final DumpCacheManager<LispMapServerDetailsReplyDump, Void> dumpManager; + + public MapServerCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + dumpManager = new DumpCacheManagerBuilder<LispMapServerDetailsReplyDump, Void>() + .acceptOnly(LispMapServerDetailsReplyDump.class) + .withExecutor((instanceIdentifier, aVoid) -> + getReplyForRead(getFutureJVpp() + .lispMapServerDump(new LispMapServerDump()).toCompletableFuture(), instanceIdentifier)) + .build(); + } + + @Nonnull + @Override + public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, + @Nonnull MapServer mapServer, + @Nonnull ReadContext readContext) { + final InstanceIdentifier<MapServer> configId = InstanceIdentifier.create(Lisp.class) + .child(LispFeatureData.class) + .child(MapServers.class) + .child(MapServer.class, instanceIdentifier.firstKeyOf(MapServer.class)); + + return Initialized.create(configId, mapServer); + } + + @Nonnull + @Override + public List<MapServerKey> getAllIds(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, + @Nonnull ReadContext readContext) throws ReadFailedException { + + final Optional<LispMapServerDetailsReplyDump> dump = + dumpManager.getDump(instanceIdentifier, readContext.getModificationCache(), NO_PARAMS); + + if (dump.isPresent() && dump.get().lispMapServerDetails != null) { + return dump.get().lispMapServerDetails.stream() + .map(detail -> arrayToIpAddress(byteToBoolean(detail.isIpv6), detail.ipAddress)) + .map(MapServerKey::new) + .collect(Collectors.toList()); + } + + return Collections.emptyList(); + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull List<MapServer> list) { + MapServersBuilder.class.cast(builder).setMapServer(list); + } + + @Nonnull + @Override + public MapServerBuilder getBuilder(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier) { + return new MapServerBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, + @Nonnull MapServerBuilder mapServerBuilder, @Nonnull ReadContext readContext) + throws ReadFailedException { + final Optional<LispMapServerDetailsReplyDump> dump = + dumpManager.getDump(instanceIdentifier, readContext.getModificationCache(), NO_PARAMS); + + if (dump.isPresent() && dump.get().lispMapServerDetails != null) { + final IpAddress currentAddress = instanceIdentifier.firstKeyOf(MapServer.class).getIpAddress(); + + final LispMapServerDetails currentDetail = dump.get().lispMapServerDetails.stream() + .filter(detail -> Arrays.equals(currentAddress.getValue(), + arrayToIpAddress(byteToBoolean(detail.isIpv6), detail.ipAddress).getValue())) + .collect(RWUtils.singleItemCollector()); + + mapServerBuilder + .setIpAddress(arrayToIpAddress(byteToBoolean(currentDetail.isIpv6), currentDetail.ipAddress)); + + } + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java new file mode 100644 index 000000000..0e27a0ee8 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read; + +import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.vpp.jvpp.core.dto.ShowLispUsePetr; +import io.fd.vpp.jvpp.core.dto.ShowLispUsePetrReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfg; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfgBuilder; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class PetrCfgCustomizer extends FutureJVppCustomizer + implements InitializingReaderCustomizer<PetrCfg, PetrCfgBuilder>, JvppReplyConsumer, + AddressTranslator, LispInitPathsMapper { + + public PetrCfgCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, + @Nonnull PetrCfg petrCfg, + @Nonnull ReadContext readContext) { + return Initialized.create(lispFeaturesBasePath().child(PetrCfg.class), petrCfg); + } + + @Nonnull + @Override + public PetrCfgBuilder getBuilder(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier) { + return new PetrCfgBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, + @Nonnull PetrCfgBuilder petrCfgBuilder, + @Nonnull ReadContext readContext) throws ReadFailedException { + final ShowLispUsePetrReply read = getReplyForRead(getFutureJVpp().showLispUsePetr(new ShowLispUsePetr()) + .toCompletableFuture(), instanceIdentifier); + + if (read != null && read.status != 0) { + // TODO - https://jira.fd.io/browse/VPP-660 - returns address back in bad form + petrCfgBuilder.setPetrAddress(arrayToIpAddress(!byteToBoolean(read.isIp4), read.address)); + } + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull PetrCfg petrCfg) { + LispFeatureDataBuilder.class.cast(builder).setPetrCfg(petrCfg); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java new file mode 100644 index 000000000..bd0070141 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read; + +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.vpp.jvpp.core.dto.ShowLispRlocProbeState; +import io.fd.vpp.jvpp.core.dto.ShowLispRlocProbeStateReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbeBuilder; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class RlocProbeCustomizer extends FutureJVppCustomizer + implements InitializingReaderCustomizer<RlocProbe, RlocProbeBuilder>, JvppReplyConsumer, ByteDataTranslator, + LispInitPathsMapper { + + public RlocProbeCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public RlocProbeBuilder getBuilder(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier) { + return new RlocProbeBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier, + @Nonnull RlocProbeBuilder rlocProbeBuilder, + @Nonnull ReadContext readContext) throws ReadFailedException { + final ShowLispRlocProbeStateReply read = getReplyForRead(getFutureJVpp() + .showLispRlocProbeState(new ShowLispRlocProbeState()).toCompletableFuture(), instanceIdentifier); + + if (read != null) { + rlocProbeBuilder.setEnabled(byteToBoolean(read.isEnabled)); + } + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull RlocProbe rlocProbe) { + LispFeatureDataBuilder.class.cast(builder).setRlocProbe(rlocProbe); + } + + @Nonnull + @Override + public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier, + @Nonnull RlocProbe rlocProbe, + @Nonnull ReadContext readContext) { + return Initialized.create(lispFeaturesBasePath().child(RlocProbe.class), rlocProbe); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java index 345fe46ad..b7bd37588 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java @@ -18,18 +18,25 @@ package io.fd.hc2vpp.lisp.translate.read.factory; import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase; import io.fd.hc2vpp.lisp.translate.read.LispStateCustomizer; +import io.fd.hc2vpp.lisp.translate.read.MapRegisterCustomizer; +import io.fd.hc2vpp.lisp.translate.read.MapRequestModeCustomizer; +import io.fd.hc2vpp.lisp.translate.read.PetrCfgCustomizer; import io.fd.hc2vpp.lisp.translate.read.PitrCfgCustomizer; +import io.fd.hc2vpp.lisp.translate.read.RlocProbeCustomizer; import io.fd.honeycomb.translate.impl.read.GenericInitReader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; +import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispState; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfg; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import javax.annotation.Nonnull; - /** * Initialize readers for {@link LispState} @@ -37,6 +44,8 @@ import javax.annotation.Nonnull; public class LispStateReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory { private static final InstanceIdentifier<LispState> lispStateId = InstanceIdentifier.create(LispState.class); + static final InstanceIdentifier<LispFeatureData> + LISP_FEATURE_ID = lispStateId.child(LispFeatureData.class); @Override public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) { @@ -44,7 +53,19 @@ public class LispStateReaderFactory extends AbstractLispInfraFactoryBase impleme registry.add(new GenericInitReader<>(lispStateId, new LispStateCustomizer(vppApi))); registry.addStructuralReader(lispStateId.child(LispFeatureData.class), LispFeatureDataBuilder.class); - registry.add(new GenericInitReader<>(lispStateId.child(LispFeatureData.class).child(PitrCfg.class), + registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(PitrCfg.class), new PitrCfgCustomizer(vppApi))); + + registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(RlocProbe.class), + new RlocProbeCustomizer(vppApi))); + + registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(PetrCfg.class), + new PetrCfgCustomizer(vppApi))); + + registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(MapRegister.class), + new MapRegisterCustomizer(vppApi))); + + registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(MapRequestMode.class), + new MapRequestModeCustomizer(vppApi))); } } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java new file mode 100644 index 000000000..1af8f939f --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.lisp.translate.read.factory; + + +import static io.fd.hc2vpp.lisp.translate.read.factory.LispStateReaderFactory.LISP_FEATURE_ID; + +import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase; +import io.fd.hc2vpp.lisp.translate.read.MapServerCustomizer; +import io.fd.honeycomb.translate.impl.read.GenericInitListReader; +import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServers; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServersBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServer; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class MapServerReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory { + + private static final InstanceIdentifier<MapServers> MAP_SERVERS_ID = LISP_FEATURE_ID.child(MapServers.class); + + @Override + public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) { + registry.addStructuralReader(MAP_SERVERS_ID, MapServersBuilder.class); + registry.add(new GenericInitListReader<>(MAP_SERVERS_ID.child(MapServer.class), + new MapServerCustomizer(vppApi))); + } +} |