From 3508bc959e055c76c395e0f878d3c9f138f44114 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 14 Jun 2016 10:35:53 +0200 Subject: HONEYCOMB-91: fix restoring BD from persisted config. Covers case when bd_id was present in the bdContext Change-Id: I817fc684f175958f772a87ee708fa7f49ceec6f7 Signed-off-by: Marek Gradzki --- .../translate/v3po/vpp/BridgeDomainCustomizer.java | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java index 710a74be5..3bc7ba175 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.v3po.translate.v3po.vpp; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -29,7 +30,6 @@ import io.fd.honeycomb.v3po.translate.write.WriteContext; import io.fd.honeycomb.v3po.translate.write.WriteFailedException; import java.util.List; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; @@ -89,12 +89,17 @@ public class BridgeDomainCustomizer final String bdName = dataBefore.getName(); try { - // FIXME we need the bd index to be returned by VPP or we should have a counter field - // (maybe in context similar to artificial name) - // Here we assign the next available ID from bdContext's perspective - int index = 1; - while (bdContext.containsName(index, ctx.getMappingContext())) { - index++; + int index; + if (bdContext.containsIndex(bdName, ctx.getMappingContext())) { + index = bdContext.getIndex(bdName, ctx.getMappingContext()); + } else { + // FIXME we need the bd index to be returned by VPP or we should have a counter field + // (maybe in context similar to artificial name) + // Here we assign the next available ID from bdContext's perspective + index = 1; + while (bdContext.containsName(index, ctx.getMappingContext())) { + index++; + } } addOrUpdateBridgeDomain(index, dataBefore); bdContext.addName(index, bdName, ctx.getMappingContext()); @@ -104,12 +109,6 @@ public class BridgeDomainCustomizer } } - private byte booleanToByte(@Nullable final Boolean aBoolean) { - return aBoolean != null && aBoolean - ? (byte) 1 - : (byte) 0; - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final BridgeDomain dataBefore, -- cgit 1.2.3-korg