In case of honeycomb restart, mapping context is read first.
Then persisted config is being processed.
Therefore customiers should not reject configuration if metadata they are going to
add is already present in mapping context.
Also includes:
* locator-set and remote-mapping handling update
* fixes write order of locator sets and local-mapping.
Not included:
* initializers for lisp (hc restart without vpp restart might fail)
Change-Id: I82c1ee878d9ce074a6bd8197678653814514e6ca
Signed-off-by: Marek Gradzki <[email protected]>
checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
checkAllowedCombination(id, dataAfter);
- //checks whether value with specified mapping-id does not exist in mapping allready
- final MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
- checkState(!localMappingsContext
- .containsEid(mappingId, writeContext.getMappingContext()),
- "Local mapping with id %s already defined", id);
-
-
try {
addDelMappingAndReply(true, dataAfter,
id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
- //adds mapping for id and eid
+ // adds mapping for id and eid
+ final MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
localMappingsContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
}
checkState(isNonEmptyLocatorSet(writeContext.readAfter(id).get()),
"Creating empty locator-sets is not allowed");
final String locatorSetName = dataAfter.getName();
- checkState(!locatorSetContext.containsIndex(locatorSetName, writeContext.getMappingContext()),
- "Locator set with name %s already defined", locatorSetName);
final int locatorSetIndex = addDelLocatorSetAndReply(true, dataAfter.getName(), id);
locatorSetContext.addName(locatorSetIndex, locatorSetName, writeContext.getMappingContext());
checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
checkAllowedCombination(id, dataAfter);
- //checks whether mapping not already contains such key
- MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
- checkState(!remoteMappingContext.containsEid(mappingId, writeContext.getMappingContext()),
- "Mapping for id %s already defined", mappingId);
-
try {
addDelRemoteMappingAndReply(true, dataAfter,
id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
- //after successfull adition adds mapping
+ // after successfull adition adds mapping
+ MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
remoteMappingContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
}
*/
public final class EidTableWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory {
- private static final InstanceIdentifier<VniTable> VNI_TABLE_ID =
+ static final InstanceIdentifier<VniTable> VNI_TABLE_ID =
LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(EidTable.class).child(VniTable.class);
- private static final InstanceIdentifier<VrfSubtable> VRF_SUBTABLE_ID = VNI_TABLE_ID.child(VrfSubtable.class);
+ static final InstanceIdentifier<VrfSubtable> VRF_SUBTABLE_ID = VNI_TABLE_ID.child(VrfSubtable.class);
- private static final InstanceIdentifier<BridgeDomainSubtable> BRIDGE_DOMAIN_SUBTABLE_ID =
+ static final InstanceIdentifier<BridgeDomainSubtable> BRIDGE_DOMAIN_SUBTABLE_ID =
VNI_TABLE_ID.child(BridgeDomainSubtable.class);
package io.fd.hc2vpp.lisp.translate.write.factory;
+import static io.fd.hc2vpp.lisp.translate.write.factory.EidTableWriterFactory.BRIDGE_DOMAIN_SUBTABLE_ID;
+import static io.fd.hc2vpp.lisp.translate.write.factory.EidTableWriterFactory.VRF_SUBTABLE_ID;
+
import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.write.InterfaceCustomizer;
import io.fd.hc2vpp.lisp.translate.write.LocatorSetCustomizer;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import java.util.Arrays;
import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.Interface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
/**
* Factory producing writers for {@code LocatorSets}
*/
public final class LocatorSetWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory {
+ static InstanceIdentifier<LocatorSet> LOCATOR_SET_ID =
+ LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(LocatorSets.class).child(LocatorSet.class);
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
- InstanceIdentifier<LocatorSet> locatorSetId =
- LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(LocatorSets.class).child(LocatorSet.class);
+ // LocatorSet must be written before eid table entries, because local mappings under eid-table are referencing it
+ registry.addBefore(new GenericListWriter<>(LOCATOR_SET_ID, new LocatorSetCustomizer(vppApi, locatorSetContext)),
+ Arrays.asList(VRF_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class),
+ BRIDGE_DOMAIN_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class)));
- registry.add(new GenericListWriter<>(locatorSetId, new LocatorSetCustomizer(vppApi, locatorSetContext)));
- registry.add(new GenericListWriter<>(locatorSetId.child(Interface.class),
- new InterfaceCustomizer(vppApi, interfaceContext)));
+ registry.add(new GenericListWriter<>(LOCATOR_SET_ID.child(Interface.class),
+ new InterfaceCustomizer(vppApi, interfaceContext)));
}
}