Port neutronvpn to Datastore-constrained txes 64/73764/5
authorVishal Thapar <vthapar@redhat.com>
Thu, 5 Jul 2018 04:27:12 +0000 (09:57 +0530)
committerStephen Kitt <skitt@redhat.com>
Thu, 5 Jul 2018 14:33:02 +0000 (14:33 +0000)
JIRA: NETVIRT-1348
Change-Id: I77132c3eae83bcec70d977b266a7b1dc19c1e5fa
Signed-off-by: Vishal Thapar <vthapar@redhat.com>
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronTrunkChangeListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/evpn/utils/NeutronEvpnUtils.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/l2gw/L2GatewayListener.java

index facce142fbf80a36038cdd111466c8893e48af54..2c5fd96567eabe99b49564aa1d469e4d1c030f5e 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.neutronvpn;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
 import com.google.gson.Gson;
@@ -28,14 +30,15 @@ import javax.annotation.PostConstruct;
 import javax.inject.Singleton;
 import org.apache.commons.lang3.ObjectUtils;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
+import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
@@ -244,22 +247,22 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         if (origSecurityEnabled || updatedSecurityEnabled) {
             InstanceIdentifier<Interface>  interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
             jobCoordinator.enqueueJob("PORT- " + portName,
-                () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(confTx -> {
-                    Optional<Interface> optionalInf =
-                            confTx.read(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier).checkedGet();
-                    if (optionalInf.isPresent()) {
-                        InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
-                        InterfaceAcl infAcl = handlePortSecurityUpdated(original, update,
-                                origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
-                        interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
-                        LOG.info("update: Of-port-interface updation for port {}", portName);
-                        // Update OFPort interface for this neutron port
-                        confTx.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier,
-                                interfaceBuilder.build());
-                    } else {
-                        LOG.warn("update: Interface {} is not present", portName);
-                    }
-                })));
+                () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
+                    confTx -> {
+                        Optional<Interface> optionalInf =
+                                confTx.read(interfaceIdentifier).get();
+                        if (optionalInf.isPresent()) {
+                            InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
+                            InterfaceAcl infAcl = handlePortSecurityUpdated(original, update,
+                                    origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
+                            interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
+                            LOG.info("update: Of-port-interface updation for port {}", portName);
+                            // Update OFPort interface for this neutron port
+                            confTx.put(interfaceIdentifier, interfaceBuilder.build());
+                        } else {
+                            LOG.warn("update: Interface {} is not present", portName);
+                        }
+                    })));
         }
     }
 
@@ -337,10 +340,11 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                 }
                 nvpnManager.addToNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
                 nvpnNatManager.handleSubnetsForExternalRouter(routerId);
