Support active-standby mode in openstacknetworking app

Change-Id: I155e1a082078e5c1b7e8a35275dfd517c787ade7
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
index b59307e..6475a7a 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
@@ -18,6 +18,7 @@
 import com.google.common.collect.ImmutableMap;
 import org.onlab.packet.MacAddress;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 /**
@@ -41,6 +42,11 @@
 
     public static final String OPENSTACK_NETWORKING_APP_ID =
                                             "org.onosproject.openstacknetworking";
+    public static final String OPENSTACK_NETWORKING_REST_PATH = "onos/openstacknetworking";
+    public static final int REST_PORT = 8181;
+    public static final String REST_USER = "onos";
+    public static final String REST_PASSWORD = "rocks";
+    public static final String REST_UTF8 = StandardCharsets.UTF_8.name();
 
     public static final String ARP_BROADCAST_MODE = "broadcast";
     public static final String ARP_PROXY_MODE = "proxy";
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackHaService.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackHaService.java
new file mode 100644
index 0000000..2b39179
--- /dev/null
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackHaService.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.api;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Handles openstack mastership.
+ */
+public interface OpenstackHaService {
+
+    /**
+     * Indicates the active-standby status.
+     *
+     * @return true if the the node runs in active mode, false otherwise
+     */
+    boolean isActive();
+
+    /**
+     * Obtains the IP address of the active node.
+     *
+     * @return IP address of the active node
+     */
+    IpAddress getActiveIp();
+
+    /**
+     * Configures the IP address of the active node.
+     *
+     * @param ip  IP address of the active node
+     */
+    void setActiveIp(IpAddress ip);
+
+    /**
+     * Configures the active status.
+     *
+     * @param flag true if the node runs in active mode, false otherwise
+     */
+    void setActive(boolean flag);
+}
diff --git a/apps/openstacknetworking/app/BUILD b/apps/openstacknetworking/app/BUILD
index acdb2df..3f79a02 100644
--- a/apps/openstacknetworking/app/BUILD
+++ b/apps/openstacknetworking/app/BUILD
@@ -13,6 +13,7 @@
     "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
     "//apps/openstacknode/api:onos-apps-openstacknode-api",
     "//apps/openstacknetworking/api:onos-apps-openstacknetworking-api",
+    "@jersey_client//jar",
     "@httpclient_osgi//jar",
     "@httpcore_osgi//jar",
     "@commons_codec//jar",
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaActiveIpCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaActiveIpCommand.java
new file mode 100644
index 0000000..8b59ed1
--- /dev/null
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaActiveIpCommand.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
+
+/**
+ * Configures openstack active IP address.
+ */
+@Service
+@Command(scope = "onos", name = "openstack-ha-activeip",
+        description = "Configure openstack active IP address.")
+public class OpenstackHaActiveIpCommand extends AbstractShellCommand {
+
+    @Argument(index = 0, name = "active node IP", description = "active node IP",
+            required = true, multiValued = false)
+    private String ip = null;
+
+    @Override
+    protected void doExecute() {
+        OpenstackHaService service = get(OpenstackHaService.class);
+
+        service.setActiveIp(IpAddress.valueOf(ip));
+
+        print("Active node IP address " + ip + " is configured");
+    }
+}
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaConfigCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaConfigCommand.java
new file mode 100644
index 0000000..c0e15ea
--- /dev/null
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaConfigCommand.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
+
+/**
+ * Configures openstack HA.
+ */
+@Service
+@Command(scope = "onos", name = "openstack-ha-config",
+        description = "Configure openstack active-standby HA status.")
+public class OpenstackHaConfigCommand extends AbstractShellCommand {
+
+    private static final String FLAG_TRUE = "true";
+    private static final String FLAG_FALSE = "false";
+
+    @Argument(index = 0, name = "active node", description = "active node",
+            required = true, multiValued = false)
+    private String active = null;
+
+    @Override
+    protected void doExecute() {
+        OpenstackHaService service = get(OpenstackHaService.class);
+
+        if (FLAG_TRUE.equalsIgnoreCase(active)) {
+            service.setActive(true);
+        } else if (FLAG_FALSE.equalsIgnoreCase(active)) {
+            service.setActive(false);
+        } else {
+            error("The input value is not correct");
+            return;
+        }
+
+        String role = service.isActive() ? "ACTIVE" : "STANDBY";
+
+        print("Node is configured as " + role);
+    }
+}
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaShowCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaShowCommand.java
new file mode 100644
index 0000000..af389d6
--- /dev/null
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackHaShowCommand.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.cli;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
+
+/**
+ * Shows openstack HA status.
+ */
+@Service
+@Command(scope = "onos", name = "openstack-ha-show",
+        description = "Show openstack active-standby HA status.")
+public class OpenstackHaShowCommand extends AbstractShellCommand {
+
+    private static final String FORMAT = "%-20s%-30s";
+
+    @Override
+    protected void doExecute() {
+        OpenstackHaService service = get(OpenstackHaService.class);
+
+        print(FORMAT, "Status", "Active Node IP");
+
+        print(FORMAT,
+                service.isActive() ? "Active" : "Standby",
+                service.getActiveIp() == null ? "None" : service.getActiveIp().toString());
+    }
+}
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackHaManager.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackHaManager.java
new file mode 100644
index 0000000..7aed8c3
--- /dev/null
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackHaManager.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.impl;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.CoreService;
+import org.onosproject.openstacknetworking.api.Constants;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of administering and interfacing openstack HA service.
+ */
+@Component(
+    immediate = true,
+    service = { OpenstackHaService.class }
+)
+public class OpenstackHaManager implements OpenstackHaService {
+
+    protected final Logger log = getLogger(getClass());
+
+    private static final boolean DEFAULT_ACTIVE_STATUS = true;
+    private static final IpAddress DEFAULT_ACTIVE_IP_ADDRESS = IpAddress.valueOf("127.0.0.1");
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected CoreService coreService;
+
+    boolean activeFlag;
+    IpAddress activeIpAddress;
+
+    @Activate
+    protected void activate() {
+        coreService.registerApplication(Constants.OPENSTACK_NETWORKING_APP_ID);
+        activeFlag = DEFAULT_ACTIVE_STATUS;
+        activeIpAddress = DEFAULT_ACTIVE_IP_ADDRESS;
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        log.info("Stopped");
+    }
+
+    @Override
+    public boolean isActive() {
+        return activeFlag;
+    }
+
+    @Override
+    public IpAddress getActiveIp() {
+        return activeIpAddress;
+    }
+
+    @Override
+    public void setActiveIp(IpAddress ip) {
+        this.activeIpAddress = ip;
+    }
+
+    @Override
+    public void setActive(boolean flag) {
+        this.activeFlag = flag;
+    }
+}
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
index ce12d77..31882c9 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
@@ -42,6 +42,7 @@
 import org.apache.sshd.client.future.OpenFuture;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.util.io.NoCloseInputStream;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.onlab.packet.ARP;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.Ip4Address;
