diff options
Diffstat (limited to 'lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write')
8 files changed, 447 insertions, 10 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java index e2943c670..494afd3cb 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java @@ -22,26 +22,28 @@ import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDump import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6; import static java.nio.charset.StandardCharsets.UTF_8; +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.context.util.EidMappingContext; import io.fd.hc2vpp.lisp.translate.read.trait.MappingProducer; import io.fd.hc2vpp.lisp.translate.util.EidTranslator; import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -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.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEid; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeoutException; import javax.annotation.Nonnull; 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.local.mappings.LocalMapping; 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.HmacKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.LispAddDelLocalEid; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; /** @@ -129,6 +131,14 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer request.prefixLen = (byte) 128; } + final HmacKey hmacKey = data.getHmacKey(); + if (hmacKey != null) { + request.key = checkNotNull(hmacKey.getKey(), "HMAC key not specified") + .getBytes(StandardCharsets.UTF_8); + request.keyId = (byte) checkNotNull(hmacKey.getKeyType(), + "HMAC key type not specified").getIntValue(); + } + getReply(getFutureJVpp().lispAddDelLocalEid(request).toCompletableFuture()); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java new file mode 100644 index 000000000..1dac298a3 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java @@ -0,0 +1,66 @@ +/* + * 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.write; + +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.honeycomb.translate.spi.write.WriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisable; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import javax.annotation.Nonnull; + +public class MapRegisterCustomizer extends FutureJVppCustomizer + implements WriterCustomizer<MapRegister>, ByteDataTranslator, JvppReplyConsumer { + + public MapRegisterCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Override + public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier, + @Nonnull MapRegister mapRegister, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enableDisableMapRegister(mapRegister.isEnabled(), instanceIdentifier); + } + + @Override + public void updateCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier, + @Nonnull MapRegister mapRegisterBefore, + @Nonnull MapRegister mapRegisterAfter, @Nonnull + WriteContext writeContext) throws WriteFailedException { + enableDisableMapRegister(mapRegisterAfter.isEnabled(), instanceIdentifier); + } + + @Override + public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier, + @Nonnull MapRegister mapRegister, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enableDisableMapRegister(false, instanceIdentifier); + } + + private void enableDisableMapRegister(final boolean enable, @Nonnull final InstanceIdentifier<MapRegister> id) throws WriteFailedException { + LispMapRegisterEnableDisable request = new LispMapRegisterEnableDisable(); + request.isEnabled = booleanToByte(enable); + getReplyForWrite(getFutureJVpp().lispMapRegisterEnableDisable(request).toCompletableFuture(), id); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java new file mode 100644 index 000000000..0e069504d --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.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.write; + +import static com.google.common.base.Preconditions.checkNotNull; + +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.honeycomb.translate.spi.write.WriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.LispMapRequestMode; +import io.fd.vpp.jvpp.core.dto.LispMapRequestModeReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.concurrent.CompletableFuture; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MapRequestModeCustomizer extends FutureJVppCustomizer + implements WriterCustomizer<MapRequestMode>, JvppReplyConsumer { + + private static final Logger LOG = LoggerFactory.getLogger(MapRequestModeCustomizer.class); + + public MapRequestModeCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Override + public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier, + @Nonnull MapRequestMode mapRequestMode, + @Nonnull WriteContext writeContext) throws WriteFailedException { + getReplyForWrite(mapRequestModeRequestFuture(mapRequestMode), instanceIdentifier); + } + + @Override + public void updateCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier, + @Nonnull MapRequestMode mapRequestModeBefore, + @Nonnull MapRequestMode mapRequestModeAfter, @Nonnull WriteContext writeContext) + throws WriteFailedException { + getReplyForUpdate(mapRequestModeRequestFuture(mapRequestModeAfter), instanceIdentifier, + mapRequestModeBefore, mapRequestModeAfter); + } + + @Override + public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier, + @Nonnull MapRequestMode mapRequestMode, + @Nonnull WriteContext writeContext) throws WriteFailedException { + //TODO - after HC2VPP-115 - change to throw UnsupportedOperationException + LOG.error("Map request mode cannot be deleted, ignoring"); + } + + private CompletableFuture<LispMapRequestModeReply> mapRequestModeRequestFuture( + @Nonnull final MapRequestMode mapRequestMode) { + LispMapRequestMode request = new LispMapRequestMode(); + request.mode = (byte) checkNotNull(mapRequestMode.getMode(), + "Mode not specified").getIntValue(); + return getFutureJVpp().lispMapRequestMode(request).toCompletableFuture(); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java new file mode 100644 index 000000000..9697e16bc --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.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.write; + +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.spi.write.ListWriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.LispAddDelMapServer; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +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.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.MapServerKey; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import javax.annotation.Nonnull; + +public class MapServerCustomizer extends FutureJVppCustomizer + implements ListWriterCustomizer<MapServer, MapServerKey>, AddressTranslator, + JvppReplyConsumer { + + public MapServerCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Override + public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, + @Nonnull MapServer mapServer, + @Nonnull WriteContext writeContext) throws WriteFailedException { + addDelMapServer(true, instanceIdentifier, mapServer); + } + + @Override + public void updateCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, + @Nonnull MapServer mapServerBefore, + @Nonnull MapServer mapServerAfter, + @Nonnull WriteContext writeContext) throws WriteFailedException { + throw new WriteFailedException.UpdateFailedException(instanceIdentifier, mapServerBefore, mapServerAfter, + new UnsupportedOperationException("Not supported")); + } + + @Override + public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, @Nonnull MapServer mapServer, @Nonnull WriteContext writeContext) throws WriteFailedException { + addDelMapServer(false, instanceIdentifier, mapServer); + } + + private void addDelMapServer(final boolean add, + @Nonnull final InstanceIdentifier<MapServer> id, + @Nonnull final MapServer data) throws WriteFailedException { + LispAddDelMapServer request = new LispAddDelMapServer(); + + final IpAddress ipAddress = data.getIpAddress(); + + request.isAdd = booleanToByte(add); + request.isIpv6 = booleanToByte(isIpv6(ipAddress)); + request.ipAddress = ipAddressToArray(ipAddress); + + getReplyForWrite(getFutureJVpp().lispAddDelMapServer(request).toCompletableFuture(), id); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java new file mode 100644 index 000000000..d3a381490 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java @@ -0,0 +1,82 @@ +/* + * 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.write; + +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.spi.write.WriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.LispUsePetr; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +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.use.petr.cfg.grouping.PetrCfg; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import javax.annotation.Nonnull; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class PetrCfgCustomizer extends FutureJVppCustomizer + implements WriterCustomizer<PetrCfg>, AddressTranslator, JvppReplyConsumer { + + public PetrCfgCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Override + public void writeCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, + @Nonnull PetrCfg petrCfg, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enablePetrCfg(instanceIdentifier, petrCfg); + } + + @Override + public void updateCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, + @Nonnull PetrCfg petrCfgBefore, + @Nonnull PetrCfg petrCfgAfter, + @Nonnull WriteContext writeContext) throws WriteFailedException { + if (petrCfgAfter.getPetrAddress() != null) { + enablePetrCfg(instanceIdentifier, petrCfgAfter); + } else { + disablePetrCfg(instanceIdentifier); + } + } + + @Override + public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, @Nonnull PetrCfg petrCfg, @Nonnull WriteContext writeContext) throws WriteFailedException { + disablePetrCfg(instanceIdentifier); + } + + private void enablePetrCfg(@Nonnull final InstanceIdentifier<PetrCfg> id, @Nonnull final PetrCfg data) throws WriteFailedException { + LispUsePetr request = new LispUsePetr(); + + final IpAddress petrAddress = checkNotNull(data.getPetrAddress(), "PETR address not defined"); + request.isAdd = 1; + request.address = ipAddressToArray(petrAddress); + request.isIp4 = booleanToByte(!isIpv6(petrAddress)); + getReplyForWrite(getFutureJVpp().lispUsePetr(request).toCompletableFuture(), id); + } + + private void disablePetrCfg(@Nonnull final InstanceIdentifier<PetrCfg> id) throws WriteFailedException { + LispUsePetr request = new LispUsePetr(); + request.isAdd = 0; + getReplyForDelete(getFutureJVpp().lispUsePetr(request).toCompletableFuture(), id); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java new file mode 100644 index 000000000..b240d1d2e --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java @@ -0,0 +1,68 @@ +/* + * 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.write; + +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.honeycomb.translate.spi.write.WriterCustomizer; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisable; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import javax.annotation.Nonnull; + +public class RlocProbeCustomizer extends FutureJVppCustomizer + implements WriterCustomizer<RlocProbe>, ByteDataTranslator, JvppReplyConsumer { + + public RlocProbeCustomizer(@Nonnull FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Override + public void writeCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier, + @Nonnull RlocProbe rlocProbe, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enableDisableRlocProbe(rlocProbe.isEnabled(), instanceIdentifier); + } + + @Override + public void updateCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier, + @Nonnull RlocProbe rlocProbeBefore, + @Nonnull RlocProbe rlocProbeAfter, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enableDisableRlocProbe(rlocProbeAfter.isEnabled(), instanceIdentifier); + } + + @Override + public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier, + @Nonnull RlocProbe rlocProbe, + @Nonnull WriteContext writeContext) throws WriteFailedException { + enableDisableRlocProbe(false, instanceIdentifier); + } + + private void enableDisableRlocProbe(final boolean enable, @Nonnull final InstanceIdentifier<RlocProbe> id) throws WriteFailedException { + LispRlocProbeEnableDisable request = new LispRlocProbeEnableDisable(); + + request.isEnabled = booleanToByte(enable); + + getReplyForWrite(getFutureJVpp().lispRlocProbeEnableDisable(request).toCompletableFuture(), id); + } +} diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java index b2ce44e82..ed7d2122a 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java @@ -21,14 +21,22 @@ import static io.fd.hc2vpp.lisp.translate.write.factory.LocatorSetWriterFactory. import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase; import io.fd.hc2vpp.lisp.translate.write.LispCustomizer; +import io.fd.hc2vpp.lisp.translate.write.MapRegisterCustomizer; +import io.fd.hc2vpp.lisp.translate.write.MapRequestModeCustomizer; +import io.fd.hc2vpp.lisp.translate.write.PetrCfgCustomizer; import io.fd.hc2vpp.lisp.translate.write.PitrCfgCustomizer; +import io.fd.hc2vpp.lisp.translate.write.RlocProbeCustomizer; import io.fd.honeycomb.translate.impl.write.GenericWriter; import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; 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.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; @@ -36,13 +44,27 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * Initialize writers for {@link Lisp} */ public final class LispWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory { - private final InstanceIdentifier<Lisp> lispInstanceIdentifier = InstanceIdentifier.create(Lisp.class); + private static final InstanceIdentifier<Lisp> LISP_INSTANCE_IDENTIFIER = InstanceIdentifier.create(Lisp.class); + private static final InstanceIdentifier<LispFeatureData> LISP_FEATURE_IDENTIFIER = + LISP_INSTANCE_IDENTIFIER.child(LispFeatureData.class); @Override public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) { - registry.add(new GenericWriter<>(lispInstanceIdentifier, new LispCustomizer(vppApi))); + registry.add(new GenericWriter<>(LISP_INSTANCE_IDENTIFIER, new LispCustomizer(vppApi))); - registry.addAfter(new GenericWriter<>(lispInstanceIdentifier.child(LispFeatureData.class).child(PitrCfg.class), - new PitrCfgCustomizer(vppApi)),LOCATOR_SET_ID); + registry.addAfter(writer(LISP_FEATURE_IDENTIFIER.child(PitrCfg.class), + new PitrCfgCustomizer(vppApi)), LOCATOR_SET_ID); + + registry.add(writer(LISP_FEATURE_IDENTIFIER.child(MapRegister.class), + new MapRegisterCustomizer(vppApi))); + + registry.add(writer(LISP_FEATURE_IDENTIFIER.child(MapRequestMode.class), + new MapRequestModeCustomizer(vppApi))); + + registry.add(writer(LISP_FEATURE_IDENTIFIER.child(PetrCfg.class), + new PetrCfgCustomizer(vppApi))); + + registry.add(writer(LISP_FEATURE_IDENTIFIER.child(RlocProbe.class), + new RlocProbeCustomizer(vppApi))); } } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java new file mode 100644 index 000000000..fc0cc4d10 --- /dev/null +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java @@ -0,0 +1,37 @@ +/* + * 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.write.factory; + +import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase; +import io.fd.hc2vpp.lisp.translate.write.MapServerCustomizer; +import io.fd.honeycomb.translate.impl.write.GenericListWriter; +import io.fd.honeycomb.translate.write.WriterFactory; +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; +import javax.annotation.Nonnull; +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.map.servers.MapServer; + +public class MapServerWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory { + + @Override + public void init(@Nonnull ModifiableWriterRegistryBuilder registry) { + registry.add(new GenericListWriter<>( + LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(MapServers.class).child(MapServer.class), + new MapServerCustomizer(vppApi))); + } +} |