-                ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                    String portInterfaceName = createOfPortInterface(routerPort, confTx);
-                    createElanInterface(routerPort, portInterfaceName, confTx);
-                }), LOG, "Error creating ELAN interface for {}", routerPort);
+                ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                    confTx -> {
+                        String portInterfaceName = createOfPortInterface(routerPort, confTx);
+                        createElanInterface(routerPort, portInterfaceName, confTx);
+                    }), LOG, "Error creating ELAN interface for {}", routerPort);
             } else {
                 LOG.error("Neutron network {} corresponding to router interface port {} for neutron router {}"
                     + " already associated to VPN {}", infNetworkId.getValue(), routerPort.getUuid().getValue(),
@@ -380,33 +384,35 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
             nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(),
                                            null /* vpn-id */, null /* wrtConfigTxn*/);
             // update RouterInterfaces map
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
-                boolean vpnInstanceIpVersionRemoved = false;
-                IpVersionChoice vpnInstanceIpVersionToRemove = IpVersionChoice.UNDEFINED;
-                for (FixedIps portIP : portIps) {
-                    Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
-                    // router Port have either IPv4 or IPv6, never both
-                    if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
-                        vpnInstanceIpVersionRemoved = true;
-                        vpnInstanceIpVersionToRemove = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                confTx -> {
+                    boolean vpnInstanceIpVersionRemoved = false;
+                    IpVersionChoice vpnInstanceIpVersionToRemove = IpVersionChoice.UNDEFINED;
+                    for (FixedIps portIP : portIps) {
+                        Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
+                        // router Port have either IPv4 or IPv6, never both
+                        if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
+                            vpnInstanceIpVersionRemoved = true;
+                            vpnInstanceIpVersionToRemove = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
+                        }
+                        String ipValue = String.valueOf(portIP.getIpAddress().getValue());
+                        neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
+                        // NOTE:  Please donot change the order of calls to removeSubnetFromVpn and
+                        // and updateSubnetNodeWithFixedIP
+                        nvpnManager.removeSubnetFromVpn(vpnId, portIP.getSubnetId(),
+                                sn != null ? sn.getInternetVpnId() : null);
+                        nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null,
+                            null, null, null);
                     }
-                    String ipValue = String.valueOf(portIP.getIpAddress().getValue());
-                    neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
-                    // NOTE:  Please donot change the order of calls to removeSubnetFromVpn and
-                    // and updateSubnetNodeWithFixedIP
-                    nvpnManager.removeSubnetFromVpn(vpnId, portIP.getSubnetId(),
-                            sn != null ? sn.getInternetVpnId() : null);
-                    nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
-                }
-                nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
-                deleteElanInterface(routerPort.getUuid().getValue(), confTx);
-                deleteOfPortInterface(routerPort, confTx);
-                nvpnNatManager.handleSubnetsForExternalRouter(routerId);
-                if (vpnInstanceIpVersionRemoved) {
-                    neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), vpnInstanceIpVersionToRemove,
-                            false);
-                }
-            }), LOG, "Error handling interface removal");
+                    nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
+                    deleteElanInterface(routerPort.getUuid().getValue(), confTx);
+                    deleteOfPortInterface(routerPort, confTx);
+                    nvpnNatManager.handleSubnetsForExternalRouter(routerId);
+                    if (vpnInstanceIpVersionRemoved) {
+                        neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), vpnInstanceIpVersionToRemove,
+                                false);
+                    }
+                }), LOG, "Error handling interface removal");
             if (vpnInstanceInternetIpVersionRemoved) {
                 neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(),
                         IpVersionChoice.IPV6, false);
@@ -591,7 +597,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                          + "OF Port interfaces are not created", portName);
                 return Collections.emptyList();
             }
-            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                 LOG.info("Of-port-interface creation for port {}", portName);
                 // Create of-port interface for this neutron port
                 String portInterfaceName = createOfPortInterface(port, tx);
@@ -638,7 +644,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         final Uuid portId = port.getUuid();
         final List<FixedIps> portIpsList = port.getFixedIps();
         jobCoordinator.enqueueJob("PORT- " + portName,
-            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
+            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
                 if (!(NeutronUtils.isPortVnicTypeNormal(port) || isPortTypeSwitchdev(port))) {
                     for (FixedIps ip : portIpsList) {
                         // remove direct port from subnetMaps config DS
@@ -712,7 +718,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
             return;
         }
         jobCoordinator.enqueueJob("PORT- " + portupdate.getUuid().getValue(),
-            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
+            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
                 final List<Uuid> originalSnMapsIds = portoriginalIps.stream().map(FixedIps::getSubnetId)
                         .collect(Collectors.toList());
                 final List<Uuid> updateSnMapsIds = portupdateIps.stream().map(FixedIps::getSubnetId)
@@ -814,7 +820,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         return interfaceAclBuilder;
     }
 
-    private String createOfPortInterface(Port port, WriteTransaction wrtConfigTxn) {
+    private String createOfPortInterface(Port port, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         Interface inf = createInterface(port);
         String infName = inf.getName();
 
@@ -824,7 +830,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                     SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION,
                             interfaceIdentifier);
             if (!optionalInf.isPresent()) {
-                wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, inf);
+                wrtConfigTxn.put(interfaceIdentifier, inf);
             } else {
                 LOG.warn("Interface {} is already present", infName);
             }
@@ -861,7 +867,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         return interfaceBuilder.build();
     }
 
-    private void deleteOfPortInterface(Port port, WriteTransaction wrtConfigTxn) {
+    private void deleteOfPortInterface(Port port, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         String name = port.getUuid().getValue();
         LOG.debug("Removing OFPort Interface {}", name);
         InstanceIdentifier<Interface>  interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name);
@@ -870,7 +876,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                     SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION,
                             interfaceIdentifier);
             if (optionalInf.isPresent()) {
-                wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
+                wrtConfigTxn.delete(interfaceIdentifier);
             } else {
                 LOG.warn("deleteOfPortInterface: Interface {} is not present", name);
             }
@@ -879,7 +885,8 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         }
     }
 