@@ -59,6 +60,7 @@
 import org.onosproject.openstacknetworking.api.Constants.VnicType;
 import org.onosproject.openstacknetworking.api.ExternalPeerRouter;
 import org.onosproject.openstacknetworking.api.InstancePort;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetwork.Type;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
@@ -95,6 +97,11 @@
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -115,13 +122,20 @@
 import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Strings.isNullOrEmpty;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
+import static org.apache.commons.io.IOUtils.toInputStream;
 import static org.onlab.packet.Ip4Address.valueOf;
 import static org.onosproject.net.AnnotationKeys.PORT_NAME;
 import static org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC_STR;
+import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_REST_PATH;
 import static org.onosproject.openstacknetworking.api.Constants.PCISLOT;
 import static org.onosproject.openstacknetworking.api.Constants.PCI_VENDOR_INFO;
 import static org.onosproject.openstacknetworking.api.Constants.PORT_NAME_PREFIX_VM;
 import static org.onosproject.openstacknetworking.api.Constants.PORT_NAME_VHOST_USER_PREFIX_VM;
+import static org.onosproject.openstacknetworking.api.Constants.REST_PASSWORD;
+import static org.onosproject.openstacknetworking.api.Constants.REST_PORT;
+import static org.onosproject.openstacknetworking.api.Constants.REST_USER;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
 import static org.onosproject.openstacknetworking.api.Constants.portNamePrefixMap;
 import static org.openstack4j.core.transport.ObjectMapperSingleton.getContext;
@@ -177,13 +191,14 @@
     /**
      * Interprets JSON string to corresponding openstack model entity object.
      *
-     * @param input JSON string
+     * @param inputStr JSON string
      * @param entityClazz openstack model entity class
      * @return openstack model entity object
      */
