Config save support for networkconfiguration.neutron 68/4368/1
authorMadhu Venugopal <mavenugo@gmail.com>
Sat, 18 Jan 2014 00:22:47 +0000 (16:22 -0800)
committerMadhu Venugopal <mavenugo@gmail.com>
Sat, 18 Jan 2014 00:22:47 +0000 (16:22 -0800)
With the ODL ML2 Integration, the REST APIs are uni-directional, hence a simple controller restart
results in synchronization issues between Openstack/CloudStack ML2 and ODL.

The solution that was agreed with Kyle, Ryan, Hugo & others is to add the config save support on the
ODL side which will effectively remove the inconsistency issues between Openstack / Cloudstack and ODL.

Change-Id: I9c5cb1a7d4acd0c147a3014da090770b231fd8d9
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
17 files changed:
opendaylight/networkconfiguration/neutron/implementation/pom.xml
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronFloatingIPInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronPortInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronRouterInterface.java
opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronSubnetInterface.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronFloatingIP.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronNetwork.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronPort.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter_Interface.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronRouter_NetworkReference.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet_HostRoute.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet_IPAllocationPool.java
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/Neutron_IPs.java

index 3b335463d97b34c8faf0f69825c5fa814f9fb4e4..8e14d9b366227726190f9dc3589e4b3f33a70c74 100644 (file)
@@ -50,6 +50,7 @@
           <instructions>
             <Import-Package>
               org.opendaylight.controller.clustering.services,
           <instructions>
             <Import-Package>
               org.opendaylight.controller.clustering.services,
+              org.opendaylight.controller.configuration,
               org.opendaylight.controller.sal.core,
               org.opendaylight.controller.sal.utils,
               org.apache.felix.dm,
               org.opendaylight.controller.sal.core,
               org.opendaylight.controller.sal.utils,
               org.apache.felix.dm,
       <artifactId>clustering.services</artifactId>
       <version>0.4.1-SNAPSHOT</version>
     </dependency>
       <artifactId>clustering.services</artifactId>
       <version>0.4.1-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration</artifactId>
+      <version>0.4.1-SNAPSHOT</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>networkconfig.neutron</artifactId>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>networkconfig.neutron</artifactId>
index 4202856774b81a19403a0de2f193c8aa24bf185e..351496abb3052c406260191bc80cf77f8db32266 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 import java.util.Hashtable;
 import java.util.Dictionary;
 
 import java.util.Hashtable;
 import java.util.Dictionary;
+
 import org.apache.felix.dm.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.felix.dm.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
@@ -32,6 +33,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      * ComponentActivatorAbstractBase.
      *
      */
      * ComponentActivatorAbstractBase.
      *
      */
+    @Override
     public void init() {
 
     }
     public void init() {
 
     }
@@ -41,6 +43,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      * cleanup done by ComponentActivatorAbstractBase
      *
      */
      * cleanup done by ComponentActivatorAbstractBase
      *
      */
+    @Override
     public void destroy() {
 
     }
     public void destroy() {
 
     }
@@ -54,6 +57,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      * instantiated in order to get an fully working implementation
      * Object
      */
      * instantiated in order to get an fully working implementation
      * Object
      */