-    private void createElanInterface(Port port, String name, WriteTransaction wrtConfigTxn) {
+    private void createElanInterface(Port port, String name,
+                                     TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         String elanInstanceName = port.getNetworkId().getValue();
         List<StaticMacEntries> staticMacEntries = NeutronvpnUtils.buildStaticMacEntry(port);
 
@@ -887,14 +894,14 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                 .class, new ElanInterfaceKey(name)).build();
         ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName)
                 .setName(name).setStaticMacEntries(staticMacEntries).withKey(new ElanInterfaceKey(name)).build();
-        wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, elanInterface);
+        wrtConfigTxn.put(id, elanInterface);
         LOG.debug("Creating new ELan Interface {}", elanInterface);
     }
 
-    private void deleteElanInterface(String name, WriteTransaction wrtConfigTxn) {
+    private void deleteElanInterface(String name, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface
                 .class, new ElanInterfaceKey(name)).build();
-        wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, id);
+        wrtConfigTxn.delete(id);
     }
 
     // TODO Clean up the exception handling
index 161565d822dbef1086355e7a3d60aea531f14ac2..22b5d563b5437b45a7a213186c4442bbbb8f0c15 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2017, 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.neutronvpn;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -150,10 +152,11 @@ public class NeutronTrunkChangeListener extends AsyncDataTreeChangeListenerBase<
              * Interface is already created for parent NeutronPort. We're updating parent refs
              * and VLAN Information
              */
-            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                tx.merge(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, newIface);
-                LOG.trace("Creating trunk member interface {}", newIface);
-            }));
+            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                CONFIGURATION, tx -> {
+                    tx.merge(interfaceIdentifier, newIface);
+                    LOG.trace("Creating trunk member interface {}", newIface);
+                }));
         });
     }
 
@@ -186,10 +189,11 @@ public class NeutronTrunkChangeListener extends AsyncDataTreeChangeListenerBase<
              * and this being subport delete path, don't expect any significant changes to
              * corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
              */
-            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                tx.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, newIface);
-                LOG.trace("Resetting trunk member interface {}", newIface);
-            }));
+            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                CONFIGURATION, tx -> {
+                    tx.put(interfaceIdentifier, newIface);
+                    LOG.trace("Resetting trunk member interface {}", newIface);
+                }));
         });
 
     }
index 48752cfd5d50d151669c77b714e30888ee32a2f0..d2f37a6559d23d850fefecf17b358af571a62700 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2015, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright © 2015, 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,9 +8,8 @@
 package org.opendaylight.netvirt.neutronvpn;
 
 import static java.util.Collections.singletonList;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
 import static org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker.syncReadOptional;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -45,13 +44,14 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.infrautils.utils.concurrent.KeyedLocks;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
