diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-06-14 10:35:53 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-06-15 10:32:10 +0000 |
commit | a96c6eb24b09a5106d9a4217b36d3daa8786de5d (patch) | |
tree | 27df8199268d80b71965707e421ece08ccea2213 /v3po/v3po2vpp/src/main | |
parent | 6c8836de587b137c6e8d15f6832ce457b5f2bed4 (diff) |
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 <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java | 25 |
1 files changed, 12 insertions, 13 deletions
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<BridgeDomain> id, @Nonnull final BridgeDomain dataBefore, |