summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-06-14 10:35:53 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-06-15 10:32:10 +0000
commit3508bc959e055c76c395e0f878d3c9f138f44114 (patch)
treec8881f6172644808d9f7199dfa198856d77656f7 /v3po/v3po2vpp/src/main
parent0624f45d8cf3656f6805316834eb025acb1f0453 (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.java25
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,