@@ -788,7 +788,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface,
-                                  WriteTransaction wrtConfigTxn, Subnetmap sn, VpnInterface vpnIface) {
+                                                  TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn,
+                                                  Subnetmap sn, VpnInterface vpnIface) {
         List<Adjacency> adjList = new ArrayList<>();
         if (vpnIface != null) {
             adjList = vpnIface.augmentation(Adjacencies.class).getAdjacency();
@@ -836,7 +837,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return new AdjacenciesBuilder().setAdjacency(adjList).build();
     }
 
-    protected void createVpnInterface(Collection<Uuid> vpnIds, Port port, WriteTransaction wrtConfigTxn) {
+    protected void createVpnInterface(Collection<Uuid> vpnIds, Port port,
+                                      TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         boolean isRouterInterface = false;
         if (port.getDeviceOwner() != null) {
             isRouterInterface = NeutronConstants.DEVICE_OWNER_ROUTER_INF.equals(port.getDeviceOwner());
@@ -848,7 +850,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     protected void withdrawPortIpFromVpnIface(Uuid vpnId, Uuid internetVpnId,
-                       Port port, Subnetmap sn, WriteTransaction wrtConfigTxn) {
+                       Port port, Subnetmap sn, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         String infName = port.getUuid().getValue();
         InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
         Optional<VpnInterface> optionalVpnInterface = null;
@@ -931,10 +933,12 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
 
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    protected void deleteVpnInterface(String infName, @Nullable String vpnId, WriteTransaction wrtConfigTxn) {
+    protected void deleteVpnInterface(String infName, @Nullable String vpnId,
+                                      TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         if (wrtConfigTxn == null) {
             ListenableFutures.addErrorLogging(
-                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> deleteVpnInterface(infName, vpnId, tx)),
+                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                        tx -> deleteVpnInterface(infName, vpnId, tx)),
                     LOG, "Error deleting VPN interface {} {}", infName, vpnId);
             return;
         }
@@ -967,16 +971,17 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 }
                 VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get())
                         .setVpnInstanceNames(vpnList);
-                wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
+                wrtConfigTxn.put(vpnIfIdentifier, vpnIfBuilder
                         .build());
             }
         }
         LOG.debug("Deleting vpn interface {}", infName);
-        wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
+        wrtConfigTxn.delete(vpnIfIdentifier);
     }
 
     protected void removeVpnFromVpnInterface(Uuid vpnId, Port port,
-                                     WriteTransaction writeConfigTxn, Subnetmap sm) {
+                                             TypedWriteTransaction<Datastore.Configuration> writeConfigTxn,
+                                             Subnetmap sm) {
         if (vpnId == null || port == null) {
             return;
         }
@@ -1032,8 +1037,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     }
                     deleteVpnInterface(port.getUuid().getValue(), null /* vpn-id */, writeConfigTxn);
                 } else {
-                    writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
-                            .build());
+                    writeConfigTxn.put(vpnIfIdentifier, vpnIfBuilder.build());
                 }
             } else {
                 LOG.info("removeVpnFromVpnInterface: VPN Interface {} not found", infName);
@@ -1044,7 +1048,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     protected void updateVpnInterface(Uuid vpnId, Uuid oldVpnId, Port port, boolean isBeingAssociated,
-                                      boolean isSubnetIp, WriteTransaction writeConfigTxn) {
+                                      boolean isSubnetIp,
+                                      TypedWriteTransaction<Datastore.Configuration> writeConfigTxn) {
         if (vpnId == null || port == null) {
             return;
         }
@@ -1108,8 +1113,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port
                             .getMacAddress().getValue(), isSubnetIp, writeConfigTxn);
                 }
-                writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
-                        .build());
+                writeConfigTxn.put(vpnIfIdentifier, vpnIfBuilder.build());
             } else {
                 LOG.error("VPN Interface {} not found", infName);
             }
@@ -1601,7 +1605,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 final Boolean isRouterInterface = port.getDeviceOwner()
                         .equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF) ? true : false;
                 jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> singletonList(
-                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(wrtConfigTxn -> {
+                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, wrtConfigTxn -> {
                         Adjacencies portAdj = createPortIpAdjacencies(port, isRouterInterface, wrtConfigTxn, sn,
                                     vpnIface);
                         if (vpnIface == null) {
@@ -1691,16 +1695,17 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp(), portId.getValue());
                 final Port port = neutronvpnUtils.getNeutronPort(portId);
                 jobCoordinator.enqueueJob("PORT-" + portId.getValue(),
-                    () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                        if (port != null) {
-                            withdrawPortIpFromVpnIface(vpnId, internetId, port, sn, tx);
-                        } else {
-                            LOG.warn(
-                                    "Cannot proceed with withdrawPortIpFromVpnIface for port {} in subnet {} since "
-                                            + "port is absent in Neutron config DS", portId.getValue(),
-                                    subnet.getValue());
-                        }
-                    })));
+                    () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                            CONFIGURATION, tx -> {
+                            if (port != null) {
+                                withdrawPortIpFromVpnIface(vpnId, internetId, port, sn, tx);
+                            } else {
+                                LOG.warn(
+                                        "Cannot proceed with withdrawPortIpFromVpnIface for port {} in subnet {} since "
+                                                + "port is absent in Neutron config DS", portId.getValue(),
+                                        subnet.getValue());
+                            }
+                        })));
             }
         }
         //update subnet-vpn association