+    @Override
     public Object[] getImplementations() {
         Object[] res = { NeutronFloatingIPInterface.class,
                 NeutronRouterInterface.class,
     public Object[] getImplementations() {
         Object[] res = { NeutronFloatingIPInterface.class,
                 NeutronRouterInterface.class,
@@ -76,11 +80,13 @@ public class Activator extends ComponentActivatorAbstractBase {
      * also optional per-container different behavior if needed, usually
      * should not be the case though.
      */
      * also optional per-container different behavior if needed, usually
      * should not be the case though.
      */
+    @Override
     public void configureInstance(Component c, Object imp, String containerName) {
         if (imp.equals(NeutronFloatingIPInterface.class)) {
             // export the service
             c.setInterface(
     public void configureInstance(Component c, Object imp, String containerName) {
         if (imp.equals(NeutronFloatingIPInterface.class)) {
             // export the service
             c.setInterface(
-                    new String[] { INeutronFloatingIPCRUD.class.getName() }, null);
+                    new String[] { INeutronFloatingIPCRUD.class.getName(),
+                                   IConfigurationContainerAware.class.getName()}, null);
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
@@ -91,7 +97,8 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(NeutronRouterInterface.class)) {
             // export the service
             c.setInterface(
         if (imp.equals(NeutronRouterInterface.class)) {
             // export the service
             c.setInterface(
-                    new String[] { INeutronRouterCRUD.class.getName() }, null);
+                    new String[] { INeutronRouterCRUD.class.getName(),
+                                   IConfigurationContainerAware.class.getName()}, null);
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
@@ -102,7 +109,8 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(NeutronPortInterface.class)) {
             // export the service
             c.setInterface(
         if (imp.equals(NeutronPortInterface.class)) {
             // export the service
             c.setInterface(
-                    new String[] { INeutronPortCRUD.class.getName() }, null);
+                    new String[] { INeutronPortCRUD.class.getName(),
+                                   IConfigurationContainerAware.class.getName()}, null);
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
@@ -113,7 +121,8 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(NeutronSubnetInterface.class)) {
             // export the service
             c.setInterface(
         if (imp.equals(NeutronSubnetInterface.class)) {
             // export the service
             c.setInterface(
-                    new String[] { INeutronSubnetCRUD.class.getName() }, null);
+                    new String[] { INeutronSubnetCRUD.class.getName(),
+                                   IConfigurationContainerAware.class.getName()}, null);
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
@@ -124,7 +133,8 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(NeutronNetworkInterface.class)) {
             // export the service
             c.setInterface(
         if (imp.equals(NeutronNetworkInterface.class)) {
             // export the service
             c.setInterface(
-                    new String[] { INeutronNetworkCRUD.class.getName() }, null);
+                    new String[] { INeutronNetworkCRUD.class.getName(),
+                                   IConfigurationContainerAware.class.getName()}, null);
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "neutron");
             c.add(createContainerServiceDependency(containerName)
index 7d9a2e657675e767d78a774c484e07a39f81d7d9..ceb009bf2c142006f44c069eae06beb81526a317 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -16,6 +19,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
@@ -23,6 +27,7 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
@@ -31,11 +36,20 @@ import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
 import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
 import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.IObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectWriter;
+import org.opendaylight.controller.sal.utils.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
+public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD, IConfigurationContainerAware,
+                                                   IObjectReader {
     private static final Logger logger = LoggerFactory.getLogger(NeutronFloatingIPInterface.class);
     private static final Logger logger = LoggerFactory.getLogger(NeutronFloatingIPInterface.class);
+    private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+    private static final String FILENAME ="neutron.floatingip";
+    private static String fileName;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
@@ -103,6 +117,9 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
     private void startUp() {
         allocateCache();
         retrieveCache();
     private void startUp() {
         allocateCache();
         retrieveCache();
+        if (floatingIPDB.isEmpty()) {
+            loadConfiguration();
+        }
     }
 
     /**
     }
 
     /**
@@ -119,6 +136,7 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
+        fileName = ROOT + FILENAME + "_" + containerName + ".conf";
         startUp();
     }
 
         startUp();
     }
 
@@ -178,16 +196,19 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
 
     // IfNBFloatingIPCRUD interface methods
 
 
     // IfNBFloatingIPCRUD interface methods
 
+    @Override
     public boolean floatingIPExists(String uuid) {
         return floatingIPDB.containsKey(uuid);
     }
 
     public boolean floatingIPExists(String uuid) {
         return floatingIPDB.containsKey(uuid);
     }
 
+    @Override
     public NeutronFloatingIP getFloatingIP(String uuid) {
         if (!floatingIPExists(uuid))
             return null;
         return floatingIPDB.get(uuid);
     }
 
     public NeutronFloatingIP getFloatingIP(String uuid) {
         if (!floatingIPExists(uuid))
             return null;
         return floatingIPDB.get(uuid);
     }
 
+    @Override
     public List<NeutronFloatingIP> getAllFloatingIPs() {
         Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
         for (Entry<String, NeutronFloatingIP> entry : floatingIPDB.entrySet()) {
     public List<NeutronFloatingIP> getAllFloatingIPs() {
         Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
         for (Entry<String, NeutronFloatingIP> entry : floatingIPDB.entrySet()) {
@@ -200,6 +221,7 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
         return ans;
     }
 
         return ans;
     }
 
+    @Override
     public boolean addFloatingIP(NeutronFloatingIP input) {
         INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
         INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
     public boolean addFloatingIP(NeutronFloatingIP input) {
         INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
         INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
@@ -223,6 +245,7 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean removeFloatingIP(String uuid) {
         INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
         INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
     public boolean removeFloatingIP(String uuid) {
         INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);
         INeutronSubnetCRUD subnetCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
@@ -242,6 +265,7 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean updateFloatingIP(String uuid, NeutronFloatingIP delta) {
         INeutronPortCRUD portCRUD = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
 
     public boolean updateFloatingIP(String uuid, NeutronFloatingIP delta) {
         INeutronPortCRUD portCRUD = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
 
@@ -263,4 +287,30 @@ public class NeutronFloatingIPInterface implements INeutronFloatingIPCRUD {
         target.setFixedIPAddress(delta.getFixedIPAddress());
         return true;
     }
         target.setFixedIPAddress(delta.getFixedIPAddress());
         return true;
     }
+
+    @SuppressWarnings("unchecked")
+    private void loadConfiguration() {
+        ObjectReader objReader = new ObjectReader();
+        ConcurrentMap<String, NeutronFloatingIP> confList = (ConcurrentMap<String, NeutronFloatingIP>)
+                                                            objReader.read(this, fileName);
+
+        if (confList == null) {
+            return;
+        }
+
+        for (String key : confList.keySet()) {
+            floatingIPDB.put(key, confList.get(key));
+        }
+    }
+
+    @Override
+    public Status saveConfiguration() {
+        ObjectWriter objWriter = new ObjectWriter();
+        return objWriter.write(new ConcurrentHashMap<String, NeutronFloatingIP>(floatingIPDB), fileName);
+    }
+
+    @Override
+    public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
+        return ois.readObject();
+    }
 }
 }
index b1e382107adcb5e52b58da3e41a5f4b91e9881bf..de9b9d1bc4fdd9d77fb29d342cf24512c4dd5b06 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -16,6 +19,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
@@ -23,13 +27,23 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.IObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectWriter;
+import org.opendaylight.controller.sal.utils.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronNetworkInterface implements INeutronNetworkCRUD {
+public class NeutronNetworkInterface implements INeutronNetworkCRUD, IConfigurationContainerAware,
+                                                IObjectReader {
     private static final Logger logger = LoggerFactory.getLogger(NeutronNetworkInterface.class);
     private static final Logger logger = LoggerFactory.getLogger(NeutronNetworkInterface.class);
+    private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+    private static final String FILENAME ="neutron.network";
+    private static String fileName;
     private String containerName = null;
 
     private ConcurrentMap<String, NeutronNetwork> networkDB;
     private String containerName = null;
 
     private ConcurrentMap<String, NeutronNetwork> networkDB;
@@ -85,6 +99,9 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
     private void startUp() {
         allocateCache();
         retrieveCache();
     private void startUp() {
         allocateCache();
         retrieveCache();
+        if (networkDB.isEmpty()) {
+            loadConfiguration();
+        }
     }
 
     /**
     }
 
     /**
@@ -101,6 +118,7 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
+        fileName = ROOT + FILENAME + "_" + containerName + ".conf";
         startUp();
     }
 
         startUp();
     }
 
@@ -170,16 +188,19 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
 
     // IfNBNetworkCRUD methods
 
 
     // IfNBNetworkCRUD methods
 
+    @Override
     public boolean networkExists(String uuid) {
         return networkDB.containsKey(uuid);
     }
 
     public boolean networkExists(String uuid) {
         return networkDB.containsKey(uuid);
     }
 
+    @Override
     public NeutronNetwork getNetwork(String uuid) {
         if (!networkExists(uuid))
             return null;
         return networkDB.get(uuid);
     }
 
     public NeutronNetwork getNetwork(String uuid) {
         if (!networkExists(uuid))
             return null;
         return networkDB.get(uuid);
     }
 
+    @Override
     public List<NeutronNetwork> getAllNetworks() {
         Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
         for (Entry<String, NeutronNetwork> entry : networkDB.entrySet()) {
     public List<NeutronNetwork> getAllNetworks() {
         Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
         for (Entry<String, NeutronNetwork> entry : networkDB.entrySet()) {
@@ -192,6 +213,7 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
         return ans;
     }
 
         return ans;
     }
 
+    @Override
     public boolean addNetwork(NeutronNetwork input) {
         if (networkExists(input.getID()))
             return false;
     public boolean addNetwork(NeutronNetwork input) {
         if (networkExists(input.getID()))
             return false;
@@ -200,6 +222,7 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean removeNetwork(String uuid) {
         if (!networkExists(uuid))
             return false;
     public boolean removeNetwork(String uuid) {
         if (!networkExists(uuid))
             return false;
@@ -208,6 +231,7 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean updateNetwork(String uuid, NeutronNetwork delta) {
         if (!networkExists(uuid))
             return false;
     public boolean updateNetwork(String uuid, NeutronNetwork delta) {
         if (!networkExists(uuid))
             return false;
@@ -215,6 +239,7 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
         return overwrite(target, delta);
     }
 
         return overwrite(target, delta);
     }
 
+    @Override
     public boolean networkInUse(String netUUID) {
         if (!networkExists(netUUID))
             return true;
     public boolean networkInUse(String netUUID) {
         if (!networkExists(netUUID))
             return true;
@@ -223,4 +248,31 @@ public class NeutronNetworkInterface implements INeutronNetworkCRUD {
             return true;
         return false;
     }
             return true;
         return false;
     }
+
+    @SuppressWarnings("unchecked")
+    private void loadConfiguration() {
+        ObjectReader objReader = new ObjectReader();
+        ConcurrentMap<String, NeutronNetwork> confList = (ConcurrentMap<String, NeutronNetwork>)
+                                                            objReader.read(this, fileName);
+
+        if (confList == null) {
+            return;
+        }
+
+        for (String key : confList.keySet()) {
+            networkDB.put(key, confList.get(key));
+        }
+    }
+
+    @Override
+    public Status saveConfiguration() {
+        ObjectWriter objWriter = new ObjectWriter();
+        return objWriter.write(new ConcurrentHashMap<String, NeutronNetwork>(networkDB), fileName);
+    }
+
+    @Override
+    public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
+        return ois.readObject();
+    }
+
 }
 }
index fd030e178bd021cb8ec4ccfcb14c1877d89b172a..ec439bb92782b9f8b7b9f1dd865666c1d3ae8286 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -17,6 +20,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
@@ -24,6 +28,7 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
@@ -32,11 +37,20 @@ import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
 import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
 import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.IObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectWriter;
+import org.opendaylight.controller.sal.utils.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronPortInterface implements INeutronPortCRUD {
+public class NeutronPortInterface implements INeutronPortCRUD, IConfigurationContainerAware,
+                                             IObjectReader {
     private static final Logger logger = LoggerFactory.getLogger(NeutronPortInterface.class);
     private static final Logger logger = LoggerFactory.getLogger(NeutronPortInterface.class);
+    private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+    private static final String FILENAME ="neutron.port";
+    private static String fileName;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
@@ -104,6 +118,10 @@ public class NeutronPortInterface implements INeutronPortCRUD {
     private void startUp() {
         allocateCache();
         retrieveCache();
     private void startUp() {
         allocateCache();
         retrieveCache();
+        if (portDB.isEmpty()) {
+            loadConfiguration();
+        }
+
     }
 
     /**
     }
 
     /**
@@ -120,6 +138,7 @@ public class NeutronPortInterface implements INeutronPortCRUD {
             // In the Global instance case the containerName is empty
             containerName = "";
         }
             // In the Global instance case the containerName is empty
             containerName = "";
         }
+        fileName = ROOT + FILENAME + "_" + containerName + ".conf";
         startUp();
     }
 
         startUp();
     }
 
@@ -329,4 +348,30 @@ public class NeutronPortInterface implements INeutronPortCRUD {
         return null;
     }
 
         return null;
     }
 
+    @SuppressWarnings("unchecked")
+    private void loadConfiguration() {
+        ObjectReader objReader = new ObjectReader();
+        ConcurrentMap<String, NeutronPort> confList = (ConcurrentMap<String, NeutronPort>)
+                                                            objReader.read(this, fileName);
+
+        if (confList == null) {
+            return;
+        }
+
+        for (String key : confList.keySet()) {
+            portDB.put(key, confList.get(key));
+        }
+    }
+
+    @Override
+    public Status saveConfiguration() {
+        ObjectWriter objWriter = new ObjectWriter();
+        return objWriter.write(new ConcurrentHashMap<String, NeutronPort>(portDB), fileName);
+    }
+
+    @Override
+    public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
+        return ois.readObject();
+    }
+
 }
 }
index 0e64dc5a098284640bb9d242a68e3649e100cf5e..850cc02163bd7965a2aefd936e39149e607bf26f 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -16,6 +19,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
@@ -23,13 +27,23 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.IObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectWriter;
+import org.opendaylight.controller.sal.utils.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronRouterInterface implements INeutronRouterCRUD {
+public class NeutronRouterInterface implements INeutronRouterCRUD, IConfigurationContainerAware,
+                                               IObjectReader {
     private static final Logger logger = LoggerFactory.getLogger(NeutronRouterInterface.class);
     private static final Logger logger = LoggerFactory.getLogger(NeutronRouterInterface.class);
+    private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+    private static final String FILENAME ="neutron.router";
+    private static String fileName;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
@@ -96,6 +110,10 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
     private void startUp() {
         allocateCache();
         retrieveCache();
     private void startUp() {
         allocateCache();
         retrieveCache();
+        if (routerDB.isEmpty()) {
+            loadConfiguration();
+        }
+
     }
 
     /**
     }
 
     /**
@@ -112,6 +130,7 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
+        fileName = ROOT + FILENAME + "_" + containerName + ".conf";
         startUp();
     }
 
         startUp();
     }
 
@@ -172,16 +191,19 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
 
     // IfNBRouterCRUD Interface methods
 
 
     // IfNBRouterCRUD Interface methods
 
+    @Override
     public boolean routerExists(String uuid) {
         return routerDB.containsKey(uuid);
     }
 
     public boolean routerExists(String uuid) {
         return routerDB.containsKey(uuid);
     }
 
+    @Override
     public NeutronRouter getRouter(String uuid) {
         if (!routerExists(uuid))
             return null;
         return routerDB.get(uuid);
     }
 
     public NeutronRouter getRouter(String uuid) {
         if (!routerExists(uuid))
             return null;
         return routerDB.get(uuid);
     }
 
+    @Override
     public List<NeutronRouter> getAllRouters() {
         Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
         for (Entry<String, NeutronRouter> entry : routerDB.entrySet()) {
     public List<NeutronRouter> getAllRouters() {
         Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
         for (Entry<String, NeutronRouter> entry : routerDB.entrySet()) {
@@ -194,6 +216,7 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
         return ans;
     }
 
         return ans;
     }
 
+    @Override
     public boolean addRouter(NeutronRouter input) {
         if (routerExists(input.getID()))
             return false;
     public boolean addRouter(NeutronRouter input) {
         if (routerExists(input.getID()))
             return false;
@@ -201,6 +224,7 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean removeRouter(String uuid) {
         if (!routerExists(uuid))
             return false;
     public boolean removeRouter(String uuid) {
         if (!routerExists(uuid))
             return false;
@@ -208,6 +232,7 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean updateRouter(String uuid, NeutronRouter delta) {
         if (!routerExists(uuid))
             return false;
     public boolean updateRouter(String uuid, NeutronRouter delta) {
         if (!routerExists(uuid))
             return false;
@@ -215,10 +240,38 @@ public class NeutronRouterInterface implements INeutronRouterCRUD {
         return overwrite(target, delta);
     }
 
         return overwrite(target, delta);
     }
 
+    @Override
     public boolean routerInUse(String routerUUID) {
         if (!routerExists(routerUUID))
             return true;
         NeutronRouter target = routerDB.get(routerUUID);
         return (target.getInterfaces().size() > 0);
     }
     public boolean routerInUse(String routerUUID) {
         if (!routerExists(routerUUID))
             return true;
         NeutronRouter target = routerDB.get(routerUUID);
         return (target.getInterfaces().size() > 0);
     }
+
+    @SuppressWarnings("unchecked")
+    private void loadConfiguration() {
+        ObjectReader objReader = new ObjectReader();
+        ConcurrentMap<String, NeutronRouter> confList = (ConcurrentMap<String, NeutronRouter>)
+                                                            objReader.read(this, fileName);
+
+        if (confList == null) {
+            return;
+        }
+
+        for (String key : confList.keySet()) {
+            routerDB.put(key, confList.get(key));
+        }
+    }
+
+    @Override
+    public Status saveConfiguration() {
+        ObjectWriter objWriter = new ObjectWriter();
+        return objWriter.write(new ConcurrentHashMap<String, NeutronRouter>(routerDB), fileName);
+    }
+
+    @Override
+    public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
+        return ois.readObject();
+    }
+
 }
 }
index 62ef64c74c705fe8d0fb0f92c913d750157ece9c..f908a95c313390e25b340f862d4f63e65999c07c 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
 
 package org.opendaylight.controller.networkconfig.neutron.implementation;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -16,6 +19,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
 import java.util.List;
 import java.util.Set;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
@@ -23,16 +27,27 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
 import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.IObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectReader;
+import org.opendaylight.controller.sal.utils.ObjectWriter;
+import org.opendaylight.controller.sal.utils.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronSubnetInterface implements INeutronSubnetCRUD {
+public class NeutronSubnetInterface implements INeutronSubnetCRUD, IConfigurationContainerAware,
+                                               IObjectReader {
     private static final Logger logger = LoggerFactory.getLogger(NeutronSubnetInterface.class);
     private static final Logger logger = LoggerFactory.getLogger(NeutronSubnetInterface.class);
+    private static String ROOT = GlobalConstants.STARTUPHOME.toString();
+    private static final String FILENAME ="neutron.subnet";
+    private static String fileName;
+
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
     private String containerName = null;
 
     private IClusterContainerServices clusterContainerService = null;
@@ -100,6 +115,10 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
     private void startUp() {
         allocateCache();
         retrieveCache();
     private void startUp() {
         allocateCache();
         retrieveCache();
+        if (subnetDB.isEmpty()) {
+            loadConfiguration();
+        }
+
     }
 
     /**
     }
 
     /**
@@ -116,6 +135,7 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
+        fileName = ROOT + FILENAME + "_" + containerName + ".conf";
         startUp();
     }
 
         startUp();
     }
 
@@ -176,16 +196,19 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
 
     // IfNBSubnetCRUD methods
 
 
     // IfNBSubnetCRUD methods
 
+    @Override
     public boolean subnetExists(String uuid) {
         return subnetDB.containsKey(uuid);
     }
 
     public boolean subnetExists(String uuid) {
         return subnetDB.containsKey(uuid);
     }
 
+    @Override
     public NeutronSubnet getSubnet(String uuid) {
         if (!subnetExists(uuid))
             return null;
         return subnetDB.get(uuid);
     }
 
     public NeutronSubnet getSubnet(String uuid) {
         if (!subnetExists(uuid))
             return null;
         return subnetDB.get(uuid);
     }
 
+    @Override
     public List<NeutronSubnet> getAllSubnets() {
         Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
         for (Entry<String, NeutronSubnet> entry : subnetDB.entrySet()) {
     public List<NeutronSubnet> getAllSubnets() {
         Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
         for (Entry<String, NeutronSubnet> entry : subnetDB.entrySet()) {
@@ -198,6 +221,7 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
         return ans;
     }
 
         return ans;
     }
 
+    @Override
     public boolean addSubnet(NeutronSubnet input) {
         String id = input.getID();
         if (subnetExists(id))
     public boolean addSubnet(NeutronSubnet input) {
         String id = input.getID();
         if (subnetExists(id))
@@ -210,6 +234,7 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean removeSubnet(String uuid) {
         if (!subnetExists(uuid))
             return false;
     public boolean removeSubnet(String uuid) {
         if (!subnetExists(uuid))
             return false;
@@ -222,6 +247,7 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
         return true;
     }
 
         return true;
     }
 
+    @Override
     public boolean updateSubnet(String uuid, NeutronSubnet delta) {
         if (!subnetExists(uuid))
             return false;
     public boolean updateSubnet(String uuid, NeutronSubnet delta) {
         if (!subnetExists(uuid))
             return false;
@@ -229,10 +255,38 @@ public class NeutronSubnetInterface implements INeutronSubnetCRUD {
         return overwrite(target, delta);
     }
 
         return overwrite(target, delta);
     }
 
+    @Override
     public boolean subnetInUse(String subnetUUID) {
         if (!subnetExists(subnetUUID))
             return true;
         NeutronSubnet target = subnetDB.get(subnetUUID);
         return (target.getPortsInSubnet().size() > 0);
     }
     public boolean subnetInUse(String subnetUUID) {
         if (!subnetExists(subnetUUID))
             return true;
         NeutronSubnet target = subnetDB.get(subnetUUID);
         return (target.getPortsInSubnet().size() > 0);
     }
+
+    @SuppressWarnings("unchecked")
+    private void loadConfiguration() {
+        ObjectReader objReader = new ObjectReader();
+        ConcurrentMap<String, NeutronSubnet> confList = (ConcurrentMap<String, NeutronSubnet>)
+                                                            objReader.read(this, fileName);
+
+        if (confList == null) {
+            return;
+        }
+
+        for (String key : confList.keySet()) {
+            subnetDB.put(key, confList.get(key));
+        }
+    }
+
+    @Override
+    public Status saveConfiguration() {
+        ObjectWriter objWriter = new ObjectWriter();
+        return objWriter.write(new ConcurrentHashMap<String, NeutronSubnet>(subnetDB), fileName);
+    }
+
+    @Override
+    public Object readObject(ObjectInputStream ois) throws FileNotFoundException, IOException, ClassNotFoundException {
+        return ois.readObject();
+    }
+
 }
 }
index 4d029dccf31c642a7fd8ca790570e8764bcbebb2..9c8c91b284f0914a16011429306de380fb7f2399 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.Iterator;
 import java.util.List;
 
 import java.util.Iterator;
 import java.util.List;
 
@@ -19,7 +20,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronFloatingIP {
+public class NeutronFloatingIP implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 9d7ba5d58a8535dec530c37e4e29c2c821031fec..1277436e236fa375467d3ec07e6dda12a62f70c0 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -20,10 +21,12 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement(name = "network")
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement(name = "network")
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronNetwork {
+public class NeutronNetwork implements Serializable {
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
+    private static final long serialVersionUID = 1L;
+
     @XmlElement (name="id")
     String networkUUID;              // network UUID
 
     @XmlElement (name="id")
     String networkUUID;              // network UUID
 
index 536fc3fd6e5ac1f2594cd8850afe8f9bd5538297..bcadba202a049f9948d48270964beb94b9d7ea9b 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -22,7 +23,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronPort {
+public class NeutronPort implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 1ef48bd95bfe2f4a378f497371f38db11b307e91..ed65c5c91b9b8d16b86c1d96499ce135c1b91e52 100644 (file)
@@ -8,9 +8,11 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -19,7 +21,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronRouter {
+public class NeutronRouter implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
     @XmlElement (name="id")
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
     @XmlElement (name="id")
index 5b5e0ce9cc61de995360bb0172b14b7f13475676..e2df13b9aa859d739114b72b89cb1072e891bd9f 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -15,7 +17,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class NeutronRouter_Interface {
+public class NeutronRouter_Interface implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 07f165dc7e16b661c0f9c9e052af89c63c43cf2a..8583d44531ec5387b1ea7b1d8b884fc98ffe2564 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -16,7 +18,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronRouter_NetworkReference {
+public class NeutronRouter_NetworkReference implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 1dbe253a5815ce75e4cea142ed2903a42cc31bdd..fbaa63a14800f163659b8fe1616cfca271598879 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -23,7 +24,9 @@ import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class NeutronSubnet {
+public class NeutronSubnet implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 75238c1ad97956de49a0d77ab1b0f2ac76d255d8..07744061e66b4eba3fbd18c20455e4ef1b7ba9fa 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -15,7 +17,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSubnet_HostRoute {
+public class NeutronSubnet_HostRoute implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
index 7829ba2199aac43b5e7ac99c2fa730d656436562..15ff548a532c1a14f6ec5e963c1734ca40278aab 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
 import java.util.ArrayList;
 import java.util.List;
 
@@ -18,7 +19,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class NeutronSubnet_IPAllocationPool {
+public class NeutronSubnet_IPAllocationPool implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
@@ -28,7 +31,8 @@ public class NeutronSubnet_IPAllocationPool {
     @XmlElement(name="end")
     String poolEnd;
 
     @XmlElement(name="end")
     String poolEnd;
 
-    public NeutronSubnet_IPAllocationPool() { }
+    public NeutronSubnet_IPAllocationPool() {
+    }
 
     public NeutronSubnet_IPAllocationPool(String lowAddress, String highAddress) {
         poolStart = lowAddress;
 
     public NeutronSubnet_IPAllocationPool(String lowAddress, String highAddress) {
         poolStart = lowAddress;
index 6fe7c529942f1cf524320b923282d3b0b60315cc..e862a59e8a7bef2772645d9567661be9716a49fd 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.controller.networkconfig.neutron;
 
 
 package org.opendaylight.controller.networkconfig.neutron;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -15,7 +17,9 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class Neutron_IPs {
+public class Neutron_IPs implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes
 
     // See OpenStack Network API v2.0 Reference for description of
     // annotated attributes