-    public static ModelEntity jsonToModelEntity(InputStream input, Class entityClazz) {
+    public static ModelEntity jsonToModelEntity(String inputStr, Class entityClazz) {
         ObjectMapper mapper = new ObjectMapper();
         try {
+            InputStream input = toInputStream(inputStr, REST_UTF8);
             JsonNode jsonTree = mapper.enable(INDENT_OUTPUT).readTree(input);
             log.trace(new ObjectMapper().writeValueAsString(jsonTree));
             return ObjectMapperSingleton.getContext(entityClazz)
@@ -1088,6 +1103,118 @@
         }
     }
 
+    /**
+     * Returns the REST URL of active node.
+     *
+     * @param haService openstack HA service
+     * @return REST URL of active node
+     */
+    public static String getActiveUrl(OpenstackHaService haService) {
+        return "http://" + haService.getActiveIp().toString() + ":" +
+                REST_PORT + "/" + OPENSTACK_NETWORKING_REST_PATH + "/";
+    }
+
+    /**
+     * Returns the REST client instance with given resource path.
+     *
+     * @param haService         openstack HA service
+     * @param resourcePath      resource path
+     * @return REST client instance
+     */
+    public static WebTarget getActiveClient(OpenstackHaService haService,
+                                            String resourcePath) {
+        HttpAuthenticationFeature feature =
+                HttpAuthenticationFeature.universal(REST_USER, REST_PASSWORD);
+        Client client = ClientBuilder.newClient().register(feature);
+        return client.target(getActiveUrl(haService)).path(resourcePath);
+    }
+
+    /**
+     * Returns the post response from the active node.
+     *
+     * @param haService         openstack HA service
+     * @param resourcePath      resource path
+     * @param input             input
+     * @return post response
+     */
+    public static Response syncPost(OpenstackHaService haService,
+                                    String resourcePath,
+                                    String input) {
+
+        log.debug("Sync POST request with {} on {}",
+                            haService.getActiveIp().toString(), resourcePath);
+
+        return getActiveClient(haService, resourcePath)
+                .request(APPLICATION_JSON_TYPE)
+                .post(Entity.json(input));
+    }
+
+    /**
+     * Returns the put response from the active node.
+     *
+     * @param haService         openstack HA service
+     * @param resourcePath      resource path
+     * @param id                resource identifier
+     * @param input             input
+     * @return put response
+     */
+    public static Response syncPut(OpenstackHaService haService,
+                                   String resourcePath,
+                                   String id, String input) {
+        return syncPut(haService, resourcePath, null, id, input);
+    }
+
+    /**
+     * Returns the put response from the active node.
+     *
+     * @param haService         openstack HA service
+     * @param resourcePath      resource path
+     * @param id                resource identifier
+     * @param suffix            resource suffix
+     * @param input             input
+     * @return put response
+     */
+    public static Response syncPut(OpenstackHaService haService,
+                                   String resourcePath,
+                                   String suffix,
+                                   String id, String input) {
+
+        log.debug("Sync PUT request with {} on {}",
+                haService.getActiveIp().toString(), resourcePath);
+
+        String pathStr = "/" + id;
+
+        if (suffix != null) {
+            pathStr += "/" + suffix;
+        }
+
+        return getActiveClient(haService, resourcePath)
+                .path(pathStr)
+                .request(APPLICATION_JSON_TYPE)
+                .put(Entity.json(input));
+    }
+
+    /**
+     * Returns the delete response from the active node.
+     *
+     * @param haService         openstack HA service
+     * @param resourcePath      resource path
+     * @param id            resource identifier
+     * @return delete response
+     */
+    public static Response syncDelete(OpenstackHaService haService,
+                                      String resourcePath,
+                                      String id) {
+
+        log.debug("Sync DELETE request with {} on {}",
+                haService.getActiveIp().toString(), resourcePath);
+
+        return getActiveClient(haService, resourcePath)
+                .path("/" + id)
+                .request(APPLICATION_JSON_TYPE)
+                .delete();
+    }
+
     private static Router getRouterFromSubnet(Subnet subnet,
                                               OpenstackRouterService osRouterService) {
         RouterInterface osRouterIface = osRouterService.routerInterfaces().stream()
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResource.java
index 25bc74b..33a0fa6 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResource.java
@@ -16,6 +16,8 @@
 
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronFloatingIP;
@@ -34,12 +36,17 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
 import static javax.ws.rs.core.Response.status;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPut;
 
 /**
  * Handles floating IP REST API call of Neutron L3 plugin.
@@ -53,6 +60,7 @@
 
     private final OpenstackRouterAdminService adminService =
                                         get(OpenstackRouterAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -63,16 +71,23 @@
      * @param input floating ip JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated floating ip already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronFloatingIp
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createFloatingIp(InputStream input) {
+    public Response createFloatingIp(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, FLOATING_IPS, inputStr);
+        }
+
         final NeutronFloatingIP floatingIp = (NeutronFloatingIP)
-                                jsonToModelEntity(input, NeutronFloatingIP.class);
+                jsonToModelEntity(inputStr, NeutronFloatingIP.class);
 
         adminService.createFloatingIp(floatingIp);
 
@@ -90,17 +105,24 @@
      * @param input floating ip JSON input stream
      * @return 200 OK with the updated floating ip, 400 BAD_REQUEST if the requested
      * floating ip does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronFloatingIp
      */
     @PUT
     @Path("{id}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response updateFloatingIp(@PathParam("id") String id, InputStream input) {
+    public Response updateFloatingIp(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, FLOATING_IPS, id, inputStr);
+        }
+
         final NeutronFloatingIP floatingIp = (NeutronFloatingIP)
-                                jsonToModelEntity(input, NeutronFloatingIP.class);
+                jsonToModelEntity(inputStr, NeutronFloatingIP.class);
 
         adminService.updateFloatingIp(floatingIp);
 
@@ -119,6 +141,10 @@
     public Response deleteFloatingIp(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "DELETE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, FLOATING_IPS, id);
+        }
+
         adminService.removeFloatingIp(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackManagementWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackManagementWebResource.java
index 008c5e5..3628848 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackManagementWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackManagementWebResource.java
@@ -19,12 +19,14 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
+import org.onlab.packet.IpAddress;
 import org.onlab.util.ItemNotFoundException;
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.net.flow.FlowRuleService;
 import org.onosproject.openstacknetworking.api.Constants;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
 import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
@@ -42,7 +44,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -57,6 +61,7 @@
 
 import static java.lang.Thread.sleep;
 import static java.util.stream.StreamSupport.stream;
+import static javax.ws.rs.core.Response.status;
 import static org.onlab.util.Tools.nullIsIllegal;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.addRouterIface;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.checkActivationFlag;
@@ -93,6 +98,9 @@
     private static final String HTTP_HEADER_ACCEPT = "accept";
     private static final String HTTP_HEADER_VALUE_JSON = "application/json";
 
+    private static final String FLAG_TRUE = "true";
+    private static final String FLAG_FALSE = "false";
+
     private final ObjectNode root = mapper().createObjectNode();
     private final ArrayNode floatingipsNode = root.putArray(FLOATINGIPS);
 
@@ -104,6 +112,7 @@
             get(OpenstackRouterAdminService.class);
     private final OpenstackNodeAdminService osNodeAdminService =
             get(OpenstackNodeAdminService.class);
+    private final OpenstackHaService osHaService = get(OpenstackHaService.class);
     private final FlowRuleService flowRuleService = get(FlowRuleService.class);
     private final CoreService coreService = get(CoreService.class);
 
@@ -355,6 +364,46 @@
         return ok(root).build();
     }
 
+    /**
+     * Configures the HA active-standby status.
+     *
+     * @param flag active-standby status
+     * @return 200 OK or 400 BAD_REQUEST
+     */
+    @PUT
+    @Path("active/status/{flag}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response updateActiveStatus(@PathParam("flag") String flag) {
+
+        if (FLAG_TRUE.equalsIgnoreCase(flag)) {
+            osHaService.setActive(true);
+        }
+
+        if (FLAG_FALSE.equalsIgnoreCase(flag)) {
+            osHaService.setActive(false);
+        }
+
+        return status(Response.Status.OK).build();
+    }
+
+    /**
+     * Configures the HA active IP address.
+     *
+     * @param ip IP address of active node
+     * @return 200 OK or 400 BAD_REQUEST
+     */
+    @PUT
+    @Path("active/ip/{ip}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response updateActiveIp(@PathParam("ip") String ip) {
+
+        osHaService.setActiveIp(IpAddress.valueOf(ip));
+
+        return status(Response.Status.OK).build();
+    }
+
     private void syncRulesBase() {
         // we first initialize the COMPUTE node, in order to feed all instance ports
         // by referring to ports' information obtained from neutron server
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResource.java
index 567b7bd..208af92 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResource.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronNetwork;
@@ -33,12 +35,17 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
 import static javax.ws.rs.core.Response.status;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPut;
 
 /**
  * Handles network REST API call of Neutron ML2 plugin.
@@ -52,6 +59,7 @@
 
     private final OpenstackNetworkAdminService adminService =
                                         get(OpenstackNetworkAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -62,16 +70,23 @@
      * @param input network JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated network already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronNetwork
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createNetwork(InputStream input) {
+    public Response createNetwork(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, NETWORKS, inputStr);
+        }
+
         final NeutronNetwork net = (NeutronNetwork)
-                             jsonToModelEntity(input, NeutronNetwork.class);
+                jsonToModelEntity(inputStr, NeutronNetwork.class);
 
         adminService.createNetwork(net);
 
@@ -89,17 +104,24 @@
      * @param input network JSON input stream
      * @return 200 OK with the updated network, 400 BAD_REQUEST if the requested
      * network does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronNetwork
      */
     @PUT
     @Path("{id}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response updateNetwork(@PathParam("id") String id, InputStream input) {
+    public Response updateNetwork(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, NETWORKS, id, inputStr);
+        }
+
         final NeutronNetwork net = (NeutronNetwork)
-                             jsonToModelEntity(input, NeutronNetwork.class);
+                jsonToModelEntity(inputStr, NeutronNetwork.class);
 
         adminService.updateNetwork(net);
 
@@ -119,6 +141,10 @@
     public Response deleteNetwork(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "DELETE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, NETWORKS, id);
+        }
+
         adminService.removeNetwork(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResource.java
index d1a0ab3..c5b9b6e 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResource.java
@@ -17,6 +17,8 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.openstacknode.api.DpdkConfig;
 import org.onosproject.openstacknode.api.OpenstackNode;
@@ -38,12 +40,17 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
 import static javax.ws.rs.core.Response.status;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPut;
 
 /**
  * Handles port REST API call from Neutron ML2 plugin.
@@ -61,6 +68,7 @@
     private final OpenstackNetworkAdminService
                         adminService = get(OpenstackNetworkAdminService.class);
     private final OpenstackNodeService nodeService = get(OpenstackNodeService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -71,16 +79,23 @@
      * @param input port JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated port already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronPort
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createPorts(InputStream input) {
+    public Response createPorts(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, PORTS, inputStr);
+        }
+
         final NeutronPort port = (NeutronPort)
-                                 jsonToModelEntity(input, NeutronPort.class);
+                jsonToModelEntity(inputStr, NeutronPort.class);
 
         adminService.createPort(port);
         UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
@@ -97,17 +112,24 @@
      * @param input port JSON input stream
      * @return 200 OK with the updated port, 400 BAD_REQUEST if the requested
      * port does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronPort
      */
     @PUT
     @Path("{id}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response updatePort(@PathParam("id") String id, InputStream input) {
+    public Response updatePort(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, PORTS, id, inputStr);
+        }
+
         final NeutronPort port = (NeutronPort)
-                                 jsonToModelEntity(input, NeutronPort.class);
+                jsonToModelEntity(inputStr, NeutronPort.class);
 
         adminService.updatePort(port);
         ObjectMapper mapper = new ObjectMapper();
@@ -144,6 +166,10 @@
     public Response deletePorts(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "DELETE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, PORTS, id);
+        }
+
         adminService.removePort(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
index 444b351..bdd4b60 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronRouter;
@@ -34,12 +36,17 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
 import static javax.ws.rs.core.Response.status;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPut;
 
 /**
  * Handles router REST API call of Neutron L3 plugin.
@@ -55,6 +62,7 @@
 
     private final OpenstackRouterAdminService adminService =
                                         get(OpenstackRouterAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -65,16 +73,23 @@
      * @param input router JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated router already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronRouter
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createRouter(InputStream input) {
+    public Response createRouter(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE_ROUTER, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, ROUTERS, inputStr);
+        }
+
         final NeutronRouter osRouter = (NeutronRouter)
-                            jsonToModelEntity(input, NeutronRouter.class);
+                            jsonToModelEntity(inputStr, NeutronRouter.class);
 
         adminService.createRouter(osRouter);
 
@@ -92,17 +107,24 @@
      * @param input router JSON input stream
      * @return 200 OK with the updated router, 400 BAD_REQUEST if the requested
      * router does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronRouter
      */
     @PUT
     @Path("{id}")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response updateRouter(@PathParam("id") String id, InputStream input) {
+    public Response updateRouter(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE_ROUTER, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, ROUTERS, id, inputStr);
+        }
+
         final NeutronRouter osRouter = (NeutronRouter)
-                            jsonToModelEntity(input, NeutronRouter.class);
+                jsonToModelEntity(inputStr, NeutronRouter.class);
 
         osRouter.setId(id);
         adminService.updateRouter(osRouter);
@@ -117,17 +139,24 @@
      * @param input router interface JSON input stream
      * @return 200 OK with the updated router interface, 400 BAD_REQUEST if the
      * requested router does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronRouterInterface
      */
     @PUT
     @Path("{id}/add_router_interface")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response addRouterInterface(@PathParam("id") String id, InputStream input) {
+    public Response addRouterInterface(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE_ROUTER_IFACE, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, ROUTERS, "add_router_interface", id, inputStr);
+        }
+
         final NeutronRouterInterface osRouterIface = (NeutronRouterInterface)
-                        jsonToModelEntity(input, NeutronRouterInterface.class);
+                        jsonToModelEntity(inputStr, NeutronRouterInterface.class);
 
         adminService.addRouterInterface(osRouterIface);
 
@@ -141,17 +170,24 @@
      * @param input router interface JSON input stream
      * @return 200 OK with the updated router interface, 400 BAD_REQUEST if the
      * requested router does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronRouterInterface
      */
     @PUT
     @Path("{id}/remove_router_interface")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response deleteRouterInterface(@PathParam("id") String id, InputStream input) {
+    public Response deleteRouterInterface(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE_ROUTER_IFACE, "DELETE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, ROUTERS, "remove_router_interface", id, inputStr);
+        }
+
         final NeutronRouterInterface osRouterIface = (NeutronRouterInterface)
-                        jsonToModelEntity(input, NeutronRouterInterface.class);
+                        jsonToModelEntity(inputStr, NeutronRouterInterface.class);
 
         adminService.removeRouterInterface(osRouterIface.getPortId());
 
@@ -170,6 +206,10 @@
     public Response deleteRouter(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE_ROUTER, "DELETE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, ROUTERS, id);
+        }
+
         adminService.removeRouter(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResource.java
index 009e941..895d353 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResource.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronSecurityGroupRule;
@@ -32,11 +34,15 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
 
 /**
  * Handles Security Group Rule Rest API call from Neutron ML2 plugin.
@@ -50,6 +56,7 @@
 
     private final OpenstackSecurityGroupAdminService adminService =
                                     get(OpenstackSecurityGroupAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -60,16 +67,23 @@
      * @param input security group JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated security group rule ID already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronSecurityGroupRule
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createSecurityGroupRules(InputStream input) {
+    public Response createSecurityGroupRules(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, SECURITY_GROUP_RULES, inputStr);
+        }
+
         final NeutronSecurityGroupRule sgRule = (NeutronSecurityGroupRule)
-                        jsonToModelEntity(input, NeutronSecurityGroupRule.class);
+                        jsonToModelEntity(inputStr, NeutronSecurityGroupRule.class);
 
         adminService.createSecurityGroupRule(sgRule);
         UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
@@ -92,6 +106,10 @@
     public Response deleteSecurityGroupRule(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "REMOVE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, SECURITY_GROUP_RULES, id);
+        }
+
         adminService.removeSecurityGroupRule(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResource.java
index b1f1d47..3c9c2b4 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResource.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronSecurityGroup;
@@ -33,11 +35,15 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
 
 /**
  * Handles Security Group REST API call from Neutron ML2 plugin.
@@ -51,6 +57,7 @@
 
     private final OpenstackSecurityGroupAdminService adminService =
                                     get(OpenstackSecurityGroupAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -61,16 +68,23 @@
      * @param input security group JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated security group ID already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronSecurityGroup
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createSecurityGroups(InputStream input) {
+    public Response createSecurityGroups(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, SECURITY_GROUPS, inputStr);
+        }
+
         final NeutronSecurityGroup sg = (NeutronSecurityGroup)
-                            jsonToModelEntity(input, NeutronSecurityGroup.class);
+                jsonToModelEntity(inputStr, NeutronSecurityGroup.class);
 
         adminService.createSecurityGroup(sg);
         UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
@@ -112,6 +126,10 @@
     public Response removeSecurityGroup(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "REMOVE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, SECURITY_GROUPS, id);
+        }
+
         adminService.removeSecurityGroup(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
index d8ab462..3f20c09 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.openstacknetworking.web;
 
+import org.apache.commons.io.IOUtils;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.rest.AbstractWebResource;
 import org.openstack4j.openstack.networking.domain.NeutronSubnet;
@@ -33,12 +35,17 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
 import java.io.InputStream;
 
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.noContent;
 import static javax.ws.rs.core.Response.status;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.jsonToModelEntity;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncDelete;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPost;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.syncPut;
 
 /**
  * Handles subnet REST API call from Neutron ML2 plugin.
@@ -52,6 +59,7 @@
 
     private final OpenstackNetworkAdminService adminService =
                                         get(OpenstackNetworkAdminService.class);
+    private final OpenstackHaService haService = get(OpenstackHaService.class);
 
     @Context
     private UriInfo uriInfo;
@@ -62,16 +70,23 @@
      * @param input subnet JSON input stream
      * @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
      * is invalid or duplicated subnet already exists
+     * @throws IOException exception
      * @onos.rsModel NeutronSubnet
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
-    public Response createSubnet(InputStream input) {
+    public Response createSubnet(InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "CREATE"));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPost(haService, SUBNETS, inputStr);
+        }
+
         final NeutronSubnet subnet = (NeutronSubnet)
-                            jsonToModelEntity(input, NeutronSubnet.class);
+                jsonToModelEntity(inputStr, NeutronSubnet.class);
 
         adminService.createSubnet(subnet);
         UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
@@ -89,17 +104,24 @@
      * @param input subnet JSON input stream
      * @return 200 OK with the updated subnet, 400 BAD_REQUEST if the requested
      * subnet does not exist
+     * @throws IOException exception
      * @onos.rsModel NeutronSubnet
      */
     @PUT
     @Path("{id}")
     @Produces(MediaType.APPLICATION_JSON)
     @Consumes(MediaType.APPLICATION_JSON)
-    public Response updateSubnet(@PathParam("id") String id, InputStream input) {
+    public Response updateSubnet(@PathParam("id") String id, InputStream input) throws IOException {
         log.trace(String.format(MESSAGE, "UPDATE " + id));
 
+        String inputStr = IOUtils.toString(input, REST_UTF8);
+
+        if (!haService.isActive()) {
+            return syncPut(haService, SUBNETS, id, inputStr);
+        }
+
         final NeutronSubnet subnet = (NeutronSubnet)
-                            jsonToModelEntity(input, NeutronSubnet.class);
+                            jsonToModelEntity(inputStr, NeutronSubnet.class);
 
         adminService.updateSubnet(subnet);
 
@@ -119,6 +141,10 @@
     public Response deleteSubnet(@PathParam("id") String id) {
         log.trace(String.format(MESSAGE, "DELETE " + id));
 
+        if (!haService.isActive()) {
+            return syncDelete(haService, SUBNETS, id);
+        }
+
         adminService.removeSubnet(id);
         return noContent().build();
     }
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingSnatIcmpHandlerTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingSnatIcmpHandlerTest.java
index e4846ad..7dbbed1 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingSnatIcmpHandlerTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingSnatIcmpHandlerTest.java
@@ -18,6 +18,7 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.MoreExecutors;
+import org.apache.commons.io.IOUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,6 +61,7 @@
 import org.openstack4j.openstack.networking.domain.NeutronRouter;
 import org.openstack4j.openstack.networking.domain.NeutronSubnet;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.util.Map;
@@ -73,6 +75,7 @@
 import static org.onlab.packet.ICMP.TYPE_ECHO_REPLY;
 import static org.onlab.packet.ICMP.TYPE_ECHO_REQUEST;
 import static org.onosproject.net.NetTestTools.connectPoint;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 
 public class OpenstackRoutingSnatIcmpHandlerTest {
     private OpenstackRoutingSnatIcmpHandler icmpHandler;
@@ -108,7 +111,7 @@
      * Initial setup for this unit test.
      */
     @Before
-    public void setUp() {
+    public void setUp() throws IOException {
 
         icmpHandler = new OpenstackRoutingSnatIcmpHandler();
 
@@ -432,24 +435,27 @@
     }
 
 
-    private void createPort() {
+    private void createPort() throws IOException {
         InputStream portJsonStream1 = OpenstackRoutingSnatIcmpHandlerTest.class
                 .getResourceAsStream("openstack-port-1.json");
-        port1 = (Port) OpenstackNetworkingUtil.jsonToModelEntity(portJsonStream1, NeutronPort.class);
+        port1 = (Port) OpenstackNetworkingUtil.jsonToModelEntity(
+                IOUtils.toString(portJsonStream1, REST_UTF8), NeutronPort.class);
 
         InputStream portJsonStream2 = OpenstackRoutingSnatIcmpHandlerTest.class
                 .getResourceAsStream("openstack-port-external.json");
-        externalPort = (Port) OpenstackNetworkingUtil.jsonToModelEntity(portJsonStream2, NeutronPort.class);
+        externalPort = (Port) OpenstackNetworkingUtil.jsonToModelEntity(
+                IOUtils.toString(portJsonStream2, REST_UTF8), NeutronPort.class);
 
         portMap.put(port1.getId(), port1);
         portMap.put(externalPort.getId(), externalPort);
 
     }
 
-    private void createSubnet() {
+    private void createSubnet() throws IOException {
         InputStream subnetJsonStream1 = OpenstackRoutingSnatIcmpHandlerTest.class
                 .getResourceAsStream("openstack-subnet-1.json");
-        subnet1 = (Subnet) OpenstackNetworkingUtil.jsonToModelEntity(subnetJsonStream1, NeutronSubnet.class);
+        subnet1 = (Subnet) OpenstackNetworkingUtil.jsonToModelEntity(
+                IOUtils.toString(subnetJsonStream1, REST_UTF8), NeutronSubnet.class);
     }
 
     private void createRouterInterfaceMap() {
@@ -461,11 +467,12 @@
         osRouterInterfaceMap.put(routerInterface1.getPortId(), routerInterface1);
     }
 
-    private void createRouterMap() {
+    private void createRouterMap() throws IOException {
         InputStream routerStream1 = OpenstackRoutingSnatIcmpHandlerTest.class
                 .getResourceAsStream("openstack-router-1.json");
         router1 = (Router)
-                OpenstackNetworkingUtil.jsonToModelEntity(routerStream1, NeutronRouter.class);
+                OpenstackNetworkingUtil.jsonToModelEntity(
+                        IOUtils.toString(routerStream1, REST_UTF8), NeutronRouter.class);
         osRouterMap.put(router1.getId(), router1);
 
     }
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
index c6e403a..e5635e5 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
@@ -47,6 +47,7 @@
 import org.onosproject.openstacknetworking.impl.TestRouterInterface;
 import org.onosproject.openstacknetworking.web.OpenstackFloatingIpWebResourceTest;
 import org.onosproject.openstacknetworking.web.OpenstackNetworkWebResourceTest;
+import org.onosproject.openstacknode.api.DefaultKeystoneConfig;
 import org.onosproject.openstacknode.api.DefaultOpenstackAuth;
 import org.onosproject.openstacknode.api.DefaultOpenstackNode;
 import org.onosproject.openstacknode.api.KeystoneConfig;
@@ -54,7 +55,6 @@
 import org.onosproject.openstacknode.api.OpenstackAuth;
 import org.onosproject.openstacknode.api.OpenstackNode;
 import org.onosproject.openstacknode.api.OpenstackNodeTest;
-import org.onosproject.openstacknode.api.DefaultKeystoneConfig;
 import org.openstack4j.model.network.NetFloatingIP;
 import org.openstack4j.model.network.Network;
 import org.openstack4j.model.network.Port;
@@ -75,6 +75,7 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.onosproject.net.AnnotationKeys.PORT_NAME;
+import static org.onosproject.openstacknetworking.api.Constants.REST_UTF8;
 import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.addRouterIface;
 import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.associatedFloatingIp;
@@ -109,7 +110,7 @@
     private OpenstackNode openstackControlNodeV3;
 
     @Before
-    public void setUp() {
+    public void setUp() throws IOException {
 
         instancePort1 = DefaultInstancePort.builder()
                 .networkId("net-id-1")
@@ -151,11 +152,14 @@
                 .getResourceAsStream("openstack-floatingip3.json");
 
         floatingIp1 = (NetFloatingIP)
-                jsonToModelEntity(floatingIpjsonStream1, NeutronFloatingIP.class);
+                jsonToModelEntity(IOUtils.toString(floatingIpjsonStream1, REST_UTF8),
+                        NeutronFloatingIP.class);
         floatingIp2 = (NetFloatingIP)
-                jsonToModelEntity(floatingIpjsonStream2, NeutronFloatingIP.class);
+                jsonToModelEntity(IOUtils.toString(floatingIpjsonStream2, REST_UTF8),
+                        NeutronFloatingIP.class);
         floatingIp3 = (NetFloatingIP)
-                jsonToModelEntity(floatingIpjsonStream3, NeutronFloatingIP.class);
+                jsonToModelEntity(IOUtils.toString(floatingIpjsonStream3, REST_UTF8),
+                        NeutronFloatingIP.class);
 
         InputStream portJsonStream = OpenstackNetworkWebResourceTest.class
                 .getResourceAsStream("openstack-port.json");
@@ -168,14 +172,18 @@
                 .getResourceAsStream("openstack-port-sriov3.json");
 
         openstackPort = (Port)
-                jsonToModelEntity(portJsonStream, NeutronPort.class);
+                jsonToModelEntity(
+                        IOUtils.toString(portJsonStream, REST_UTF8), NeutronPort.class);
 
         openstackSriovPort1 = (Port)
-                jsonToModelEntity(sriovPortJsonStream1, NeutronPort.class);
+                jsonToModelEntity(IOUtils.toString(sriovPortJsonStream1, REST_UTF8),
+                        NeutronPort.class);
         openstackSriovPort2 = (Port)
-                jsonToModelEntity(sriovPortJsonStream2, NeutronPort.class);
+                jsonToModelEntity(IOUtils.toString(sriovPortJsonStream2, REST_UTF8),
+                        NeutronPort.class);
         openstackSriovPort3 = (Port)
-                jsonToModelEntity(sriovPortJsonStream3, NeutronPort.class);
+                jsonToModelEntity(IOUtils.toString(sriovPortJsonStream3, REST_UTF8),
+                        NeutronPort.class);
     }
 
     @After
@@ -191,7 +199,7 @@
                 modelEntityToJson(floatingIp1, NeutronFloatingIP.class);
         InputStream is = IOUtils.toInputStream(floatingIpNode.toString(), StandardCharsets.UTF_8.name());
         NetFloatingIP floatingIp2 = (NetFloatingIP)
-                jsonToModelEntity(is, NeutronFloatingIP.class);
+                jsonToModelEntity(IOUtils.toString(is, REST_UTF8), NeutronFloatingIP.class);
         new EqualsTester().addEqualityGroup(floatingIp1, floatingIp2).testEquals();
     }
 
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResourceTest.java
index e786784..f5890e5 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackFloatingIpWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackRouterAdminService mockOpenstackRouterAdminService =
             createMock(OpenstackRouterAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "floatingips";
 
     /**
@@ -62,9 +65,9 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackRouterAdminService.class,
-                                mockOpenstackRouterAdminService);
+                                mockOpenstackRouterAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
-
     }
 
     /**
@@ -74,6 +77,8 @@
     public void testCreateFloatingIpWithCreationOperation() {
         mockOpenstackRouterAdminService.createFloatingIp(anyObject());
         replay(mockOpenstackRouterAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackFloatingIpWebResourceTest.class
@@ -93,6 +98,8 @@
      */
     @Test
     public void testCreateFloatingIpWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackFloatingIpWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -109,6 +116,8 @@
      */
     @Test
     public void testCreateFloatingIpWithDuplicatedIp() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.createFloatingIp(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -131,6 +140,8 @@
      */
     @Test
     public void testUpdateFloatingIpWithUpdatingOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.updateFloatingIp(anyObject());
         replay(mockOpenstackRouterAdminService);
 
@@ -153,6 +164,8 @@
      */
     @Test
     public void testUpdateFloatingIpWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackFloatingIpWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -170,6 +183,8 @@
      */
     @Test
     public void testUpdateFloatingIpWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.updateFloatingIp(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -193,6 +208,8 @@
      */
     @Test
     public void testDeleteFloatingIpWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeFloatingIp(anyString());
         replay(mockOpenstackRouterAdminService);
 
@@ -213,6 +230,8 @@
      */
     @Test
     public void testDeleteFloatingIpWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeFloatingIp(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResourceTest.java
index bbac93b..ecafc14 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackNetworkWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackNetworkAdminService mockOpenstackNetworkAdminService =
             createMock(OpenstackNetworkAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "networks";
 
     /**
@@ -62,7 +65,8 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackNetworkAdminService.class,
-                                mockOpenstackNetworkAdminService);
+                                mockOpenstackNetworkAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
     }
 
@@ -73,6 +77,8 @@
     public void testCreateNetworkWithCreationOperation() {
         mockOpenstackNetworkAdminService.createNetwork(anyObject());
         replay(mockOpenstackNetworkAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
@@ -92,6 +98,9 @@
      */
     @Test
     public void testCreateNetworkWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -111,6 +120,8 @@
         mockOpenstackNetworkAdminService.createNetwork(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
@@ -132,6 +143,8 @@
     public void testUpdateNetworkWithUpdatingOperation() {
         mockOpenstackNetworkAdminService.updateNetwork(anyObject());
         replay(mockOpenstackNetworkAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
@@ -152,6 +165,9 @@
      */
     @Test
     public void testUpdateNetworkWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -169,6 +185,8 @@
      */
     @Test
     public void testUpdateNetworkWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.updateNetwork(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
@@ -192,6 +210,8 @@
      */
     @Test
     public void testDeleteNetworkWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.removeNetwork(anyString());
         replay(mockOpenstackNetworkAdminService);
 
@@ -212,6 +232,8 @@
      */
     @Test
     public void testDeleteNetworkWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.removeNetwork(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResourceTest.java
index 7d7a603..ad0867a 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackPortWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.openstacknode.api.OpenstackNodeService;
 import org.onosproject.rest.resources.ResourceTest;
@@ -33,6 +34,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -48,6 +50,8 @@
             createMock(OpenstackNetworkAdminService.class);
     final OpenstackNodeService mockOpenstackNodeService =
             createMock(OpenstackNodeService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
+
     private static final String PATH = "ports";
 
     /**
@@ -64,7 +68,8 @@
     public void setUpTest() {
         ServiceDirectory testDirectory = new TestServiceDirectory()
                 .add(OpenstackNetworkAdminService.class, mockOpenstackNetworkAdminService)
-                .add(OpenstackNodeService.class, mockOpenstackNodeService);
+                .add(OpenstackNodeService.class, mockOpenstackNodeService)
+                .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
 
     }
@@ -76,6 +81,8 @@
     public void testCreatePortWithCreationOperation() {
         mockOpenstackNetworkAdminService.createPort(anyObject());
         replay(mockOpenstackNetworkAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
@@ -95,6 +102,9 @@
      */
     @Test
     public void testCreatePortWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackPortWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -111,6 +121,8 @@
      */
     @Test
     public void testCreatePortWithDuplicatedId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.createPort(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
@@ -133,6 +145,8 @@
      */
     @Test
     public void testUpdatePortWithUpdatingOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.updatePort(anyObject());
         replay(mockOpenstackNetworkAdminService);
 
@@ -155,6 +169,9 @@
      */
     @Test
     public void testUpdatePortWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackNetworkWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -172,6 +189,9 @@
      */
     @Test
     public void testUpdatePortWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         mockOpenstackNetworkAdminService.updatePort(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
@@ -195,6 +215,9 @@
      */
     @Test
     public void testDeletePortWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         mockOpenstackNetworkAdminService.removePort(anyString());
         replay(mockOpenstackNetworkAdminService);
 
@@ -215,6 +238,9 @@
      */
     @Test
     public void testDeletePortWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         mockOpenstackNetworkAdminService.removePort(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java
index d0a24b3..3763e48 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackRouterAdminService mockOpenstackRouterAdminService =
             createMock(OpenstackRouterAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "routers";
 
     /**
@@ -62,7 +65,8 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackRouterAdminService.class,
-                                mockOpenstackRouterAdminService);
+                                mockOpenstackRouterAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
     }
 
@@ -73,6 +77,8 @@
     public void testCreateRouterWithCreationOperation() {
         mockOpenstackRouterAdminService.createRouter(anyObject());
         replay(mockOpenstackRouterAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackRouterWebResourceTest.class
@@ -92,6 +98,9 @@
      */
     @Test
     public void testCreateRouterWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackRouterWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -108,6 +117,8 @@
      */
     @Test
     public void testCreateRouterWithDuplicatedId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.createRouter(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -130,6 +141,8 @@
      */
     @Test
     public void testUpdateRouterWithUpdatingOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.updateRouter(anyObject());
         replay(mockOpenstackRouterAdminService);
 
@@ -152,6 +165,9 @@
      */
     @Test
     public void testUpdateRouterWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackRouterWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -169,6 +185,8 @@
      */
     @Test
     public void testUpdateRouterWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.updateRouter(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -192,6 +210,8 @@
      */
     @Test
     public void testDeleteRouterWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeRouter(anyString());
         replay(mockOpenstackRouterAdminService);
 
@@ -212,6 +232,8 @@
      */
     @Test
     public void testDeleteRouterWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeRouter(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -233,6 +255,8 @@
      */
     @Test
     public void testAddRouterInterfaceWithAdditionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.addRouterInterface(anyObject());
         replay(mockOpenstackRouterAdminService);
 
@@ -255,6 +279,8 @@
      */
     @Test
     public void testAddRouterInterfaceWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.addRouterInterface(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
@@ -278,6 +304,8 @@
      */
     @Test
     public void testDeleteRouterInterfaceWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeRouterInterface(anyString());
         replay(mockOpenstackRouterAdminService);
 
@@ -300,6 +328,8 @@
      */
     @Test
     public void testDeleteRouterInterfaceWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackRouterAdminService.removeRouterInterface(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackRouterAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResourceTest.java
index 4ffafc1..57caf0b 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupRuleWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackSecurityGroupAdminService mockOpenstackSecurityGroupAdminService =
             createMock(OpenstackSecurityGroupAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "security-group-rules";
 
     /**
@@ -62,7 +65,8 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackSecurityGroupAdminService.class,
-                                mockOpenstackSecurityGroupAdminService);
+                                mockOpenstackSecurityGroupAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
     }
 
@@ -71,6 +75,8 @@
      */
     @Test
     public void testCreateSecurityGroupRulesWithCreationOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.createSecurityGroupRule(anyObject());
         replay(mockOpenstackSecurityGroupAdminService);
 
@@ -92,6 +98,9 @@
      */
     @Test
     public void testCreateSecurityGroupRulesWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSecurityGroupRuleWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -108,6 +117,8 @@
      */
     @Test
     public void testCreateSecurityGroupRulesWithDuplicatedId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.createSecurityGroupRule(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackSecurityGroupAdminService);
@@ -130,6 +141,8 @@
      */
     @Test
     public void testDeleteSecurityGroupRuleWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.removeSecurityGroupRule(anyString());
         replay(mockOpenstackSecurityGroupAdminService);
 
@@ -150,6 +163,8 @@
      */
     @Test
     public void testDeleteSecurityGroupRuleWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.removeSecurityGroupRule(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackSecurityGroupAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResourceTest.java
index 49f85b4..d8b7844 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSecurityGroupWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackSecurityGroupAdminService mockOpenstackSecurityGroupAdminService =
             createMock(OpenstackSecurityGroupAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "security-groups";
 
     /**
@@ -62,7 +65,8 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackSecurityGroupAdminService.class,
-                                mockOpenstackSecurityGroupAdminService);
+                                mockOpenstackSecurityGroupAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
     }
 
@@ -73,6 +77,8 @@
     public void testCreateSecurityGroupWithCreationOperation() {
         mockOpenstackSecurityGroupAdminService.createSecurityGroup(anyObject());
         replay(mockOpenstackSecurityGroupAdminService);
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
 
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSecurityGroupWebResourceTest.class
@@ -92,6 +98,9 @@
      */
     @Test
     public void testCreateSecurityGroupWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSecurityGroupWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -108,6 +117,8 @@
      */
     @Test
     public void testCreateSecurityGroupWithDuplicatedId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.createSecurityGroup(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackSecurityGroupAdminService);
@@ -130,6 +141,9 @@
      */
     @Test
     public void testUpdateSecurityGroupWithUpdatingOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSecurityGroupWebResourceTest.class
                 .getResourceAsStream("openstack-security-group.json");
@@ -147,6 +161,8 @@
      */
     @Test
     public void testDeleteSecurityGroupWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.removeSecurityGroup(anyString());
         replay(mockOpenstackSecurityGroupAdminService);
 
@@ -167,6 +183,8 @@
      */
     @Test
     public void testDeleteSecurityGroupWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackSecurityGroupAdminService.removeSecurityGroup(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackSecurityGroupAdminService);
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java
index 1dabccb..cd9a39d 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java
@@ -20,6 +20,7 @@
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackHaService;
 import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
 import org.onosproject.rest.resources.ResourceTest;
 
@@ -32,6 +33,7 @@
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
@@ -45,6 +47,7 @@
 
     final OpenstackNetworkAdminService mockOpenstackNetworkAdminService =
             createMock(OpenstackNetworkAdminService.class);
+    final OpenstackHaService mockOpenstackHaService = createMock(OpenstackHaService.class);
     private static final String PATH = "subnets";
 
     /**
@@ -62,7 +65,8 @@
         ServiceDirectory testDirectory =
                 new TestServiceDirectory()
                         .add(OpenstackNetworkAdminService.class,
-                                mockOpenstackNetworkAdminService);
+                                mockOpenstackNetworkAdminService)
+                        .add(OpenstackHaService.class, mockOpenstackHaService);
         setServiceDirectory(testDirectory);
 
     }
@@ -72,6 +76,8 @@
      */
     @Test
     public void testCreateSubnetWithCreationOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.createSubnet(anyObject());
         replay(mockOpenstackNetworkAdminService);
 
@@ -93,6 +99,8 @@
      */
     @Test
     public void testCreateSubnetWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSubnetWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -109,6 +117,8 @@
      */
     @Test
     public void testCreateSubnetWithDuplicatedId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.createSubnet(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
@@ -131,6 +141,8 @@
      */
     @Test
     public void testUpdateSubnetWithUpdatingOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.updateSubnet(anyObject());
         replay(mockOpenstackNetworkAdminService);
 
@@ -153,6 +165,9 @@
      */
     @Test
     public void testUpdateSubnetWithIncorrectInput() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
+
         final WebTarget wt = target();
         InputStream jsonStream = OpenstackSubnetWebResourceTest.class
                 .getResourceAsStream("dummy.json");
@@ -170,6 +185,8 @@
      */
     @Test
     public void testUpdateSubnetWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.updateSubnet(anyObject());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);
@@ -193,6 +210,8 @@
      */
     @Test
     public void testDeleteSubnetWithDeletionOperation() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.removeSubnet(anyString());
         replay(mockOpenstackNetworkAdminService);
 
@@ -213,6 +232,8 @@
      */
     @Test
     public void testDeleteSubnetWithNonexistId() {
+        expect(mockOpenstackHaService.isActive()).andReturn(true).anyTimes();
+        replay(mockOpenstackHaService);
         mockOpenstackNetworkAdminService.removeSubnet(anyString());
         expectLastCall().andThrow(new IllegalArgumentException());
         replay(mockOpenstackNetworkAdminService);