@@ -1724,7 +1729,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
 
         jobCoordinator.enqueueJob("VPN-" + vpn.getValue(), () -> singletonList(
-            txRunner.callWithNewWriteOnlyTransactionAndSubmit(wrtConfigTxn -> {
+            txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, wrtConfigTxn -> {
                 if (isBeingAssociated) {
                     updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(
                             sm.getRouterInterfacePortId()), true, true, wrtConfigTxn);
@@ -1743,14 +1748,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}",
                         port.getValue(), isBeingAssociated);
                 jobCoordinator.enqueueJob("PORT-" + port.getValue(),
-                    () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                        if (isBeingAssociated) {
-                            updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(port),
-                                    true, false, tx);
-                        } else {
-                            removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(port), tx, sm);
-                        }
-                    })));
+                    () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                        tx -> {
+                            if (isBeingAssociated) {
+                                updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(port),
+                                        true, false, tx);
+                            } else {
+                                removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(port), tx, sm);
+                            }
+                        })));
             }
         }
     }
@@ -1772,7 +1778,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         //Update Router Interface first synchronously.
         //CAUTION:  Please DONOT make the router interface VPN Movement as an asynchronous commit again !
         ListenableFuture<Void> future =
-                txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> updateVpnInterface(newVpnId, oldVpnId,
+                txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                    tx -> updateVpnInterface(newVpnId, oldVpnId,
                         neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()),
                         isBeingAssociated, true, tx));
         Futures.addCallback(future, new FutureCallback<Void>() {
@@ -1786,7 +1793,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                         LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}",
                                 port.getValue(), isBeingAssociated);
                         jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> Collections.singletonList(
-                                txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                                txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
                                     tx -> updateVpnInterface(newVpnId, oldVpnId,
                                             neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false,
                                             tx))));
@@ -2884,7 +2891,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         result.add("-------------------------------------------------------------------------------------------");
         InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
 
-        Optional<Ports> ports = syncReadOptional(dataBroker, CONFIGURATION, portidentifier);
+        Optional<Ports> ports = syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, portidentifier);
         if (ports.isPresent() && ports.get().getPort() != null) {
             for (Port port : ports.get().getPort()) {
                 List<FixedIps> fixedIPs = port.getFixedIps();
@@ -2994,7 +3001,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             return;
         }
 
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
             for (String elanInterface : extElanInterfaces) {
                 createExternalVpnInterface(extNetId, elanInterface, tx);
             }
@@ -3009,17 +3016,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             LOG.error("No external ports attached for external network {}", extNetId.getValue());
             return;
         }
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
             for (String elanInterface : extElanInterfaces) {
                 InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils
                         .buildVpnInterfaceIdentifier(elanInterface);
                 LOG.info("Removing vpn interface {}", elanInterface);
-                tx.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
+                tx.delete(vpnIfIdentifier);
             }
         }), LOG, "Error removing external VPN interfaces for {}", extNetId);
     }
 
-    private void createExternalVpnInterface(Uuid vpnId, String infName, WriteTransaction wrtConfigTxn) {
+    private void createExternalVpnInterface(Uuid vpnId, String infName,
+                                            TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         writeVpnInterfaceToDs(Collections.singletonList(vpnId), infName, null,
                 false /* not a router iface */, wrtConfigTxn);
     }
@@ -3027,13 +3035,13 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
     private void writeVpnInterfaceToDs(@Nonnull Collection<Uuid> vpnIdList, String infName, Adjacencies adjacencies,
-            Boolean isRouterInterface, WriteTransaction wrtConfigTxn) {
+            Boolean isRouterInterface, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         if (vpnIdList.isEmpty() || infName == null) {
             LOG.error("vpn id or interface is null");
             return;
         }
         if (wrtConfigTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
                 tx -> writeVpnInterfaceToDs(vpnIdList, infName, adjacencies, isRouterInterface, tx)), LOG,
                 "Error writing VPN interface");
             return;
@@ -3056,20 +3064,21 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         VpnInterface vpnIf = vpnb.build();
         try {
             LOG.info("Creating vpn interface {}", vpnIf);
-            wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
+            wrtConfigTxn.put(vpnIfIdentifier, vpnIf);
         } catch (Exception ex) {
             LOG.error("Creation of vpninterface {} failed", infName, ex);
         }
     }
 
     private void updateVpnInterfaceWithAdjacencies(Uuid vpnId, String infName, Adjacencies adjacencies,
-            WriteTransaction wrtConfigTxn) {
+                                                   TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
         if (vpnId == null || infName == null) {
             LOG.error("vpn id or interface is null");
             return;
         }
         if (wrtConfigTxn == null) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+            LOG.error("updateVpnInterfaceWithAdjancies called with wrtConfigTxn as null");
+            ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                 updateVpnInterfaceWithAdjacencies(vpnId, infName, adjacencies, tx);
             }), LOG, "Error updating VPN interface with adjacencies");
             return;
