BoundServices serviceInfo = ElanUtils.getBoundServices(
String.format("%s.%s.%s", "elan", elanInstanceName, interfaceName), elanServiceIndex,
ElanConstants.ELAN_SERVICE_PRIORITY, NwConstants.COOKIE_ELAN_INGRESS_TABLE, instructions);
- tx.put(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier<BoundServices> bindServiceId = ElanUtils.buildServiceId(interfaceName, elanServiceIndex);
+ Optional<BoundServices> existingElanService = elanUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ bindServiceId);
+ if (!existingElanService.isPresent()) {
+ tx.put(LogicalDatastoreType.CONFIGURATION,
ElanUtils.buildServiceId(interfaceName, elanServiceIndex), serviceInfo, true);
+ }
}
private void bindEtreeService(ElanInstance elanInfo, ElanInterface elanInterface, int lportTag,
if (existingInterfaceMacEntry.isPresent()) {
tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
}
- tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
+ Optional<MacEntry> existingMacEntryForElanInstance = elanUtils.read(broker,
+ LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
+ if (existingMacEntryForElanInstance.isPresent()) {
+ tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
+ }
ListenableFuture<Void> writeResult = tx.submit();
addCallBack(writeResult, srcMacAddress);
}