@@ -3111,7 +3120,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     vpnIfBuilder.setVpnInstanceNames(listVpnInstances);
                 }
                 LOG.info("Updating vpn interface {} with new adjacencies", infName);
-                wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder.build());
+                wrtConfigTxn.put(vpnIfIdentifier, vpnIfBuilder.build());
             }
         } catch (IllegalStateException | ReadFailedException ex) {
             LOG.error("Update of vpninterface {} failed", infName, ex);
@@ -3227,7 +3236,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataOptional;
         try {
             vpnInstanceOpDataOptional = SingleTransactionDataBroker
-                    .syncReadOptional(dataBroker, OPERATIONAL, neutronvpnUtils.getVpnOpDataIdentifier(primaryRd));
+                .syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL,
+                    neutronvpnUtils.getVpnOpDataIdentifier(primaryRd));
         } catch (ReadFailedException e) {
             LOG.error("getExistingOperationalVpn: Exception while checking operational status of vpn with rd {}",
                     primaryRd, e);
index 4d9763ed8d1c3abf9dc248601dd9cc7916c3e9ce..877f8877fbd1319271dc6c700260d077e594cacf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,6 +8,8 @@
 
 package org.opendaylight.netvirt.neutronvpn;
 
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.Sets;
@@ -37,13 +39,14 @@ import javax.inject.Singleton;
 
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
@@ -826,7 +829,7 @@ public class NeutronvpnUtils {
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void createVpnPortFixedIpToPort(String vpnName, String fixedIp, String portName, String macAddress,
-            boolean isSubnetIp, WriteTransaction writeConfigTxn) {
+            boolean isSubnetIp, TypedWriteTransaction<Datastore.Configuration> writeConfigTxn) {
         InstanceIdentifier<VpnPortipToPort> id = NeutronvpnUtils.buildVpnPortipToPortIdentifier(vpnName, fixedIp);
         VpnPortipToPortBuilder builder = new VpnPortipToPortBuilder()
             .withKey(new VpnPortipToPortKey(fixedIp, vpnName))
@@ -834,7 +837,7 @@ public class NeutronvpnUtils {
             .setPortName(portName).setMacAddress(macAddress).setSubnetIp(isSubnetIp);
         try {
             if (writeConfigTxn != null) {
-                writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, builder.build());
+                writeConfigTxn.put(id, builder.build());
             } else {
                 MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
             }
@@ -848,11 +851,12 @@ public class NeutronvpnUtils {
 
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    protected void removeVpnPortFixedIpToPort(String vpnName, String fixedIp, WriteTransaction writeConfigTxn) {
+    protected void removeVpnPortFixedIpToPort(String vpnName, String fixedIp,
+                                              TypedWriteTransaction<Datastore.Configuration> writeConfigTxn) {
         InstanceIdentifier<VpnPortipToPort> id = NeutronvpnUtils.buildVpnPortipToPortIdentifier(vpnName, fixedIp);
         try {
             if (writeConfigTxn != null) {
-                writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, id);
+                writeConfigTxn.delete(id);
             } else {
                 MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
             }
@@ -1522,15 +1526,16 @@ public class NeutronvpnUtils {
             if (isFinalVpnInstanceIpv6Changed) {
                 builder.setIpv6Configured(finalIsIpv6Configured);
             }
-            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-                InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class)
+            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                OPERATIONAL, tx -> {
+                    InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class)
                         .child(VpnInstanceOpDataEntry.class,
                                 new VpnInstanceOpDataEntryKey(vpnInstanceOpDataEntry.getVrfId())).build();
-                tx.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
-                LOG.info("updateVpnInstanceWithIpFamily: Successfully {} {} to Vpn {}",
-                        add ? "added" : "removed",
-                        ipVersion.toString(), vpnName);
-            }));
+                    tx.merge(id, builder.build(), false);
+                    LOG.info("updateVpnInstanceWithIpFamily: Successfully {} {} to Vpn {}",
+                            add ? "added" : "removed",
+                            ipVersion.toString(), vpnName);
+                }));
         });
     }
 
@@ -1679,8 +1684,8 @@ public class NeutronvpnUtils {
         }
         VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
         builder.setBgpvpnType(choice);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
-            tx.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
+        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
+            tx.merge(id, builder.build(), false);
             LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
         }), LOG, "Error updating VPN instance op {} with type {}", vpn, choice);
     }
index ed3e1fc930228fc06b8af66a9315dbe9ef1b6e83..86e6b97034fa78a87271690e76a8a4d8cdb68053 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright © 2017, 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.neutronvpn.evpn.utils;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.base.Optional;
 import java.util.Collections;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -81,9 +83,9 @@ public class NeutronEvpnUtils {
     public void updateElanWithVpnInfo(String elanInstanceName, VpnInstance vpnInstance, Operation operation) {
         String vpnName = vpnInstance.getVpnInstanceName();
         InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
             Optional<ElanInstance> elanInstanceOptional =
-                    tx.read(LogicalDatastoreType.CONFIGURATION, elanIid).checkedGet();
+                    tx.read(elanIid).get();
             if (!elanInstanceOptional.isPresent()) {
                 return;
             }
@@ -103,8 +105,7 @@ public class NeutronEvpnUtils {
             }
 
             elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
-            tx.put(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build(),
-                    WriteTransaction.CREATE_MISSING_PARENTS);
+            tx.put(elanIid, elanInstanceBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
         }), LOG, "Error updating ELAN with VPN info {}, {}, {}", elanInstanceName, vpnInstance, operation);
     }
 
@@ -114,10 +115,10 @@ public class NeutronEvpnUtils {
         InstanceIdentifier<EvpnRdToNetwork> rdToNetworkIdentifier = getRdToNetworkIdentifier(rd);
 
         jobCoordinator.enqueueJob("EVPN_ASSOCIATE-" + rd,
-            () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+            () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                 if (operation == Operation.DELETE) {
                     LOG.debug("Deleting Evpn-Network with key {}", rd);
-                    tx.delete(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier);
+                    tx.delete(rdToNetworkIdentifier);
                 } else {
                     EvpnRdToNetworkBuilder evpnRdToNetworkBuilder = new EvpnRdToNetworkBuilder().withKey(
                             new EvpnRdToNetworkKey(rd));
@@ -125,7 +126,7 @@ public class NeutronEvpnUtils {
                     evpnRdToNetworkBuilder.setNetworkId(elanInstanceName);
                     LOG.info("updating Evpn {} with elaninstance {} and rd {}",
                             vpnInstance.getVpnInstanceName(), elanInstanceName, rd);
-                    tx.put(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier,
+                    tx.put(rdToNetworkIdentifier,
                             evpnRdToNetworkBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
                 }
             })));
index a1cf06092c304d3e9cf59b7785f4e73837122409..cf3aa3cc6306bf3a57aac1006b3a53688da82ad1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.netvirt.neutronvpn.l2gw;
 
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -101,11 +103,11 @@ public class L2GatewayListener extends AsyncClusteredDataTreeChangeListenerBase<
         LOG.info("Removing L2gateway with ID: {}", input.getUuid());
         List<L2gatewayConnection> connections = l2gwService
                 .getL2GwConnectionsByL2GatewayId(input.getUuid());
-        Futures.addCallback(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+        Futures.addCallback(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
             for (L2gatewayConnection connection : connections) {
                 InstanceIdentifier<L2gatewayConnection> iid = InstanceIdentifier.create(Neutron.class)
                         .child(L2gatewayConnections.class).child(L2gatewayConnection.class, connection.key());
-                tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
+                tx.delete(iid);
             }
         }), new FutureCallback<Void>() {
             @Override
@@ -140,7 +142,7 @@ public class L2GatewayListener extends AsyncClusteredDataTreeChangeListenerBase<
             return;
         }
         jobCoordinator.enqueueJob("l2gw.update", () -> {
-            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+            ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                 DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
                 original.getDevices()
                         .stream()