cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-10053) Performance improvement: Caching of external id's
Date Thu, 02 Nov 2017 10:14:02 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-10053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16235498#comment-16235498 ] 

ASF GitHub Bot commented on CLOUDSTACK-10053:
---------------------------------------------

fmaximus closed pull request #2238: [CLOUDSTACK-10053] Performance improvement: caching of NuageVsp ID
URL: https://github.com/apache/cloudstack/pull/2238
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDao.java b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDao.java
index 2a0f751b404..ef8df516e9f 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDao.java
@@ -48,6 +48,8 @@
 
     NicSecondaryIpVO findByIp4AddressAndNicId(String ip4Address, long nicId);
 
+    NicSecondaryIpVO findByIp4AddressAndInstanceId(Long vmId, String vmIp);
+
     NicSecondaryIpVO findByIp4AddressAndNetworkIdAndInstanceId(long networkId, Long vmId, String vmIp);
 
     List<String> getSecondaryIpAddressesForNic(long nicId);
diff --git a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDaoImpl.java
index 55c3c8a5146..4b04ff01a6d 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpDaoImpl.java
@@ -119,8 +119,10 @@ public NicSecondaryIpVO findByInstanceIdAndNetworkId(long networkId, long instan
 
     @Override
     public NicSecondaryIpVO findByIp4AddressAndNetworkId(String ip4Address, long networkId) {
-        // TODO Auto-generated method stub
-        return null;
+        SearchCriteria<NicSecondaryIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("network", networkId);
+        sc.setParameters("address", ip4Address);
+        return findOneBy(sc);
     }
 
     @Override
@@ -132,6 +134,14 @@ public NicSecondaryIpVO findByIp4AddressAndNicId(String ip4Address, long nicId)
     }
 
     @Override
+    public NicSecondaryIpVO findByIp4AddressAndInstanceId(Long vmId, String vmIp) {
+        SearchCriteria<NicSecondaryIpVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", vmId);
+        sc.setParameters("address", vmIp);
+        return findOneBy(sc);
+    }
+
+    @Override
     public NicSecondaryIpVO findByIp4AddressAndNetworkIdAndInstanceId(long networkId, Long vmId, String vmIp) {
         SearchCriteria<NicSecondaryIpVO> sc = AllFieldsSearch.create();
         sc.setParameters("network", networkId);
diff --git a/plugins/network-elements/nuage-vsp/pom.xml b/plugins/network-elements/nuage-vsp/pom.xml
index e93978bac2d..fe51c8b0d51 100644
--- a/plugins/network-elements/nuage-vsp/pom.xml
+++ b/plugins/network-elements/nuage-vsp/pom.xml
@@ -35,7 +35,7 @@
     </repository>
   </repositories>
   <properties>
-      <nuage.vsp.client.version>1.0.1</nuage.vsp.client.version>
+      <nuage.vsp.client.version>1.0.5</nuage.vsp.client.version>
   </properties>
   <dependencies>
     <dependency>
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java b/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java
new file mode 100644
index 00000000000..03ab183d7b5
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java
@@ -0,0 +1,45 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 com.cloud.agent.api.manager;
+
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
+
+/**
+ * Created by sgoeminn on 3/24/17.
+ */
+public class ImplementNetworkVspAnswer extends Answer {
+    private NetworkRelatedVsdIds networkRelatedVsdIds;
+
+    public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, NetworkRelatedVsdIds networkRelatedVsdIds) {
+        super(command);
+        this.networkRelatedVsdIds = networkRelatedVsdIds;
+    }
+
+    public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, Exception e) {
+        super(command, e);
+    }
+
+    public NetworkRelatedVsdIds getNetworkRelatedVsdIds() {
+        return networkRelatedVsdIds;
+    }
+}
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
index 79cdcfbae5e..a7ce8c8d403 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
@@ -29,8 +29,6 @@
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
 import net.nuage.vsp.acs.client.api.model.VspAclRule;
 import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
 import net.nuage.vsp.acs.client.api.model.VspNetwork;
@@ -40,8 +38,11 @@
 import org.apache.log4j.Logger;
 
 import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
 import com.google.common.collect.Sets;
 
 import org.apache.cloudstack.api.InternalIdentity;
@@ -521,9 +522,18 @@ public boolean applyStaticNats(Network config, List<? extends StaticNat> rules)
             VlanVO sourceNatVlan = _vlanDao.findById(sourceNatIp.getVlanId());
             checkVlanUnderlayCompatibility(sourceNatVlan);
 
+            if (!staticNat.isForRevoke()) {
+                final List<FirewallRuleVO> firewallRules = _firewallRulesDao.listByIpAndNotRevoked(staticNat.getSourceIpAddressId());
+                for (FirewallRuleVO firewallRule : firewallRules) {
+                    _nuageVspEntityBuilder.buildVspAclRule(firewallRule, config, sourceNatIp);
+                }
+            }
+
             NicVO nicVO = _nicDao.findByIp4AddressAndNetworkId(staticNat.getDestIpAddress(), staticNat.getNetworkId());
             VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(staticNat.isForRevoke(), sourceNatIp, sourceNatVlan, nicVO);
             vspStaticNatDetails.add(vspStaticNat);
+
+
         }
 
         VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(config);
@@ -632,7 +642,7 @@ public boolean applyNetworkACLs(Network config, List<? extends NetworkACLItem> r
     @Override
     public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
         List<VpcOfferingServiceMapVO> vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId());
-        Map<Network.Service, Set<Network.Provider>> supportedVpcServices = NuageVspManagerImpl.NUAGE_VSP_VPC_SERVICE_MAP;
+        Multimap<Service, Provider> supportedVpcServices = NuageVspManagerImpl.NUAGE_VSP_VPC_SERVICE_MAP;
         for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) {
             Network.Service service = Network.Service.getService(vpcOfferingService.getService());
             if (!supportedVpcServices.containsKey(service)) {
@@ -641,7 +651,7 @@ public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext
             }
 
             Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
-            if (!supportedVpcServices.get(service).contains(provider)) {
+            if (!supportedVpcServices.containsEntry(service, provider)) {
                 s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName()));
                 return false;
             }
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
index 9966a381981..0a4733be244 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
@@ -25,9 +25,25 @@
 
 import javax.inject.Inject;
 
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
+import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
+import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
+import net.nuage.vsp.acs.client.api.model.VspDomain;
+import net.nuage.vsp.acs.client.api.model.VspNetwork;
+import net.nuage.vsp.acs.client.api.model.VspNic;
+import net.nuage.vsp.acs.client.api.model.VspStaticNat;
+import net.nuage.vsp.acs.client.api.model.VspVm;
+
+import org.apache.log4j.Logger;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
 import org.apache.cloudstack.resourcedetail.VpcDetailVO;
 import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -36,6 +52,7 @@
 import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
 import com.cloud.agent.api.guru.TrashNetworkVspCommand;
 import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand;
+import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
@@ -82,20 +99,6 @@
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.VMInstanceDao;
-import com.google.common.base.Strings;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
-import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
-import net.nuage.vsp.acs.client.api.model.VspDomain;
-import net.nuage.vsp.acs.client.api.model.VspNetwork;
-import net.nuage.vsp.acs.client.api.model.VspNic;
-import net.nuage.vsp.acs.client.api.model.VspStaticNat;
-import net.nuage.vsp.acs.client.api.model.VspVm;
 
 public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
     public static final Logger s_logger = Logger.getLogger(NuageVspGuestNetworkGuru.class);
@@ -154,6 +157,7 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use
         return networkObject;
     }
 
+    /** In case an externalId is specified, we get called here, and store the id the same way as cached data */
     @Override
     public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException {
         long networkId = network.getId();
@@ -206,7 +210,7 @@ public Network implement(Network network, NetworkOffering offering, DeployDestin
             implemented.setBroadcastUri(Networks.BroadcastDomainType.Vsp.toUri(broadcastUriStr));
             implemented.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp);
 
-            if (!implement(physicalNetworkId, vspNetwork, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) {
+            if (!implement(network.getVpcId(), physicalNetworkId, vspNetwork, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) {
                 return null;
             }
 
@@ -227,10 +231,10 @@ public Network implement(Network network, NetworkOffering offering, DeployDestin
         return implemented;
     }
 
-    private boolean implement(long physicalNetworkId, VspNetwork vspNetwork, VspDhcpDomainOption vspDhcpDomainOption) {
+    private boolean implement(Long vpcId, long physicalNetworkId, VspNetwork vspNetwork, VspDhcpDomainOption vspDhcpDomainOption) {
         HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId);
         ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpDomainOption);
-        Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
+        ImplementNetworkVspAnswer answer = (ImplementNetworkVspAnswer) _agentMgr.easySend(nuageVspHost.getId(), cmd);
         if (answer == null || !answer.getResult()) {
             s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
             if ((null != answer) && (null != answer.getDetails())) {
@@ -238,9 +242,54 @@ private boolean implement(long physicalNetworkId, VspNetwork vspNetwork, VspDhcp
             }
             return false;
         }
+        saveNetworkAndVpcDetails(vspNetwork, answer.getNetworkRelatedVsdIds(), vpcId);
         return true;
     }
 
+    private void saveNetworkAndVpcDetails(VspNetwork vspNetwork, NetworkRelatedVsdIds networkRelatedVsdIds, Long vpcId) {
+
+
+        if (!vspNetwork.isShared() && !vspNetwork.getNetworkRelatedVsdIds().equals(networkRelatedVsdIds)) {
+            Map<String, String> networkDetails = constructNetworkDetails(networkRelatedVsdIds, vspNetwork.isVpc());
+
+            for (Map.Entry<String, String> networkDetail : networkDetails.entrySet()) {
+                NetworkDetailVO networkDetailVO = new NetworkDetailVO(vspNetwork.getId(), networkDetail.getKey(), networkDetail.getValue(), false);
+                _networkDetailsDao.persist(networkDetailVO);
+            }
+
+            if(vspNetwork.isVpc()) {
+                Map<String, String> vpcDetails = constructVpcDetails(networkRelatedVsdIds);
+
+                for (Map.Entry<String, String> vpcDetail : vpcDetails.entrySet()) {
+                    VpcDetailVO vpcDetailVO = new VpcDetailVO(vpcId, vpcDetail.getKey(), vpcDetail.getValue(), false);
+                    _vpcDetailsDao.persist(vpcDetailVO);
+                }
+            }
+        }
+    }
+
+    private static Map<String, String> constructNetworkDetails(NetworkRelatedVsdIds networkRelatedVsdIds, boolean isVpc) {
+        Map<String, String> networkDetails = Maps.newHashMap();
+
+        if(!isVpc) {
+            networkRelatedVsdIds.getVsdDomainId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v));
+            networkRelatedVsdIds.getVsdZoneId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v));
+        }
+        networkRelatedVsdIds.getVsdSubnetId().ifPresent(v ->  networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, v));
+
+        return networkDetails;
+    }
+
+    private static Map<String, String> constructVpcDetails(NetworkRelatedVsdIds networkRelatedVsdIds) {
+        Map<String, String> vpcDetails = Maps.newHashMap();
+
+        networkRelatedVsdIds.getVsdDomainId().ifPresent(v ->  vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v));
+        networkRelatedVsdIds.getVsdZoneId().ifPresent(v ->  vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v));
+
+        return vpcDetails;
+    }
+
+
     @Override
     public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
         if (vm.getType() != VirtualMachine.Type.DomainRouter && _nuageVspEntityBuilder.usesVirtualRouter(network.getNetworkOfferingId())) {
@@ -303,7 +352,7 @@ public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, D
 
                 // Make sure the shared network is present
                 NetworkOffering offering = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
-                if (!implement(network.getPhysicalNetworkId(), vspNetwork, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) {
+                if (!implement(network.getVpcId(), network.getPhysicalNetworkId(), vspNetwork, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) {
                     s_logger.error("Failed to implement shared network " + network.getUuid() + " under domain " + context.getDomain().getUuid());
                     throw new InsufficientVirtualNetworkCapacityException("Failed to implement shared network " + network.getUuid() + " under domain " +
                             context.getDomain().getUuid(), Network.class, network.getId());
@@ -404,15 +453,12 @@ private void updateDhcpOptionsForExistingVms(Network network, HostVO nuageVspHos
     private void checkMultipleSubnetsCombinedWithUseData(Network network) {
         if (_ntwkOfferingSrvcDao.listServicesForNetworkOffering(network.getNetworkOfferingId()).contains(Network.Service.UserData.getName())) {
             List<VlanVO> vlanVOs = _vlanDao.listVlansByNetworkId(network.getId());
-            if (vlanVOs.size() > 1) {
-                VlanVO vlanVoItem = vlanVOs.get(0);
-                for (VlanVO VlanVoItem2 : FluentIterable.from(vlanVOs).skip(1)) {
-                    if (!vlanVoItem.equals(VlanVoItem2)
-                            && !VlanVoItem2.getVlanGateway().equals(vlanVoItem.getVlanGateway())) {
+            if (vlanVOs.stream()
+                       .map(VlanVO::getVlanGateway)
+                       .distinct()
+                       .count() > 1) {
                         s_logger.error("NuageVsp provider does not support multiple subnets in combination with user data. Network: " + network + ", vlans: " + vlanVOs);
                         throw new UnsupportedServiceException("NuageVsp provider does not support multiple subnets in combination with user data.");
-                    }
-                }
             }
         }
     }
@@ -422,7 +468,7 @@ protected boolean canHandle(NetworkOffering offering, final NetworkType networkT
         if (networkType == NetworkType.Advanced
                 && isMyTrafficType(offering.getTrafficType())
                 && isMyIsolationMethod(physicalNetwork)
-                && (offering.getGuestType() == Network.GuestType.Isolated || offering.getGuestType() == Network.GuestType.Shared)
+                && (offering.getGuestType() == GuestType.Isolated || offering.getGuestType() == GuestType.Shared)
                 && hasRequiredServices(offering)) {
             if (_configMgr.isOfferingForVpc(offering) && !offering.getIsPersistent()) {
                 if (s_logger.isDebugEnabled()) {
@@ -578,11 +624,7 @@ private boolean getDefaultHasDns(Map<Long, Boolean> cache, Nic nic) {
                 ? Long.valueOf(nic.getNetworkId())
                 : getDefaultNetwork(nic.getInstanceId());
 
-        Boolean hasDns = cache.get(networkId);
-        if (hasDns == null) {
-            hasDns = networkHasDns(_networkDao.findById(networkId));
-            cache.put(networkId, hasDns);
-        }
+        Boolean hasDns = cache.computeIfAbsent(networkId, k -> networkHasDns(_networkDao.findById(networkId)));
         return hasDns;
     }
 
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/AbstractListener.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/AbstractListener.java
new file mode 100644
index 00000000000..648e0f781e5
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/AbstractListener.java
@@ -0,0 +1,91 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 com.cloud.network.manager;
+
+import com.cloud.agent.Listener;
+import com.cloud.agent.api.AgentControlAnswer;
+import com.cloud.agent.api.AgentControlCommand;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.exception.ConnectionException;
+import com.cloud.host.Host;
+import com.cloud.host.Status;
+
+/**
+ * Created by maximusf on 7/19/17.
+ */
+abstract class AbstractListener implements Listener {
+
+    @Override
+    public boolean processAnswers(long agentId, long seq, Answer[] answers) {
+        return true;
+    }
+
+    @Override
+    public boolean processCommands(long agentId, long seq, Command[] commands) {
+        return true;
+    }
+
+    @Override
+    public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
+        return null;
+    }
+
+    @Override
+    public void processHostAdded(long hostId) {
+
+    }
+
+    @Override
+    public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
+
+    }
+
+    @Override
+    public boolean processDisconnect(long agentId, Status state) {
+        return true;
+    }
+
+    @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+
+    }
+
+    @Override
+    public boolean isRecurring() {
+        return false;
+    }
+
+    @Override
+    public int getTimeout() {
+        return 0;
+    }
+
+    @Override
+    public boolean processTimeout(long agentId, long seq) {
+        return true;
+    }
+}
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManager.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManager.java
index 9f46012dab2..429b11d5967 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManager.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManager.java
@@ -36,21 +36,21 @@
 
 public interface NuageVspManager extends PluggableService {
 
-    static final String nuageVspSharedNetworkOfferingWithSGServiceName = "DefaultNuageVspSharedNetworkOfferingWithSGService";
+    String nuageVspSharedNetworkOfferingWithSGServiceName = "DefaultNuageVspSharedNetworkOfferingWithSGService";
 
-    static final String nuageVPCOfferingName = "Nuage VSP VPC Offering";
+    String nuageVPCOfferingName = "Nuage VSP VPC Offering";
 
-    static final String nuageVPCOfferingDisplayText = "Nuage VSP VPC Offering";
+    String nuageVPCOfferingDisplayText = "Nuage VSP VPC Offering";
 
-    static final String nuageDomainTemplateDetailName = "domainTemplateName";
+    String nuageDomainTemplateDetailName = "domainTemplateName";
 
-    static final String nuageUnderlayVlanIpRangeDetailKey = "nuage.underlay";
+    String nuageUnderlayVlanIpRangeDetailKey = "nuage.underlay";
 
-    static final ConfigKey<Boolean> NuageVspConfigDns = new ConfigKey<Boolean>(Boolean.class, "nuagevsp.configure.dns", "Advanced", "true",
+    ConfigKey<Boolean> NuageVspConfigDns = new ConfigKey<Boolean>(Boolean.class, "nuagevsp.configure.dns", "Advanced", "true",
             "Defines if NuageVsp plugin needs to configure DNS setting for a VM or not. True will configure the DNS and false will not configure the DNS settings", true,
             Scope.Global, null);
 
-    static final ConfigKey<Boolean> NuageVspDnsExternal = new ConfigKey<Boolean>(
+    ConfigKey<Boolean> NuageVspDnsExternal = new ConfigKey<Boolean>(
             Boolean.class,
             "nuagevsp.dns.external",
             "Advanced",
@@ -61,18 +61,24 @@
                     + "If nuagevsp.configure.dns is false, DNS server will not be configured in the VM. Default value for this flag is true",
             true, Scope.Global, null);
 
-    static final ConfigKey<String> NuageVspConfigGateway = new ConfigKey<String>(String.class, "nuagevsp.configure.gateway.systemid", "Advanced", "",
+    ConfigKey<String> NuageVspConfigGateway = new ConfigKey<String>(String.class, "nuagevsp.configure.gateway.systemid", "Advanced", "",
             "Defines the systemID of the gateway configured in VSP", true, Scope.Global, null);
 
-    static final ConfigKey<String> NuageVspSharedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.sharedntwk.domaintemplate.name",
+    ConfigKey<String> NuageVspSharedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.sharedntwk.domaintemplate.name",
             "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for shared networks", true, Scope.Global, null);
 
-    static final ConfigKey<String> NuageVspVpcDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.vpc.domaintemplate.name",
+    ConfigKey<String> NuageVspVpcDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.vpc.domaintemplate.name",
             "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for VPCs", true, Scope.Global, null);
 
-    static final ConfigKey<String> NuageVspIsolatedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.isolatedntwk.domaintemplate.name",
+    ConfigKey<String> NuageVspIsolatedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.isolatedntwk.domaintemplate.name",
             "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for isolated networks", true, Scope.Global, null);
 
+    String NETWORK_METADATA_VSD_DOMAIN_ID = "vsdDomainId";
+
+    String NETWORK_METADATA_VSD_ZONE_ID = "vsdZoneId";
+
+    String NETWORK_METADATA_VSD_SUBNET_ID = "vsdSubnetId";
+
     NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd);
 
     NuageVspDeviceVO updateNuageVspDevice(UpdateNuageVspDeviceCmd cmd);
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
index 7932555cc3d..fb79f09b911 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
@@ -19,17 +19,16 @@
 
 package com.cloud.network.manager;
 
-import static com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand.SyncType;
-
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.ExecutionException;
 
+import javax.annotation.Nonnull;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
@@ -41,17 +40,19 @@
 import net.nuage.vsp.acs.client.common.NuageVspApiVersion;
 import net.nuage.vsp.acs.client.common.NuageVspConstants;
 
+import net.nuage.vsp.acs.client.exception.NuageVspException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.Multimap;
 
 import org.apache.cloudstack.api.ResponseGenerator;
 import org.apache.cloudstack.framework.config.ConfigKey;
@@ -59,17 +60,13 @@
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
-import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
-import com.cloud.agent.api.AgentControlAnswer;
-import com.cloud.agent.api.AgentControlCommand;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.PingNuageVspCommand;
-import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.manager.CleanUpDomainCommand;
 import com.cloud.agent.api.manager.EntityExistsCommand;
 import com.cloud.agent.api.manager.GetApiDefaultsAnswer;
@@ -99,7 +96,6 @@
 import com.cloud.domain.Domain;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
-import com.cloud.exception.ConnectionException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.host.DetailVO;
 import com.cloud.host.Host;
@@ -153,11 +149,13 @@
 import com.cloud.utils.fsm.StateListener;
 import com.cloud.utils.fsm.StateMachine2;
 
+import static com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand.SyncType;
+
 public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager, Configurable, StateListener<Status, Status.Event, Host> {
 
     private static final Logger s_logger = Logger.getLogger(NuageVspManagerImpl.class);
 
-    public static final Map<Network.Service, Set<Network.Provider>> NUAGE_VSP_VPC_SERVICE_MAP;
+    public static final Multimap<Network.Service, Network.Provider> NUAGE_VSP_VPC_SERVICE_MAP;
     private static final ConfigKey[] NUAGE_VSP_CONFIG_KEYS = new ConfigKey<?>[] { NuageVspConfigDns, NuageVspDnsExternal, NuageVspConfigGateway,
             NuageVspSharedNetworkDomainTemplateName, NuageVspVpcDomainTemplateName, NuageVspIsolatedNetworkDomainTemplateName };
     public static final String CMSID_CONFIG_KEY = "nuagevsp.cms.id";
@@ -222,23 +220,32 @@
         Set<Network.Provider> nuageVspProviders = ImmutableSet.of(Network.Provider.NuageVsp);
         Set<Network.Provider> vrProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter);
         Set<Network.Provider> lbProviders = ImmutableSet.of(Network.Provider.InternalLbVm);
-        NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMap.<Network.Service, Set<Network.Provider>>builder()
-                .put(Network.Service.Connectivity, nuageVspProviders)
-                .put(Network.Service.Gateway, nuageVspProviders)
-                .put(Network.Service.Dhcp, nuageVspProviders)
-                .put(Network.Service.StaticNat, nuageVspProviders)
-                .put(Network.Service.SourceNat, nuageVspProviders)
-                .put(Network.Service.NetworkACL, nuageVspProviders)
-                .put(Network.Service.UserData, vrProviders)
-                .put(Network.Service.Lb, lbProviders)
-                .put(Network.Service.Dns, vrProviders)
+        NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMultimap.<Network.Service, Network.Provider>builder()
+                .putAll(Network.Service.Connectivity, nuageVspProviders)
+                .putAll(Network.Service.Gateway, nuageVspProviders)
+                .putAll(Network.Service.Dhcp, nuageVspProviders)
+                .putAll(Network.Service.StaticNat, nuageVspProviders)
+                .putAll(Network.Service.SourceNat, nuageVspProviders)
+                .putAll(Network.Service.NetworkACL, nuageVspProviders)
+                .putAll(Network.Service.UserData, vrProviders)
+                .putAll(Network.Service.Lb, lbProviders)
+                .putAll(Network.Service.Dns, vrProviders)
                 .build();
     }
 
+    private Listener _nuageVspResourceListener;
+
     @Override
     public List<Class<?>> getCommands() {
-        return Lists.<Class<?>>newArrayList(AddNuageVspDeviceCmd.class, DeleteNuageVspDeviceCmd.class, ListNuageVspDevicesCmd.class,
-                UpdateNuageVspDeviceCmd.class, EnableNuageUnderlayVlanIpRangeCmd.class, DisableNuageUnderlayVlanIpRangeCmd.class, ListNuageUnderlayVlanIpRangesCmd.class);
+        return Lists.<Class<?>>newArrayList(
+                AddNuageVspDeviceCmd.class,
+                DeleteNuageVspDeviceCmd.class,
+                ListNuageVspDevicesCmd.class,
+                UpdateNuageVspDeviceCmd.class,
+                EnableNuageUnderlayVlanIpRangeCmd.class,
+                DisableNuageUnderlayVlanIpRangeCmd.class,
+                ListNuageUnderlayVlanIpRangesCmd.class
+        );
     }
 
     @Override
@@ -298,19 +305,15 @@ public NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd) {
                 }
                 apiVersion = cmd.getApiVersion();
             } else {
-                boolean apiVersionFound = false;
-                Map<NuageVspApiVersion, NuageVspApiVersion.Status> supportedVersions = clientLoader.getNuageVspManagerClient().getSupportedVersions();
-                for (NuageVspApiVersion selectedVersion : supportedVersions.keySet()) {
-                    if (supportedVersions.get(selectedVersion) == NuageVspApiVersion.Status.CURRENT){
-                        apiVersion = selectedVersion.toString();
-                        apiVersionFound = true;
-                        break;
-                    }
-                }
+                List<NuageVspApiVersion> supportedVsdVersions = clientLoader.getNuageVspManagerClient().getSupportedVersionList();
+                supportedVsdVersions.retainAll(Arrays.asList(NuageVspApiVersion.SUPPORTED_VERSIONS));
 
-                if(!apiVersionFound) {
+                if(supportedVsdVersions.isEmpty()) {
                     throw new CloudRuntimeException("No supported API version found!");
                 }
+
+                supportedVsdVersions.sort(Comparator.reverseOrder());
+                apiVersion = supportedVsdVersions.get(0).toString();
             }
 
 
@@ -365,7 +368,7 @@ public NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd) {
         } catch (ConfigurationException e) {
             s_logger.error("Failed to configure Nuage VSD resource " + cmd.getHostName(), e);
             throw new CloudRuntimeException("Failed to configure Nuage VSD resource " + cmd.getHostName(), e);
-        } catch (ExecutionException ee) {
+        } catch (NuageVspException ee) {
             s_logger.error("Failed to add Nuage VSP device " + cmd.getHostName(), ee);
             throw new CloudRuntimeException("Failed to add Nuage VSP device " + cmd.getHostName(), ee);
         }
@@ -677,7 +680,12 @@ public boolean executeSyncCmsId(NuageVspDeviceVO nuageVspDevice, SyncType syncTy
         return answer != null && answer.getSuccess();
     }
 
-    private void auditHost(HostVO host) {
+    void auditHost(long hostId) {
+        Host host = _hostDao.findById(hostId);
+        auditHost((HostVO)host);
+    }
+
+    void auditHost(HostVO host) {
         if (host == null) return;
 
         _hostDao.loadDetails(host);
@@ -897,124 +905,66 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
     @DB
     private void initMessageBusListeners() {
         // Create corresponding enterprise and profile in VSP when creating a CS Domain
-        _messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, new MessageSubscriber() {
-            @Override
-            public void onPublishMessage(String senderAddress, String subject, Object args) {
-                Long domainId = (Long) args;
-                Domain domain = _domainDao.findById(domainId);
-
-                try {
-                    _domainDao.acquireInLockTable(domain.getId());
-
-                    List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
-                    for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
-                        VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
-                        SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.ADD);
-                        _agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
-                    }
-                } finally {
-                    _domainDao.releaseFromLockTable(domain.getId());
-                }
-            }
-        });
+        _messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, (senderAddress, subject, args) -> {
+            Long domainId = (Long) args;
+            Domain domain = _domainDao.findById(domainId);
+
+            try {
+                _domainDao.acquireInLockTable(domain.getId());
 
-        // Clean up corresponding resources in VSP when deleting a CS Domain
-        _messageBus.subscribe(DomainManager.MESSAGE_PRE_REMOVE_DOMAIN_EVENT, new MessageSubscriber() {
-            @Override
-            public void onPublishMessage(String senderAddress, String subject, Object args) {
-                DomainVO domain = (DomainVO) args;
                 List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
                 for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
-                    VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain);
-                    CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp);
+                    VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
+                    SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.ADD);
                     _agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
                 }
+            } finally {
+                _domainDao.releaseFromLockTable(domain.getId());
             }
         });
 
-        // Delete corresponding enterprise and profile in VSP when deleting a CS Domain
-        _messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, new MessageSubscriber() {
-            @Override
-            public void onPublishMessage(String senderAddress, String subject, Object args) {
-                DomainVO domain = (DomainVO) args;
-                List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
-                for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
-                    VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
-                    SyncDomainCommand syncCmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.REMOVE);
-                    _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd);
-                }
+        // Clean up corresponding resources in VSP when deleting a CS Domain
+        _messageBus.subscribe(DomainManager.MESSAGE_PRE_REMOVE_DOMAIN_EVENT, (senderAddress, subject, args) -> {
+            DomainVO domain = (DomainVO) args;
+            List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
+            for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
+                VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain);
+                CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp);
+                _agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
             }
         });
-    }
 
-    @DB
-    private void initNuageVspResourceListeners() {
-        _agentMgr.registerForHostEvents(new Listener() {
-            @Override
-            public boolean processAnswers(long agentId, long seq, Answer[] answers) {
-                return true;
+        // Delete corresponding enterprise and profile in VSP when deleting a CS Domain
+        _messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, (senderAddress, subject, args) -> {
+            DomainVO domain = (DomainVO) args;
+            List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
+            for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
+                VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
+                SyncDomainCommand syncCmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.REMOVE);
+                _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd);
             }
+        });
+    }
 
-            @Override
-            public boolean processCommands(long agentId, long seq, Command[] commands) {
-                if (commands != null && commands.length == 1) {
-                    Command command = commands[0];
-                    if (command instanceof PingNuageVspCommand) {
-                        PingNuageVspCommand pingNuageVspCommand = (PingNuageVspCommand) command;
-                        if (pingNuageVspCommand.shouldAudit()) {
-                            Host host = _hostDao.findById(pingNuageVspCommand.getHostId());
-                            auditHost((HostVO) host);
-                        }
+    private class NuageVspResourceListener extends AbstractListener {
+        @Override
+        public boolean processCommands(long agentId, long seq, Command[] commands) {
+            if (commands != null && commands.length == 1) {
+                Command command = commands[0];
+                if (command instanceof PingNuageVspCommand) {
+                    PingNuageVspCommand pingNuageVspCommand = (PingNuageVspCommand)command;
+                    if (pingNuageVspCommand.shouldAudit()) {
+                        auditHost(pingNuageVspCommand.getHostId());
                     }
                 }
-                return true;
-            }
-
-            @Override
-            public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
-                return null;
-            }
-
-            @Override
-            public void processHostAdded(long hostId) {
-
-            }
-
-            @Override
-            public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
-
-            }
-
-            @Override
-            public boolean processDisconnect(long agentId, Status state) {
-                return true;
-            }
-
-            @Override
-            public void processHostAboutToBeRemoved(long hostId) {
-
-            }
-
-            @Override
-            public void processHostRemoved(long hostId, long clusterId) {
-
-            }
-
-            @Override
-            public boolean isRecurring() {
-                return false;
-            }
-
-            @Override
-            public int getTimeout() {
-                return 0;
             }
+            return true;
+        }
+    }
 
-            @Override
-            public boolean processTimeout(long agentId, long seq) {
-                return true;
-            }
-        }, false, true, false);
+    @DB
+    private void initNuageVspResourceListeners() {
+        _agentMgr.registerForHostEvents(new NuageVspResourceListener(), false, true, false);
     }
 
     @DB
@@ -1070,79 +1020,74 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
     }
 
     @DB
-    protected VpcOffering createVpcOffering(final String name, final String displayText, final Map<Network.Service, Set<Network.Provider>> svcProviderMap, final boolean isDefault,
+    protected VpcOffering createVpcOffering(final String name, final String displayText, final Multimap<Network.Service, Network.Provider> svcProviderMap, final boolean isDefault,
                                             final VpcOffering.State state, final Long serviceOfferingId) {
-        return Transaction.execute(new TransactionCallback<VpcOffering>() {
-            @Override
-            public VpcOffering doInTransaction(TransactionStatus status) {
-                // create vpc offering object
-                VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, false, false);
+        return Transaction.execute((TransactionCallback<VpcOffering>)status -> createVpcOfferingInTransaction(name, displayText, svcProviderMap, isDefault, state, serviceOfferingId));
+    }
 
-                if (state != null) {
-                    offering.setState(state);
-                }
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(String.format("Adding vpc offering %s", offering));
-                }
-                offering = _vpcOffDao.persist(offering);
-                // populate services and providers
-                if (svcProviderMap != null) {
-                    for (Network.Service service : svcProviderMap.keySet()) {
-                        Set<Network.Provider> providers = svcProviderMap.get(service);
-                        if (providers != null && !providers.isEmpty()) {
-                            for (Network.Provider provider : providers) {
-                                VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
-                                _vpcOffSvcMapDao.persist(offService);
-                                if (s_logger.isTraceEnabled()) {
-                                    s_logger.trace(String.format("Added service for the vpc offering: %s with provider %s", offService, provider.getName()));
-                                }
-                            }
-                        } else {
-                            throw new InvalidParameterValueException(String.format("Provider is missing for the VPC offering service %s", service.getName()));
-                        }
-                    }
+    private VpcOffering createVpcOfferingInTransaction(String name, String displayText, Multimap<Network.Service, Network.Provider> svcProviderMap, boolean isDefault,
+            VpcOffering.State state, Long serviceOfferingId) {
+        // create vpc offering object
+        VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, false, false);
+
+        if (state != null) {
+            offering.setState(state);
+        }
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug(String.format("Adding vpc offering %s", offering));
+        }
+        offering = _vpcOffDao.persist(offering);
+        // populate services and providers
+        if (svcProviderMap != null) {
+            for (Map.Entry<Network.Service, Network.Provider> entry : svcProviderMap.entries()) {
+                Network.Service service = entry.getKey();
+                Network.Provider provider = entry.getValue();
+
+                VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
+                _vpcOffSvcMapDao.persist(offService);
+                if (s_logger.isTraceEnabled()) {
+                    s_logger.trace(String.format("Added service for the vpc offering: %s with provider %s", offService, provider.getName()));
                 }
-                return offering;
             }
-        });
+        }
+
+        return offering;
     }
 
     @DB
-    protected void updateVpcOffering(final VpcOffering offering, final Map<Network.Service, Set<Network.Provider>> svcProviderMap) {
-        Transaction.execute(new TransactionCallback<VpcOffering>() {
-            @Override
-            public VpcOffering doInTransaction(TransactionStatus status) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(String.format("Updating vpc offering %s", offering));
-                }
+    protected void updateVpcOffering(final VpcOffering offering, final Multimap<Network.Service, Network.Provider> svcProviderMap) {
+        Transaction.execute((TransactionCallback<VpcOffering>)status -> updateVpcOfferingInTransaction(offering, svcProviderMap));
+    }
 
-                List<VpcOfferingServiceMapVO> currentVpcOfferingServices = _vpcOffSvcMapDao.listByVpcOffId(offering.getId());
-                Map<Network.Service, Set<Network.Provider>> currentSvcProviderMap = Maps.newHashMap();
-                for (VpcOfferingServiceMapVO vpcOfferingService : currentVpcOfferingServices) {
-                    Network.Service service = Network.Service.getService(vpcOfferingService.getService());
-                    Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
+    @Nonnull
+    private VpcOffering updateVpcOfferingInTransaction(VpcOffering offering, Multimap<Network.Service, Network.Provider> svcProviderMap) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug(String.format("Updating vpc offering %s", offering));
+        }
 
-                    if (!currentSvcProviderMap.containsKey(service)) {
-                        currentSvcProviderMap.put(service, Sets.newHashSet(provider));
-                    } else if (!currentSvcProviderMap.get(service).contains(provider)) {
-                        currentSvcProviderMap.get(service).add(provider);
-                    }
-                }
+        List<VpcOfferingServiceMapVO> currentVpcOfferingServices = _vpcOffSvcMapDao.listByVpcOffId(offering.getId());
+        Multimap<Network.Service, Network.Provider> currentSvcProviderMap = HashMultimap.create();
+        for (VpcOfferingServiceMapVO vpcOfferingService : currentVpcOfferingServices) {
+            Network.Service service = Network.Service.getService(vpcOfferingService.getService());
+            Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
+            currentSvcProviderMap.put(service, provider);
+        }
 
-                for (Network.Service service : svcProviderMap.keySet()) {
-                    for (Network.Provider provider : svcProviderMap.get(service)) {
-                        if (currentSvcProviderMap.get(service) == null || !currentSvcProviderMap.get(service).contains(provider)) {
-                            VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
-                            _vpcOffSvcMapDao.persist(offService);
-                            if (s_logger.isDebugEnabled()) {
-                                s_logger.debug(String.format("Added service for the vpc offering: %s", offService));
-                            }
-                        }
-                    }
+        for (Map.Entry<Network.Service, Network.Provider> entry : svcProviderMap.entries()) {
+            Network.Service service = entry.getKey();
+            Network.Provider provider = entry.getValue();
+
+            if (!currentSvcProviderMap.containsEntry(service, provider)) {
+                VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
+                _vpcOffSvcMapDao.persist(offService);
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug(String.format("Added service for the vpc offering: %s", offService));
                 }
-                return offering;
             }
-        });
+
+        }
+
+        return offering;
     }
 
     private HostVO findNuageVspHost(long hostId) {
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
index 5ffe683e500..72ff5b016b4 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
@@ -20,7 +20,8 @@
 package com.cloud.network.resource;
 
 import java.util.Map;
-import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
 
 import javax.naming.ConfigurationException;
 
@@ -31,6 +32,8 @@
 import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
 import net.nuage.vsp.acs.client.api.NuageVspPluginClientLoader;
 import net.nuage.vsp.acs.client.api.model.VspHost;
+import net.nuage.vsp.acs.client.common.RequestType;
+import net.nuage.vsp.acs.client.common.model.NuageVspEntity;
 import net.nuage.vsp.acs.client.exception.NuageVspException;
 
 import org.apache.log4j.Logger;
@@ -48,8 +51,9 @@
 import com.cloud.resource.ServerResource;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.mgmt.JmxUtil;
 
-public class NuageVspResource extends ManagerBase implements ServerResource {
+public class NuageVspResource extends ManagerBase implements ServerResource, VspStatisticsMBean {
     private static final Logger s_logger = Logger.getLogger(NuageVspResource.class);
 
     private String _guid;
@@ -73,7 +77,7 @@ public VspHost validate(NuageVspResourceConfiguration configuration) throws Conf
 
 
         if (!newVspHost.getApiVersion().isSupported()) {
-            s_logger.warn(String.format("[UPGRADE] API version %s of Nuage Vsp Device %s should be updated.", _vspHost.getApiVersion(), configuration.hostName()));
+            s_logger.warn(String.format("[UPGRADE] API version %s of Nuage Vsp Device %s should be updated.", newVspHost.getApiVersion(), configuration.hostName()));
         }
 
         _guid = configuration.guid();
@@ -87,7 +91,7 @@ public VspHost validate(NuageVspResourceConfiguration configuration) throws Conf
 
             _vspHost = newVspHost;
             _clientLoader = clientLoader;
-        } catch (ExecutionException e) {
+        } catch (NuageVspException e) {
             s_logger.error(e.getMessage(), e);
             throw new CloudRuntimeException(e.getMessage(), e);
         }
@@ -96,6 +100,64 @@ public VspHost validate(NuageVspResourceConfiguration configuration) throws Conf
     }
 
     @Override
+    public long getVSDStatistics() {
+        return _clientLoader.getNuageVspStatistics().getVsdCount();
+    }
+
+
+    @Override
+    public long getVsdStatisticsByEntityType(String entity) {
+        try {
+            NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity);
+            return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity);
+        } catch (IllegalArgumentException e) {
+            return -1;
+        }
+    }
+
+    @Override
+    public long getVsdStatisticsByRequestType(String requestType) {
+        try {
+            RequestType requestTypeValue = RequestType.valueOf(requestType);
+            return _clientLoader.getNuageVspStatistics().getVsdCount(requestTypeValue);
+        } catch (IllegalArgumentException e) {
+            return -1;
+        }
+
+    }
+
+    @Override
+    public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) {
+        try {
+            RequestType requestTypeValue = RequestType.valueOf(requestType);
+            NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity);
+            return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity, requestTypeValue);
+        } catch (IllegalArgumentException e) {
+            return -1;
+        }
+    }
+
+    private static Map<String, AtomicLong> convertHashMap(Map<RequestType, AtomicLong> map) {
+        return map.entrySet()
+                .stream()
+                .collect(Collectors.toMap(
+                        e -> e.getKey().toString(),
+                        Map.Entry::getValue)
+                );
+    }
+
+    @Override
+    public Map<String, Map<String, AtomicLong>> getVsdStatisticsReport() {
+       return _clientLoader.getNuageVspStatistics()
+                .getVsdCountReport()
+                .entrySet().stream()
+                .collect(Collectors.toMap(
+                        e -> e.getKey().toString(),
+                        e -> convertHashMap(e.getValue())
+                ));
+    }
+
+    @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         if(super.configure(name, params)) {
             validate(params);
@@ -113,11 +175,25 @@ protected NuageVspPluginClientLoader getClientLoader(VspHost vspHost) {
 
     @Override
     public boolean start() {
+        try {
+            JmxUtil.registerMBean("NuageVspResource", _name, new VspStatisticsMBeanImpl(this));
+        } catch (Exception e) {
+            s_logger.warn("Unable to initialize statistics Mbean", e);
+        }
+
         return true;
+
     }
 
     @Override
     public boolean stop() {
+
+        try {
+            JmxUtil.unregisterMBean("NuageVspResource", _name);
+        } catch (Exception e) {
+            s_logger.warn("Unable to initialize inaccurate clock", e);
+        }
+
         return true;
     }
 
@@ -155,7 +231,7 @@ public PingCommand getCurrentStatus(long id) {
 
         try {
             login();
-        } catch (ExecutionException | ConfigurationException e) {
+        } catch (NuageVspException | ConfigurationException e) {
             s_logger.error("Failed to ping to Nuage VSD on " + _name + " as user " +_vspHost.getCmsUserLogin(), e);
             _shouldAudit = true;
             return null;
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResourceConfiguration.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResourceConfiguration.java
index 1861941179c..71d7390a668 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResourceConfiguration.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResourceConfiguration.java
@@ -25,7 +25,6 @@
 
 import javax.naming.ConfigurationException;
 
-import com.google.common.base.Preconditions;
 import net.nuage.vsp.acs.client.api.model.NuageVspUser;
 import net.nuage.vsp.acs.client.api.model.VspHost;
 import net.nuage.vsp.acs.client.common.NuageVspApiVersion;
@@ -34,6 +33,8 @@
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.lang.builder.ToStringBuilder;
 
+import com.google.common.base.Preconditions;
+
 import com.cloud.util.NuageVspUtil;
 
 public class NuageVspResourceConfiguration {
@@ -265,7 +266,7 @@ public void validate() throws ConfigurationException {
         verifyNotEmpty("API version", _apiVersion);
 
         try {
-                new NuageVspApiVersion(_apiVersion);
+            NuageVspApiVersion.fromString(_apiVersion);
         } catch(IllegalArgumentException e) {
             throw new ConfigurationException("Incorrect API version");
         }
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBean.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBean.java
new file mode 100644
index 00000000000..55072ec6650
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBean.java
@@ -0,0 +1,66 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 com.cloud.network.resource;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import com.cloud.utils.mgmt.ManagementBean;
+
+/**
+ * Created by sgoeminn on 1/24/17.
+ */
+public interface VspStatisticsMBean extends ManagementBean {
+
+    /**
+     * Returns the global count of all the VSD calls since start up
+     * @return
+     */
+    long getVSDStatistics();
+
+    /**
+     * Returns the count of all the vsd calls where the entityType is equal to the entity
+     * @param entity
+     * @return
+     */
+    long getVsdStatisticsByEntityType(String entity);
+
+    /**
+     * Returns the count of all the vsd calls where the requestType is equal to the requestType
+     * @param requestType
+     * @return
+     */
+    long getVsdStatisticsByRequestType(String requestType);
+
+    /**
+     * Returns the count of all the vsd calls where the EntityType is equal to the entity
+     * and the RequestType is equal to the requestType string.
+     * @param entity
+     * @param requestType
+     * @return
+     */
+    long getVsdStatisticsByEntityAndRequestType(String entity, String requestType);
+
+    /**
+     * Returns the count of all VSD calls with EntityType entity and RequestType type
+     * @return
+     */
+    Map<String, Map<String, AtomicLong>> getVsdStatisticsReport();
+}
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBeanImpl.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBeanImpl.java
new file mode 100644
index 00000000000..7e3de561db1
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/VspStatisticsMBeanImpl.java
@@ -0,0 +1,66 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 com.cloud.network.resource;
+
+import javax.management.StandardMBean;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Created by sgoeminn on 1/24/17.
+ */
+public class VspStatisticsMBeanImpl extends StandardMBean implements VspStatisticsMBean{
+   private VspStatisticsMBean _delegate;
+
+    public VspStatisticsMBeanImpl(VspStatisticsMBean nuageVspResource) {
+        super(VspStatisticsMBean.class, false);
+        _delegate = nuageVspResource;
+    }
+
+    @Override
+    public long getVSDStatistics() {
+        return _delegate.getVSDStatistics();
+    }
+
+    @Override
+    public long getVsdStatisticsByEntityType(String entity) {
+        return _delegate.getVsdStatisticsByEntityType(entity);
+    }
+
+    @Override
+    public long getVsdStatisticsByRequestType(String requestType) {
+        return _delegate.getVsdStatisticsByRequestType(requestType);
+    }
+
+    @Override
+    public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) {
+        return _delegate.getVsdStatisticsByEntityAndRequestType(entity, requestType);
+    }
+
+    @Override
+    public Map<String, Map<String, AtomicLong>> getVsdStatisticsReport() {
+        return _delegate.getVsdStatisticsReport();
+    }
+
+    @Override
+    public String getName() {
+        return _delegate.getName();
+    }
+}
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java
index 1ba77ff2bd0..1e57e244e65 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java
@@ -21,22 +21,27 @@
 
 import javax.naming.ConfigurationException;
 
+import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
 import net.nuage.vsp.acs.client.exception.NuageVspException;
 
 import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
+import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
 import com.cloud.network.resource.NuageVspResource;
+import com.cloud.resource.CommandWrapper;
 import com.cloud.resource.ResourceWrapper;
 
 @ResourceWrapper(handles =  ImplementNetworkVspCommand.class)
-public final class NuageVspGuruImplementNetworkCommandWrapper extends NuageVspCommandWrapper<ImplementNetworkVspCommand> {
-
-    @Override public boolean executeNuageVspCommand(ImplementNetworkVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
-        nuageVspResource.getNuageVspGuruClient().implement(cmd.getNetwork(), cmd.getDhcpOption());
-        return true;
-    }
-
-    @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ImplementNetworkVspCommand command) {
-        return stringBuilder.append("Created network mapping to ").append(command.getNetwork().getName());
+public final class NuageVspGuruImplementNetworkCommandWrapper extends CommandWrapper<ImplementNetworkVspCommand, ImplementNetworkVspAnswer, NuageVspResource> {
+
+    @Override
+    public ImplementNetworkVspAnswer execute(ImplementNetworkVspCommand command, NuageVspResource serverResource) {
+        try {
+            NuageVspGuruClient client = serverResource.getNuageVspGuruClient();
+            NetworkRelatedVsdIds networkRelatedVsdIds = client.implement(command.getNetwork(), command.getDhcpOption());
+            return new ImplementNetworkVspAnswer(command, networkRelatedVsdIds);
+        } catch (ConfigurationException | NuageVspException e) {
+            return new ImplementNetworkVspAnswer(command, e);
+        }
     }
-
 }
\ No newline at end of file
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
index 4e6ccb3e64e..9b0e0d93213 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
@@ -25,14 +25,32 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.stream.Collectors;
 
-import javax.annotation.Nullable;
 import javax.inject.Inject;
 
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
+import net.nuage.vsp.acs.client.api.model.VspAclRule;
+import net.nuage.vsp.acs.client.api.model.VspAddressRange;
+import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
+import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
+import net.nuage.vsp.acs.client.api.model.VspDomain;
+import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp;
+import net.nuage.vsp.acs.client.api.model.VspNetwork;
+import net.nuage.vsp.acs.client.api.model.VspNic;
+import net.nuage.vsp.acs.client.api.model.VspStaticNat;
+import net.nuage.vsp.acs.client.api.model.VspVm;
+import net.nuage.vsp.acs.client.common.model.Pair;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
 import com.cloud.dc.Vlan;
 import com.cloud.dc.VlanVO;
 import com.cloud.dc.dao.VlanDao;
@@ -65,24 +83,12 @@
 import com.cloud.vm.NicVO;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.NicSecondaryIpDao;
+import com.cloud.vm.dao.NicSecondaryIpVO;
 import com.cloud.vm.dao.VMInstanceDao;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import net.nuage.vsp.acs.client.api.model.VspAclRule;
-import net.nuage.vsp.acs.client.api.model.VspAddressRange;
-import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
-import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
-import net.nuage.vsp.acs.client.api.model.VspDomain;
-import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp;
-import net.nuage.vsp.acs.client.api.model.VspNetwork;
-import net.nuage.vsp.acs.client.api.model.VspNic;
-import net.nuage.vsp.acs.client.api.model.VspStaticNat;
-import net.nuage.vsp.acs.client.api.model.VspVm;
-import net.nuage.vsp.acs.client.common.model.Pair;
+import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
+import org.apache.commons.collections.MapUtils;
 
 public class NuageVspEntityBuilder {
     private static final Logger s_logger = Logger.getLogger(NuageVspEntityBuilder.class);
@@ -112,10 +118,16 @@
     @Inject
     NetworkDetailsDao _networkDetailsDao;
     @Inject
+    VpcDetailsDao _vpcDetailsDao;
+    @Inject
     VMInstanceDao _vmInstanceDao;
     @Inject
     NuageVspManager _nuageVspManager;
     @Inject
+    NicDao _nicDao;
+    @Inject
+    NicSecondaryIpDao _nicSecondaryIpDao;
+    @Inject
     NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
 
 
@@ -151,6 +163,7 @@ public VspNetwork buildVspNetwork(Network network) {
         return buildVspNetwork(network.getDomainId(), network);
     }
 
+    //TODO:Sigert implement caching in this function. retrieve data
     public VspNetwork buildVspNetwork(long domainId, Network network) {
         VspNetwork.Builder vspNetworkBuilder = new VspNetwork.Builder()
                 .id(network.getId())
@@ -171,31 +184,60 @@ public VspNetwork buildVspNetwork(long domainId, Network network) {
         NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
         vspNetworkBuilder.egressDefaultPolicy(networkOffering.getEgressDefaultPolicy()).publicAccess(networkOffering.getSupportsPublicAccess());
 
+        Map<String, String> networkDetails = _networkDetailsDao.listDetailsKeyPairs(network.getId(), false);
+        String vsdSubnetId = null;
+        String vsdZoneId = null;
+        String vsdDomainId = null;
+
+        if (MapUtils.isNotEmpty(networkDetails)) {
+            vsdSubnetId = networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID);
+        }
+
         if (network.getVpcId() != null) {
-            VpcVO vpc = _vpcDao.findById(network.getVpcId());
+            long vpcId = network.getVpcId();
+            VpcVO vpc = _vpcDao.findById(vpcId);
             vspNetworkBuilder.vpcUuid(vpc.getUuid())
                     .vpcName(vpc.getName())
                     .networkType(VspNetwork.NetworkType.Vpc);
+            Map<String, String> vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpcId, false);
+            if (MapUtils.isNotEmpty(vpcDetails)) {
+                vsdDomainId = vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID);
+                vsdZoneId = vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID);
+            }
+
         } else {
+            if (MapUtils.isNotEmpty(networkDetails)) {
+                vsdDomainId = networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID);
+                vsdZoneId = networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID);
+            }
+
             if (networkOffering.getGuestType() == Network.GuestType.Shared) {
                 List<VlanVO> vlans = _vlanDao.listVlansByNetworkIdIncludingRemoved(network.getId());
-                List<VspAddressRange> vspAddressRanges = Lists.transform(vlans, new Function<VlanVO, VspAddressRange>() {
-                    @Nullable
-                    @Override
-                    public VspAddressRange apply(VlanVO vlanVO) {
-                        return new VspAddressRange.Builder().gateway(vlanVO.getVlanGateway()).netmask(vlanVO.getVlanNetmask()).build();
-                    }
-                });
-
-                vspNetworkBuilder.networkType(VspNetwork.NetworkType.Shared).addressRanges(vspAddressRanges);
+
+                List<VspAddressRange> vspAddressRanges =
+                        vlans.stream()
+                             .map(vlan -> new VspAddressRange.Builder().gateway(vlan.getVlanGateway()).netmask(vlan.getVlanNetmask()).build())
+                             .collect(Collectors.toList());
+
+
+                vspNetworkBuilder.networkType(VspNetwork.NetworkType.Shared)
+                                 .addressRanges(vspAddressRanges);
             } else if (_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.SourceNat)
                     || _networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.StaticNat)) {
                 vspNetworkBuilder.networkType(VspNetwork.NetworkType.L3);
             } else {
                 vspNetworkBuilder.networkType(VspNetwork.NetworkType.L2);
             }
+
         }
 
+        NetworkRelatedVsdIds networkRelatedVsdIds = new NetworkRelatedVsdIds.Builder()
+                                                          .vsdDomainId(vsdDomainId)
+                                                          .vsdSubnetId(vsdSubnetId)
+                                                          .vsdZoneId(vsdZoneId)
+                                                          .build();
+        vspNetworkBuilder.networkRelatedVsdIds(networkRelatedVsdIds);
+
         boolean firewallServiceSupported = _networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.Firewall);
         vspNetworkBuilder.firewallServiceSupported(firewallServiceSupported);
 
@@ -225,15 +267,10 @@ public boolean usesVirtualRouter(long networkOfferingId) {
     public VspNetwork updateVspNetworkByPublicIp(VspNetwork vspNetwork, Network network, String publicIp) {
         List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(network.getId());
         final long ip = NetUtils.ip2Long(publicIp);
-        VlanVO matchingVlan = Iterables.find(vlans, new Predicate<VlanVO>() {
-            @Override
-            public boolean apply(@Nullable VlanVO vlan) {
-                Pair<String, String> ipAddressRange = getIpAddressRange(vlan);
-                long startIp = NetUtils.ip2Long(ipAddressRange.getLeft());
-                long endIp = NetUtils.ip2Long(ipAddressRange.getRight());
-                return startIp <= ip && ip <= endIp;
-            }
-        });
+        VlanVO matchingVlan = vlans.stream()
+                                   .filter(vlan -> isVlanContainingIp(vlan, ip))
+                                   .findFirst()
+                                   .get();
 
         return new VspNetwork.Builder().fromObject(vspNetwork)
                 .gateway(matchingVlan.getVlanGateway())
@@ -241,6 +278,13 @@ public boolean apply(@Nullable VlanVO vlan) {
                 .build();
     }
 
+    private boolean isVlanContainingIp(Vlan vlan, long ip) {
+        Pair<String, String> ipAddressRange = getIpAddressRange(vlan);
+        long startIp = NetUtils.ip2Long(ipAddressRange.getLeft());
+        long endIp = NetUtils.ip2Long(ipAddressRange.getRight());
+        return startIp <= ip && ip <= endIp;
+    }
+
     private List<Pair<String, String>> getSharedIpAddressRanges(long networkId) {
         List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
         List<Pair<String, String>> ipAddressRanges = Lists.newArrayList();
@@ -326,30 +370,8 @@ private String getVirtualRouterIP(Network network, List<Pair<String, String>> ip
     public VspVm buildVspVm(VirtualMachine vm, Network network) {
         VspVm.Builder vspVmBuilder = new VspVm.Builder()
                 .uuid(vm.getUuid())
-                .name(vm.getInstanceName());
-
-        switch (vm.getState()) {
-            case Starting:
-                vspVmBuilder.state(VspVm.State.Starting); break;
-            case Running:
-                vspVmBuilder.state(VspVm.State.Running); break;
-            case Stopping:
-                vspVmBuilder.state(VspVm.State.Stopping); break;
-            case Stopped:
-                vspVmBuilder.state(VspVm.State.Stopped); break;
-            case Destroyed:
-                vspVmBuilder.state(VspVm.State.Destroyed); break;
-            case Expunging:
-                vspVmBuilder.state(VspVm.State.Expunging); break;
-            case Migrating:
-                vspVmBuilder.state(VspVm.State.Migrating); break;
-            case Error:
-                vspVmBuilder.state(VspVm.State.Error); break;
-            case Shutdowned:
-                vspVmBuilder.state(VspVm.State.Shutdowned); break;
-            default:
-                vspVmBuilder.state(VspVm.State.Unknown);
-        }
+                .name(vm.getInstanceName())
+                .state(getEnumValue(vm.getState(), VspVm.State.Unknown));
 
         boolean isDomainRouter = vm.getType().equals(VirtualMachine.Type.DomainRouter);
         vspVmBuilder.domainRouter(isDomainRouter);
@@ -363,20 +385,28 @@ public VspVm buildVspVm(VirtualMachine vm, Network network) {
     }
 
     public VspNic buildVspNic(String nicUuid, NicProfile nicProfile) {
-        return buildVspNic(nicUuid, nicProfile.getMacAddress(), nicProfile.getIPv4Address(), nicProfile.getNetworkId());
+        return buildVspNic(nicUuid, nicProfile.getMacAddress(), nicProfile.getIPv4Address(), nicProfile.getNetworkId(), null);
     }
 
     public VspNic buildVspNic(NicVO nic) {
-        return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId());
+        return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), null);
+    }
+
+    public VspNic buildVspNic(NicVO nic, NicSecondaryIpVO nicSecondaryIp) {
+        return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), nicSecondaryIp);
     }
 
-    private VspNic buildVspNic(String uuid, String macAddress, String ip, long networkId) {
+    private VspNic buildVspNic(String uuid, String macAddress, String ip, long networkId, NicSecondaryIpVO nicSecondaryIp) {
         VspNic.Builder vspNicBuilder = new VspNic.Builder()
                 .uuid(uuid)
                 .macAddress(macAddress)
                 .useStaticIp(true)
                 .ip(ip);
 
+        if (nicSecondaryIp != null) {
+            vspNicBuilder.secondaryIpUuid(nicSecondaryIp.getUuid()).secondaryIpAddress(nicSecondaryIp.getIp4Address());
+        }
+
         Network network = _networkDao.findById(networkId);
         NetworkOffering networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
 
@@ -395,6 +425,10 @@ public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp
                 .vlanNetmask(staticNatVlan.getVlanNetmask())
                 .vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan));
 
+        if (staticNatIp.getVmIp() != null) {
+            vspStaticNatBuilder.destinationIp(staticNatIp.getVmIp() + "/32");
+        }
+
         if (vspNic != null) {
             vspStaticNatBuilder.nic(vspNic);
         }
@@ -403,11 +437,24 @@ public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp
     }
 
     public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, NicVO nic) {
-        VspNic vspNic = (nic != null) ?buildVspNic(nic) : null;
+        NicSecondaryIpVO nicSecondaryIp = null;
+
+        if (nic == null && staticNatIp.getAssociatedWithVmId() != null && staticNatIp.getVmIp() != null) {
+            nicSecondaryIp = _nicSecondaryIpDao.findByIp4AddressAndInstanceId(staticNatIp.getAssociatedWithVmId(), staticNatIp.getVmIp());
+            if (nicSecondaryIp != null) {
+                nic = _nicDao.findById(nicSecondaryIp.getNicId());
+            }
+        }
+
+        VspNic vspNic = (nic != null) ? buildVspNic(nic, nicSecondaryIp) : null;
         return buildVspStaticNat(forRevoke, staticNatIp, staticNatVlan, vspNic);
     }
 
     public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
+        return buildVspAclRule(firewallRule, network, null);
+    }
+
+    public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network, IPAddressVO staticNat) {
         VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder()
                 .uuid(firewallRule.getUuid())
                 .protocol(firewallRule.getProtocol())
@@ -415,35 +462,25 @@ public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
                 .endPort(firewallRule.getSourcePortEnd())
                 .sourceCidrList(firewallRule.getSourceCidrList())
                 .priority(-1)
-                .type(VspAclRule.ACLType.Firewall);
-
-        switch (firewallRule.getState()) {
-            case Active:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Active); break;
-            case Add:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Add); break;
-            case Revoke:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Revoke);
-        }
-
-        switch (firewallRule.getTrafficType()) {
-            case Ingress:
-                vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Ingress); break;
-            case Egress:
-                vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Egress);
-        }
+                .type(VspAclRule.ACLType.Firewall)
+                .state(getEnumValue(firewallRule.getState(), VspAclRule.ACLState.class))
+                .trafficType(getEnumValue(firewallRule.getTrafficType(), VspAclRule.ACLTrafficType.class));
 
         NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
         if (firewallRule.getTrafficType() == FirewallRule.TrafficType.Egress && networkOffering.getEgressDefaultPolicy()) {
-            vspAclRuleBuilder.action(VspAclRule.ACLAction.Deny);
+            vspAclRuleBuilder.deny();
         } else {
-            vspAclRuleBuilder.action(VspAclRule.ACLAction.Allow);
+            vspAclRuleBuilder.allow();
         }
 
-        if (firewallRule.getSourceIpAddressId() != null) {
-            IPAddressVO ipAddress = _ipAddressDao.findById(firewallRule.getSourceIpAddressId());
-            if (ipAddress != null) {
-                vspAclRuleBuilder.sourceIpAddress(ipAddress.getVmIp() + "/32");
+        if (staticNat == null && firewallRule.getSourceIpAddressId() != null) {
+            IPAddressVO staticNatIp = _ipAddressDao.findById(firewallRule.getSourceIpAddressId());
+
+            if (staticNatIp != null) {
+                VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId());
+                NicVO nic = _nicDao.findByIp4AddressAndNetworkId(staticNatIp.getVmIp(), staticNatIp.getAssociatedWithNetworkId());
+
+                vspAclRuleBuilder.staticNat(buildVspStaticNat(null, staticNatIp, staticNatVlan, nic));
             }
         }
 
@@ -451,7 +488,7 @@ public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
     }
 
     public VspAclRule buildVspAclRule(NetworkACLItem networkAcl) {
-        VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder()
+        return new VspAclRule.Builder()
                 .uuid(networkAcl.getUuid())
                 .protocol(networkAcl.getProtocol())
                 .startPort(networkAcl.getSourcePortStart())
@@ -459,32 +496,11 @@ public VspAclRule buildVspAclRule(NetworkACLItem networkAcl) {
                 .sourceIpAddress(null)
                 .sourceCidrList(networkAcl.getSourceCidrList())
                 .priority(networkAcl.getNumber())
-                .type(VspAclRule.ACLType.NetworkACL);
-
-        switch (networkAcl.getState()) {
-            case Active:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Active); break;
-            case Add:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Add); break;
-            case Revoke:
-                vspAclRuleBuilder.state(VspAclRule.ACLState.Revoke);
-        }
-
-        switch (networkAcl.getTrafficType()) {
-            case Ingress:
-                vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Ingress); break;
-            case Egress:
-                vspAclRuleBuilder.trafficType(VspAclRule.ACLTrafficType.Egress);
-        }
-
-        switch (networkAcl.getAction()) {
-            case Allow:
-                vspAclRuleBuilder.action(VspAclRule.ACLAction.Allow); break;
-            case Deny:
-                vspAclRuleBuilder.action(VspAclRule.ACLAction.Deny);
-        }
-
-        return vspAclRuleBuilder.build();
+                .type(VspAclRule.ACLType.NetworkACL)
+                .state(getEnumValue(networkAcl.getState(), VspAclRule.ACLState.class))
+                .trafficType(getEnumValue(networkAcl.getTrafficType(), VspAclRule.ACLTrafficType.class))
+                .action(getEnumValue(networkAcl.getAction(), VspAclRule.ACLAction.class))
+                .build();
     }
 
     /** Build VspDhcpVMOption to put on the VM interface */
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/NuageTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/NuageTest.java
index 14742657e86..643a66f8122 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/NuageTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/NuageTest.java
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
 import net.nuage.vsp.acs.client.api.model.VspAclRule;
 import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
 import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
@@ -113,6 +114,16 @@ protected VspNetwork buildVspNetwork() {
                 .cidr("networkCidr")
                 .gateway("networkGateway")
                 .virtualRouterIp("virtualRouterIp")
+                .networkRelatedVsdIds(buildNetworkRelatedIds())
+                .build();
+    }
+
+    protected NetworkRelatedVsdIds buildNetworkRelatedIds() {
+        return new NetworkRelatedVsdIds.Builder()
+                .vsdZoneId("vsdZoneId")
+                .vsdDomainId("vsdDomainId")
+                .vsdEnterpriseId("vsdEnterpriseId")
+                .vsdSubnetId("vsdSubnetId")
                 .build();
     }
 
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
index 8f334eba784..e92f4a7b9e2 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
@@ -25,6 +25,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 
+import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InjectMocks;
@@ -37,6 +38,8 @@
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
+import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
+import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
@@ -142,6 +145,7 @@ public void setUp() throws Exception {
         when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
         when(host.getId()).thenReturn(NETWORK_ID);
         when(_agentManager.easySend(eq(NETWORK_ID), any(Command.class))).thenReturn(new Answer(null));
+        when(_agentManager.easySend(eq(NETWORK_ID), any(ImplementNetworkVspCommand.class))).thenReturn(new ImplementNetworkVspAnswer(null, new NetworkRelatedVsdIds.Builder().build()));
         when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
 
         final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
index e497ec4d396..fb67e6ff9d7 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
@@ -58,6 +58,7 @@
 import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
 import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
 import com.cloud.agent.api.guru.TrashNetworkVspCommand;
+import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
 import com.cloud.host.Host;
 
 import static org.junit.Assert.assertEquals;
@@ -152,7 +153,7 @@ public void testImplementNetworkVspCommand() throws Exception {
         VspNetwork vspNetwork = buildVspNetwork();
         VspDhcpDomainOption vspDhcpOptions = buildspDhcpDomainOption();
         ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpOptions);
-        com.cloud.agent.api.Answer implNtwkAns = _resource.executeRequest(cmd);
+        ImplementNetworkVspAnswer implNtwkAns = (ImplementNetworkVspAnswer)_resource.executeRequest(cmd);
         assertTrue(implNtwkAns.getResult());
         verify(_mockNuageVspGuruClient).implement(vspNetwork, vspDhcpOptions);
     }
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
index 7ebdeb371a3..0ac13becaac 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
@@ -19,17 +19,20 @@
 
 package com.cloud.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import net.nuage.vsp.acs.client.api.model.Protocol;
+import net.nuage.vsp.acs.client.api.model.VspAclRule;
+import net.nuage.vsp.acs.client.api.model.VspDomain;
+import net.nuage.vsp.acs.client.api.model.VspNetwork;
+import net.nuage.vsp.acs.client.api.model.VspNic;
+import net.nuage.vsp.acs.client.api.model.VspStaticNat;
+import net.nuage.vsp.acs.client.api.model.VspVm;
 
+import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.collect.Lists;
+
 import com.cloud.NuageTest;
 import com.cloud.dc.VlanDetailsVO;
 import com.cloud.dc.VlanVO;
@@ -57,15 +60,15 @@
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.VirtualMachine;
-import com.google.common.collect.Lists;
+import com.cloud.vm.dao.NicDao;
 
-import net.nuage.vsp.acs.client.api.model.Protocol;
-import net.nuage.vsp.acs.client.api.model.VspAclRule;
-import net.nuage.vsp.acs.client.api.model.VspDomain;
-import net.nuage.vsp.acs.client.api.model.VspNetwork;
-import net.nuage.vsp.acs.client.api.model.VspNic;
-import net.nuage.vsp.acs.client.api.model.VspStaticNat;
-import net.nuage.vsp.acs.client.api.model.VspVm;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class NuageVspEntityBuilderTest extends NuageTest {
 
@@ -76,8 +79,12 @@
     private static final long L2_NETWORK_OFFERING_ID = 3L;
     private static final long VPC_ID = 1L;
     private static final long SOURCE_IP_ADDRESS_ID = 1L;
+    private static final long VM_ID = 4L;
+    private static final long VLAN_ID = 5L;
+    public static final String VM_IP = "192.168.0.24";
 
     private VpcDao _vpcDao = mock(VpcDao.class);
+    private VpcDetailsDao _vpcDetailsDao = mock(VpcDetailsDao.class);
     private DomainDao _domainDao = mock(DomainDao.class);
     private AccountDao _accountDao = mock(AccountDao.class);
     private NetworkDao _networkDao = mock(NetworkDao.class);
@@ -87,6 +94,7 @@
     private VlanDetailsDao _vlanDetailsDao = mock(VlanDetailsDao.class);
     private IPAddressDao _ipAddressDao = mock(IPAddressDao.class);
     private NetworkDetailsDao _networkDetailsDao = mock(NetworkDetailsDao.class);
+    private NicDao _nicDao = mock(NicDao.class);
     private NuageVspEntityBuilder _nuageVspEntityBuilder = new NuageVspEntityBuilder();
 
     private DomainVO _mockedDomain = mock(DomainVO.class);
@@ -115,6 +123,7 @@ public void setUp() throws Exception {
         super.setUp();
 
         _nuageVspEntityBuilder._vpcDao = _vpcDao;
+        _nuageVspEntityBuilder._vpcDetailsDao = _vpcDetailsDao;
         _nuageVspEntityBuilder._domainDao = _domainDao;
         _nuageVspEntityBuilder._accountDao = _accountDao;
         _nuageVspEntityBuilder._networkDao = _networkDao;
@@ -126,6 +135,7 @@ public void setUp() throws Exception {
         _nuageVspEntityBuilder._ipAddressDao = _ipAddressDao;
         _nuageVspEntityBuilder._networkModel = _networkModel;
         _nuageVspEntityBuilder._networkDetailsDao = _networkDetailsDao;
+        _nuageVspEntityBuilder._nicDao = _nicDao;
 
         setUpMockedDomain();
         setUpMockedAccount();
@@ -208,12 +218,15 @@ public void testBuildVspStaticNat() {
     }
 
     @Test
-    public void testBuildVspAclRule() {
+    public void testBuildVspAclRuleAcl() {
+        VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(_mockedNetworkAclItem);
+        validateVspAclRule(vspAclRule, false);
+    }
+
+    @Test
+    public void testBuildVspAclRuleFirewall() {
         VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(_mockedFirewallRule, _mockedNetwork);
         validateVspAclRule(vspAclRule, true);
-
-        vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(_mockedNetworkAclItem);
-        validateVspAclRule(vspAclRule, false);
     }
 
     private void validateVspDomain(VspDomain vspDomain) {
@@ -229,6 +242,7 @@ private void validateVspNetwork(VspNetwork vspNetwork, boolean isL2, boolean isL
         assertEquals("networkName", vspNetwork.getName());
         assertNotNull(vspNetwork.getVspDomain());
         validateVspDomain(vspNetwork.getVspDomain());
+
         assertEquals("accountName", vspNetwork.getAccountName());
         assertEquals("accountUuid", vspNetwork.getAccountUuid());
 
@@ -262,13 +276,14 @@ private void validateVspNic(VspNic vspNic) {
         assertEquals("nicUuid", vspNic.getUuid());
         assertEquals("macAddress", vspNic.getMacAddress());
         assertEquals(true, vspNic.getUseStaticIp());
-        assertEquals("10.10.10.2", vspNic.getIp());
+        assertEquals("192.168.0.24", vspNic.getIp());
     }
 
     private void validateVspStaticNat(VspStaticNat vspStaticNat, Boolean forRevoke) {
         assertEquals("staticNatIpUuid", vspStaticNat.getIpUuid());
         assertEquals("10.10.10.2", vspStaticNat.getIpAddress());
         assertEquals(forRevoke, vspStaticNat.getRevoke());
+        assertEquals(VspStaticNat.State.Allocated, vspStaticNat.getState());
         assertEquals(true, vspStaticNat.getOneToOneNat());
         assertEquals("staticNatVlanUuid", vspStaticNat.getVlanUuid());
         assertEquals("10.10.10.1", vspStaticNat.getVlanGateway());
@@ -286,10 +301,13 @@ private void validateVspAclRule(VspAclRule vspAclRule, boolean isFirewall) {
 
         if (isFirewall) {
             assertEquals(VspAclRule.ACLType.Firewall, vspAclRule.getType());
-            assertEquals("192.168.0.24/32", vspAclRule.getSourceIpAddress());
+            final VspStaticNat staticNat = vspAclRule.getStaticNat();
+            assertNotNull(staticNat);
+            assertEquals("192.168.0.24/32", staticNat.getDestinationIp());
             assertEquals(VspAclRule.ACLAction.Deny, vspAclRule.getAction());
         } else {
             assertEquals(VspAclRule.ACLType.NetworkACL, vspAclRule.getType());
+            assertNull(vspAclRule.getStaticNat());
             assertNull(vspAclRule.getSourceIpAddress());
             assertEquals(VspAclRule.ACLAction.Allow, vspAclRule.getAction());
         }
@@ -345,14 +363,14 @@ private void setUpMockedVirtualMachine(VirtualMachine virtualMachineToMock, bool
 
     private void setUpMockedNicProfile() {
         when(_mockedNicProfile.getMacAddress()).thenReturn("macAddress");
-        when(_mockedNicProfile.getIPv4Address()).thenReturn("10.10.10.2");
+        when(_mockedNicProfile.getIPv4Address()).thenReturn(VM_IP);
         when(_mockedNicProfile.getNetworkId()).thenReturn(NETWORK_ID);
     }
 
     private void setUpMockedNic() {
         when(_mockedNic.getUuid()).thenReturn("nicUuid");
         when(_mockedNic.getMacAddress()).thenReturn("macAddress");
-        when(_mockedNic.getIPv4Address()).thenReturn("10.10.10.2");
+        when(_mockedNic.getIPv4Address()).thenReturn(VM_IP);
         when(_mockedNic.getNetworkId()).thenReturn(NETWORK_ID);
     }
 
@@ -360,8 +378,11 @@ private void setUpMockedStaticNatIp() {
         when(_mockedStaticNatIp.getUuid()).thenReturn("staticNatIpUuid");
         when(_mockedStaticNatIp.getAddress()).thenReturn(new Ip("10.10.10.2"));
         when(_mockedStaticNatIp.isOneToOneNat()).thenReturn(true);
-        when(_mockedStaticNatIp.getVmIp()).thenReturn("192.168.0.24");
+        when(_mockedStaticNatIp.getVmIp()).thenReturn(VM_IP);
+        when(_mockedStaticNatIp.getAssociatedWithNetworkId()).thenReturn(NETWORK_ID);
+        when(_mockedStaticNatIp.getAssociatedWithVmId()).thenReturn(VM_ID);
         when(_mockedStaticNatIp.getState()).thenReturn(IpAddress.State.Allocated);
+        when(_mockedStaticNatIp.getVlanId()).thenReturn(VLAN_ID);
     }
 
     private void setUpMockedStaticNatVlan() {
@@ -410,8 +431,11 @@ private void setUpMockedDaoCalls() {
         when(_networkModel.areServicesSupportedByNetworkOffering(SHARED_NETWORK_OFFERING_ID, Network.Service.Firewall)).thenReturn(true);
         when(_networkModel.areServicesSupportedByNetworkOffering(L2_NETWORK_OFFERING_ID, Network.Service.Firewall)).thenReturn(true);
         when(_vlanDao.listVlansByNetworkId(NETWORK_ID)).thenReturn(Lists.newArrayList(_mockedVlan));
+        when(_vlanDao.findById(VLAN_ID)).thenReturn(_mockedVlan);
         when(_vlanDetailsDao.findDetail(anyLong(), anyString())).thenReturn(_mockedVlanDetail);
         when(_vpcDao.findById(VPC_ID)).thenReturn(_mockedVpc);
         when(_ipAddressDao.findById(SOURCE_IP_ADDRESS_ID)).thenReturn(_mockedStaticNatIp);
+        when(_vpcDetailsDao.listDetailsKeyPairs(VPC_ID)).thenReturn(null);
+        when(_nicDao.findByIp4AddressAndNetworkId("192.168.0.24", NETWORK_ID)).thenReturn(_mockedNic);
     }
 }
diff --git a/test/integration/plugins/nuagevsp/nuageTestCase.py b/test/integration/plugins/nuagevsp/nuageTestCase.py
index c673a9b31c4..21a4ef79724 100644
--- a/test/integration/plugins/nuagevsp/nuageTestCase.py
+++ b/test/integration/plugins/nuagevsp/nuageTestCase.py
@@ -51,6 +51,7 @@
 import sys
 import time
 from retry import retry
+from nuage_vsp_statistics import VsdDataCollector
 
 
 class needscleanup(object):
diff --git a/test/integration/plugins/nuagevsp/nuage_test_data.py b/test/integration/plugins/nuagevsp/nuage_test_data.py
new file mode 100644
index 00000000000..7f3f3a2dfbf
--- /dev/null
+++ b/test/integration/plugins/nuagevsp/nuage_test_data.py
@@ -0,0 +1,2050 @@
+#t	 Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+test_data = {
+    "region": {
+        "regionid": "2",
+        "regionname": "Region2",
+        "regionendpoint": "http://region2:8080/client"
+    },
+    "zone": "NA",
+    "hypervisor": "XenServer",
+    "deleteDC": True,
+    "vdomain": {
+        "name": "domain"
+    },
+    "domain": {"name": "domain"},
+    "email": "test@test.com",
+    "gateway": "172.1.1.1",
+    "netmask": "255.255.255.0",
+    "startip": "172.1.1.10",
+    "endip": "172.1.1.20",
+    "regionid": "1",
+    "vlan": "10",
+    "isportable": "true",
+
+    "project": {
+        "name": "Project",
+        "displaytext": "Test project"
+    },
+    "publiciprange": {
+        "gateway": "",
+        "netmask": "",
+        "startip": "",
+        "endip": "",
+        "forvirtualnetwork": "true",
+        "vlan": "",
+        "zoneid": ""
+    },
+    "private_gateway": {
+        "ipaddress": "172.16.1.2",
+        "gateway": "172.16.1.1",
+        "netmask": "255.255.255.0",
+        "vlan": "10",
+        "name": "test_private_gateway"
+    },
+    "account": {
+        "email": "test-account@test.com",
+        "firstname": "test",
+        "lastname": "test",
+        "username": "test-account",
+        "password": "password"
+    },
+    "account2": {
+        "email": "test-account2@test.com",
+        "firstname": "test2",
+        "lastname": "test2",
+        "username": "test-account2",
+        "password": "password"
+    },
+    "small": {
+        "displayname": "testserver",
+        "username": "root",
+        "password": "password",
+        "ssh_port": 22,
+        "hypervisor": "XenServer",
+        "privateport": 22,
+        "publicport": 22,
+        "protocol": 'TCP',
+    },
+    "service_offering": {
+        "name": "Tiny Instance",
+        "displaytext": "Tiny Instance",
+        "cpunumber": 1,
+        "cpuspeed": 256,  # in MHz
+        "memory": 256,  # In MBs
+    },
+    "service_offerings": {
+        "tiny": {
+            "name": "Tiny Instance",
+            "displaytext": "Tiny Instance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 128,
+        },
+        "small": {
+            "name": "Small Instance",
+            "displaytext": "Small Instance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 256
+        },
+        "medium": {
+            "name": "Medium Instance",
+            "displaytext": "Medium Instance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 256,
+        },
+        "big": {
+            "name": "BigInstance",
+            "displaytext": "BigInstance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 512,
+        },
+        "large": {
+            "name": "LargeInstance",
+            "displaytext": "LargeInstance",
+            "cpunumber": 1,
+            "cpuspeed": 1024,
+            "memory": 2048,
+        },
+        "hasmall": {
+            "name": "HA Small Instance",
+            "displaytext": "HA Small Instance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 256,
+            "hosttags": "ha",
+            "offerha": True,
+        },
+        "taggedsmall": {
+            "name": "Tagged Small Instance",
+            "displaytext": "Tagged Small Instance",
+            "cpunumber": 1,
+            "cpuspeed": 100,
+            "memory": 256,
+            "hosttags": "vmsync",
+        },
+    },
+    "service_offering_h1": {
+        "name": "Tagged h1 Small Instance",
+        "displaytext": "Tagged h1 Small Instance",
+        "cpunumber": 1,
+        "cpuspeed": 100,
+        "memory": 256,
+        "hosttags": "h1"
+    },
+    "service_offering_h2": {
+        "name": "Tagged h2 Small Instance",
+        "displaytext": "Tagged h2 Small Instance",
+        "cpunumber": 1,
+        "cpuspeed": 100,
+        "memory": 256,
+        "hosttags": "h2"
+    },
+    "disk_offering": {
+        "name": "Disk offering",
+        "displaytext": "Disk offering",
+        "disksize": 1
+    },
+    'resized_disk_offering': {
+        "displaytext": "Resized",
+        "name": "Resized",
+        "disksize": 3
+    },
+    'disk_offering_shared_5GB': {
+        "displaytext": "disk_offering_shared_5GB",
+        "name": "disk_offering_shared_5GB",
+        "disksize": 5
+    },
+    'disk_offering_shared_15GB': {
+        "displaytext": "disk_offering_shared_5GB",
+        "name": "disk_offering_shared_5GB",
+        "disksize": 15
+    },
+    "network": {
+        "name": "Test Network",
+        "displaytext": "Test Network",
+        "acltype": "Account",
+    },
+    "network2": {
+        "name": "Test Network Shared",
+        "displaytext": "Test Network Shared",
+        "vlan": 1201,
+        "gateway": "172.16.15.1",
+        "netmask": "255.255.255.0",
+        "startip": "172.16.15.21",
+        "endip": "172.16.15.41",
+        "acltype": "Account",
+    },
+    "network_offering": {
+        "name": 'Test Network offering',
+        "displaytext": 'Test Network offering',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+        "traffictype": 'GUEST',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+        },
+    },
+    "nw_off_isolated_netscaler": {
+        "name": 'Netscaler',
+        "displaytext": 'Netscaler',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+        "traffictype": 'GUEST',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+            "Vpn": 'VirtualRouter',
+            "Firewall": 'VirtualRouter',
+            "Lb": 'Netscaler',
+            "UserData": 'VirtualRouter',
+            "StaticNat": 'VirtualRouter',
+        },
+    },
+    "nw_off_isolated_persistent": {
+        "name": 'Test Nw off isolated persistent',
+        "displaytext": 'Test Nw off isolated persistent',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+        "traffictype": 'GUEST',
+        "ispersistent": 'True',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+        },
+    },
+    "nw_off_isolated_persistent_lb": {
+        "name": 'Test Nw off isolated persistent',
+        "displaytext": 'Test Nw off isolated persistent',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Lb',
+        "traffictype": 'GUEST',
+        "ispersistent": 'True',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+            "Lb": "VirtualRouter"
+        },
+    },
+    "isolated_network_offering": {
+        "name": "Network offering-DA services",
+        "displaytext": "Network offering-DA services",
+        "guestiptype": "Isolated",
+        "supportedservices":
+            "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+        "traffictype": "GUEST",
+        "availability": "Optional'",
+        "serviceProviderList": {
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "SourceNat": "VirtualRouter",
+            "PortForwarding": "VirtualRouter",
+            "Vpn": "VirtualRouter",
+            "Firewall": "VirtualRouter",
+            "Lb": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "StaticNat": "VirtualRouter"
+        }
+    },
+    "network_offering_vlan": {
+        "name": 'Test Network offering',
+        "displaytext": 'Test Network offering',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+        "traffictype": 'GUEST',
+        "specifyvlan": 'False',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+        },
+    },
+    "network_offering_without_sourcenat": {
+        "name": 'Test Network offering',
+        "displaytext": 'Test Network offering',
+        "guestiptype": 'Isolated',
+        "supportedservices": 'Dhcp,Dns,UserData',
+        "traffictype": 'GUEST',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "UserData": 'VirtualRouter',
+        },
+    },
+    "isolated_network": {
+        "name": "Isolated Network",
+        "displaytext": "Isolated Network"
+    },
+    "netscaler_VPX": {
+        "ipaddress": "10.223.240.174",
+        "username": "nsroot",
+        "password": "nsroot",
+        "networkdevicetype": "NetscalerVPXLoadBalancer",
+        "publicinterface": "1/1",
+        "privateinterface": "1/2",
+        "numretries": 2,
+        "lbdevicededicated": "True",
+        "lbdevicecapacity": 2,
+        "port": 22
+    },
+    "netscaler_network": {
+        "name": "Netscaler",
+        "displaytext": "Netscaler",
+    },
+    "network_without_acl": {
+        "name": "TestNetwork",
+        "displaytext": "TestNetwork",
+    },
+    "virtual_machine": {
+        "displayname": "Test VM",
+        "username": "root",
+        "password": "password",
+        "ssh_port": 22,
+        "privateport": 22,
+        "publicport": 22,
+        "protocol": "TCP",
+        "affinity": {
+            "name": "webvms",
+            "type": "host anti-affinity",
+        }
+    },
+    "virtual_machine_userdata": {
+        "displayname": "Test VM",
+        "username": "root",
+        "password": "password",
+        "ssh_port": 22,
+        "privateport": 22,
+        "publicport": 22,
+        "protocol": "TCP",
+        "affinity": {
+            "name": "webvms",
+            "type": "host anti-affinity",
+        },
+        "userdata": "This is sample data"
+    },
+    "virtual_machine2": {
+        "name": "testvm2",
+        "displayname": "Test VM2",
+    },
+    "virtual_machine3": {
+        "name": "testvm3",
+        "displayname": "Test VM3",
+    },
+    "shared_network": {
+        "name": "MySharedNetwork - Test",
+        "displaytext": "MySharedNetwork",
+        "vlan": "",
+        "gateway": "",
+        "netmask": "",
+        "startip": "",
+        "endip": "",
+        "acltype": "Domain",
+        "scope": "all"
+    },
+    "shared_network_offering": {
+        "name": "MySharedOffering-shared",
+        "displaytext": "MySharedOffering",
+        "guestiptype": "Shared",
+        "supportedservices": "Dhcp,Dns,UserData",
+        "specifyVlan": "False",
+        "specifyIpRanges": "False",
+        "traffictype": "GUEST",
+        "serviceProviderList": {
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "UserData": "VirtualRouter"
+        }
+    },
+    "shared_network_offering_all_services": {
+        "name": "shared network offering with services enabled",
+        "displaytext": "Shared network offering",
+        "guestiptype": "Shared",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+        "specifyVlan": "False",
+        "specifyIpRanges": "False",
+        "traffictype": "GUEST",
+        "serviceProviderList": {
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "SourceNat": "VirtualRouter",
+            "PortForwarding": "VirtualRouter",
+            "Vpn": "VirtualRouter",
+            "Firewall": "VirtualRouter",
+            "Lb": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "StaticNat": "VirtualRouter"
+        }
+    },
+    "shared_network_offering_sg": {
+        "name": "MySharedOffering-sg",
+        "displaytext": "MySharedOffering-sg",
+        "guestiptype": "Shared",
+        "supportedservices": "Dhcp,Dns,UserData,SecurityGroup",
+        "specifyVlan": "False",
+        "specifyIpRanges": "False",
+        "traffictype": "GUEST",
+        "serviceProviderList": {
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "SecurityGroup": "SecurityGroupProvider"
+        }
+    },
+    "shared_network_sg": {
+        "name": "Shared-Network-SG-Test",
+        "displaytext": "Shared-Network_SG-Test",
+        "networkofferingid": "1",
+        "vlan": "",
+        "gateway": "",
+        "netmask": "255.255.255.0",
+        "startip": "",
+        "endip": "",
+        "acltype": "Domain",
+        "scope": "all"
+    },
+    "vpc_offering": {
+        "name": "VPC off",
+        "displaytext": "VPC off",
+        "supportedservices":
+            "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
+    },
+    "vpc_offering_multi_lb": {
+        "name": "VPC offering with multiple Lb service providers",
+        "displaytext": "VPC offering with multiple Lb service providers",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL",
+        "serviceProviderList": {
+            "Vpn": 'VpcVirtualRouter',
+            "Dhcp": 'VpcVirtualRouter',
+            "Dns": 'VpcVirtualRouter',
+            "SourceNat": 'VpcVirtualRouter',
+            "Lb": ["InternalLbVm", "VpcVirtualRouter"],
+            "PortForwarding": 'VpcVirtualRouter',
+            "UserData": 'VpcVirtualRouter',
+            "StaticNat": 'VpcVirtualRouter',
+            "NetworkACL": 'VpcVirtualRouter'
+        }
+    },
+    "vpc": {
+        "name": "TestVPC",
+        "displaytext": "TestVPC",
+        "cidr": "10.0.0.1/24"
+    },
+    "vpc_network_domain": {
+        "name": "TestVPC",
+        "displaytext": "TestVPC",
+        "cidr": '10.0.0.1/24',
+        "network_domain": "TestVPC"
+    },
+    "clusters": {
+        0: {
+            "clustername": "Xen Cluster",
+            "clustertype": "CloudManaged",
+            "hypervisor": "XenServer",
+        },
+        1: {
+            "clustername": "KVM Cluster",
+            "clustertype": "CloudManaged",
+            "hypervisor": "KVM",
+        },
+        2: {
+            "hypervisor": 'VMware',
+            "clustertype": 'ExternalManaged',
+            "username": 'administrator',
+            "password": 'fr3sca',
+            "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1',
+            "clustername": 'VMWare Cluster',
+        },
+    },
+    "hosts": {
+        "xenserver": {
+            "hypervisor": 'XenServer',
+            "clustertype": 'CloudManaged',
+            "url": 'http://192.168.100.211',
+            "username": "root",
+            "password": "fr3sca",
+        },
+        "kvm": {
+            "hypervisor": 'KVM',
+            "clustertype": 'CloudManaged',
+            "url": 'http://192.168.100.212',
+            "username": "root",
+            "password": "fr3sca",
+        },
+        "vmware": {
+            "hypervisor": 'VMware',
+            "clustertype": 'ExternalManaged',
+            "url": 'http://192.168.100.203',
+            "username": "administrator",
+            "password": "fr3sca",
+        },
+    },
+    "network_offering_shared": {
+        "name": 'Test Network offering shared',
+        "displaytext": 'Test Network offering Shared',
+        "guestiptype": 'Shared',
+        "supportedservices": 'Dhcp,Dns,UserData',
+        "traffictype": 'GUEST',
+        "specifyVlan": "True",
+        "specifyIpRanges": "True",
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "UserData": 'VirtualRouter',
+        },
+    },
+    "nw_off_isolated_RVR": {
+        "name": "Network offering-RVR services",
+        "displaytext": "Network off-RVR services",
+        "guestiptype": "Isolated",
+        "supportedservices": "Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat",
+        "traffictype": "GUEST",
+        "availability": "Optional",
+        "ispersistent": "False",
+        "serviceProviderList": {
+            "Vpn": "VirtualRouter",
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "SourceNat": "VirtualRouter",
+            "PortForwarding": "VirtualRouter",
+            "Firewall": "VirtualRouter",
+            "Lb": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "StaticNat": "VirtualRouter"
+        },
+        "serviceCapabilityList": {
+            "SourceNat": {
+                "SupportedSourceNatTypes": "peraccount",
+                "RedundantRouter": "true"
+            },
+            "lb": {
+                "SupportedLbIsolation": "dedicated"
+            }
+        }
+    },
+    "nw_off_persistent_RVR": {
+        "name": 'Network offering-RVR services',
+        "displaytext": 'Network off-RVR services',
+        "guestiptype": 'Isolated',
+        "supportedservices":
+            'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+        "traffictype": 'GUEST',
+        "ispersistent": 'True',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Vpn": 'VirtualRouter',
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+            "Firewall": 'VirtualRouter',
+            "Lb": 'VirtualRouter',
+            "UserData": 'VirtualRouter',
+            "StaticNat": 'VirtualRouter',
+        },
+        "serviceCapabilityList": {
+            "SourceNat": {
+                "SupportedSourceNatTypes": "peraccount",
+                "RedundantRouter": "true",
+            },
+            "lb": {
+                "SupportedLbIsolation": "dedicated"
+            },
+        },
+    },
+    "nw_offering_isolated_vpc": {
+        "name": "Isolated Network for VPC",
+        "displaytext": "Isolated Network for VPC",
+        "guestiptype": "Isolated",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat,NetworkACL,Lb",
+        "traffictype": "GUEST",
+        "availability": "Optional",
+        "ispersistent": "False",
+        "useVpc": "on",
+        "serviceProviderList": {
+            "Dhcp": "VpcVirtualRouter",
+            "Dns": "VpcVirtualRouter",
+            "SourceNat": "VpcVirtualRouter",
+            "PortForwarding": "VpcVirtualRouter",
+            "Vpn": "VpcVirtualRouter",
+            "UserData": "VpcVirtualRouter",
+            "StaticNat": "VpcVirtualRouter",
+            "NetworkACL": "VpcVirtualRouter",
+            "Lb": "VpcVirtualRouter"
+        }
+    },
+    "nw_off_persistent_VPCVR_LB": {
+        "name": "Persistent Network VPC with LB",
+        "displaytext": "Persistent Network VPC No LB",
+        "guestiptype": "Isolated",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL",
+        "traffictype": "GUEST",
+        "availability": "Optional",
+        "ispersistent": "True",
+        "useVpc": "on",
+        "serviceProviderList": {
+            "Dhcp": "VpcVirtualRouter",
+            "Dns": "VpcVirtualRouter",
+            "SourceNat": "VpcVirtualRouter",
+            "PortForwarding": "VpcVirtualRouter",
+            "Vpn": "VpcVirtualRouter",
+            "Lb": "VpcVirtualRouter",
+            "UserData": "VpcVirtualRouter",
+            "StaticNat": "VpcVirtualRouter",
+            "NetworkACL": "VpcVirtualRouter"
+        }
+    },
+    "nw_off_persistent_VPCVR_NoLB": {
+        "name": "Persistent Network VPC No LB",
+        "displaytext": "Persistent Network VPC No LB",
+        "guestiptype": "Isolated",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,UserData,StaticNat,NetworkACL",
+        "traffictype": "GUEST",
+        "availability": "Optional",
+        "ispersistent": "True",
+        "useVpc": "on",
+        "serviceProviderList": {
+            "Dhcp": "VpcVirtualRouter",
+            "Dns": "VpcVirtualRouter",
+            "SourceNat": "VpcVirtualRouter",
+            "PortForwarding": "VpcVirtualRouter",
+            "Vpn": "VpcVirtualRouter",
+            "UserData": "VpcVirtualRouter",
+            "StaticNat": "VpcVirtualRouter",
+            "NetworkACL": "VpcVirtualRouter"
+        }
+    },
+    "nw_offering_shared_persistent": {
+        "name": "Network offering for Shared Persistent Network",
+        "displaytext": "Network offering-DA services",
+        "guestiptype": "Shared",
+        "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+        "traffictype": "GUEST",
+        "availability": "Optional",
+        "ispersistent": "True",
+        "serviceProviderList": {
+            "Dhcp": "VirtualRouter",
+            "Dns": "VirtualRouter",
+            "SourceNat": "VirtualRouter",
+            "PortForwarding": "VirtualRouter",
+            "Vpn": "VirtualRouter",
+            "Firewall": "VirtualRouter",
+            "Lb": "VirtualRouter",
+            "UserData": "VirtualRouter",
+            "StaticNat": "VirtualRouter"
+        }
+    },
+    "fwrule": {
+        "startport": 22,
+        "endport": 22,
+        "cidr": "0.0.0.0/0",
+        "protocol": "TCP"
+    },
+    "nw_off_ncc_SharedSP": {
+        "name": 'SharedSP',
+        "displaytext": 'SharedSP',
+        "guestiptype": 'Isolated',
+        "supportedservices":
+            'Dhcp,Dns,SourceNat,Lb,StaticNat',
+        "traffictype": 'GUEST',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "Lb": 'Netscaler',
+            "StaticNat": 'VirtualRouter'
+        }
+    },
+    "nw_off_ncc_DedicatedSP": {
+        "name": 'DedicatedSP',
+        "displaytext": 'DedicatedSP',
+        "guestiptype": 'Isolated',
+        "supportedservices":
+            'Dhcp,Dns,SourceNat,Lb,StaticNat',
+        "traffictype": 'GUEST',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "Lb": 'Netscaler',
+            "StaticNat": 'VirtualRouter'
+        }
+    },
+    "NCC": {
+        "NCCIP": '10.102.195.215',
+    },
+    "NSShared": {
+        "NSIP": '10.102.195.210',
+    },
+    "NSDedicated": {
+        "NSIP": '10.102.195.212'
+    },
+    "servicepackage_shared": {
+        "name": "SharedSP",
+    },
+    "servicepackage_dedicated": {
+        "name": "DedicatedSP",
+    },
+
+    "nw_off_isolated_persistent_netscaler": {
+        "name": 'Netscaler',
+        "displaytext": 'Netscaler',
+        "guestiptype": 'Isolated',
+        "supportedservices":
+            'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+        "traffictype": 'GUEST',
+        "ispersistent": 'True',
+        "availability": 'Optional',
+        "serviceProviderList": {
+            "Dhcp": 'VirtualRouter',
+            "Dns": 'VirtualRouter',
+            "SourceNat": 'VirtualRouter',
+            "PortForwarding": 'VirtualRouter',
+            "Vpn": 'VirtualRouter',
+            "Firewall": 'VirtualRouter',
+            "Lb": 'Netscaler',
+            "UserData": 'VirtualRouter',
+            "StaticNat": 'VirtualRouter',
+        },
+
+    },
+    "network_acl_rule": {
+        "protocol": "TCP",
+        "traffictype": "ingress",
+        "cidrlist": "0.0.0.0/0",
+        "startport": "1",
+        "endport": "1"
+    },
+    "network_offering_internal_lb": {
+        "name": "Network offering for internal lb service",
+        "displaytext": "Network offering for internal lb service",
+        "guestiptype": "Isolated",
+        "traffictype": "Guest",
+        "supportedservices":
+            "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
+        "serviceProviderList": {
+            "Dhcp": "VpcVirtualRouter",
+            "Dns": "VpcVirtualRouter",
+            "Vpn": "VpcVirtualRouter",
+            "UserData": "VpcVirtualRouter",
+            "Lb": "InternalLbVM",
+            "SourceNat": "VpcVirtualRouter",
+            "StaticNat": "VpcVirtualRouter",
+            "PortForwarding": "VpcVirtualRouter",
+            "NetworkACL": "VpcVirtualRouter",
+        },
+        "serviceCapabilityList": {
+            "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
+            "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+        }
+    },
+    "natrule": {
+        "privateport": 22,
+        "publicport": 22,
+        "protocol": "TCP"
+    },
+    "natrulerange": {
+        "privateport": 70,
+        "privateendport": 75,
+        "publicport": 70,
+        "publicendport": 75,
+        "protocol": "TCP"
+    },
+    "updatenatrulerange": {
+        "privateport": 50,
+        "privateendport": 55,
+    },
+    "egress_80": {
+        "startport": 80,
+        "endport": 80,
+        "protocol": "TCP",
+        "cidrlist": ["0.0.0.0/0"]
+    },
+    "lbrule": {
+        "name": "SSH",
+        "alg": "roundrobin",
+        "privateport": 22,
+        "publicport": 2222,
+        "protocol": 'TCP'
+    },
+    "vpclbrule": {
+        "name": "SSH",
+        "alg": "roundrobin",
+        "privateport": 22,
+        "publicport": 22,
+        "protocol": 'TCP'
+    },
+    "internal_lbrule": {
+        "name": "SSH",
+        "algorithm": "roundrobin",
+        # Algorithm used for load balancing
+        "sourceport": 22,
+        "instanceport": 22,
+        "scheme": "internal",
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "internal_lbrule_http": {
+        "name": "HTTP",
+        "algorithm": "roundrobin",
+        # Algorithm used for load balancing
+        "sourceport": 80,
+        "instanceport": 80,
+        "scheme": "internal",
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "http_rule": {
+        "privateport": 80,
+        "publicport": 80,
+        "startport": 80,
+        "endport": 80,
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "dns_rule": {
+        "privateport": 53,
+        "publicport": 53,
+        "startport": 53,
+        "endport": 53,
+        "protocol": "UDP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "icmprule": {
+        "icmptype": -1,
+        "icmpcode": -1,
+        "cidrlist": "0.0.0.0/0",
+        "protocol": "ICMP"
+    },
+    "iso": {
+        "displaytext": "Test ISO",
+        "name": "ISO",
+        "url": "http://people.apache.org/~tsp/dummy.iso",
+        "bootable": False,
+        "ispublic": False,
+        "ostype": "Other (64-bit)",
+    },
+    "iso1": {
+        "displaytext": "Test ISO 1",
+        "name": "ISO 1",
+        "url": "http://people.apache.org/~tsp/dummy.iso",
+        "isextractable": True,
+        "isfeatured": True,
+        "ispublic": True,
+        "ostype": "CentOS 5.6 (64-bit)",
+    },
+    "iso2": {
+        "displaytext": "Test ISO 2",
+        "name": "ISO 2",
+        "url": "http://people.apache.org/~tsp/dummy.iso",
+        "isextractable": True,
+        "isfeatured": True,
+        "ispublic": True,
+        "ostype": "CentOS 5.6 (64-bit)",
+        "mode": 'HTTP_DOWNLOAD',
+    },
+    "isfeatured": True,
+    "ispublic": True,
+    "isextractable": True,
+    "bootable": True,
+    "passwordenabled": True,
+
+    "template": {
+        "displaytext": "xs",
+        "name": "xs",
+        "passwordenabled": False,
+        "ostype": "CentOS 5.6 (64-bit)"
+
+    },
+    "coreos_volume": {
+        "diskname": "Volume_core",
+        "urlvmware":"http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-vmware.ova",
+        "urlxen":"http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-xen.vhd.bz2",
+        "urlkvm": "http://dl.openvm.eu/cloudstack/coreos/x86_64/" \
+                  "coreos_production_cloudstack_image-kvm.qcow2.bz2",
+        "urlhyperv":"http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-hyperv.vhd.zip"
+    },
+    "CentOS6.3template": {
+        "displaytext": "Centos",
+        "name": "Centos",
+        "passwordenabled": False,
+        "ostype": "CentOS 6.3 (64-bit)",
+        "url": "http://people.apache.org/~sanjeev/centos63.ova",
+        "format": "OVA",
+        "ispublic": "true"
+    },
+    "CentOS7template": {
+        "displaytext": "Centos",
+        "name": "Centos",
+        "passwordenabled": False,
+        "isdynamicallyscalable":True,
+        "ostype": "CentOS 7",
+        "url": "http://dl.openvm.eu/cloudstack/centos/vanilla/7/x86_64/CentOS-7-x86_64-vanilla-xen.vhd.bz2",
+        "format": "VHD",
+        "ispublic": "true",
+        "hypervisor":"Xenserver"
+    },
+    "Rhel7template": {
+        "displaytext": "Rhel",
+        "name": "Rhel",
+        "passwordenabled": False,
+        "ostype": "Red Hat Enterprise Linux 7",
+        "format": "OVA",
+        "ispublic": "true"
+    },
+    "template_2": {
+        "displaytext": "Public Template",
+        "name": "Public template",
+        "ostype": "CentOS 5.6 (64-bit)",
+        "isfeatured": True,
+        "ispublic": True,
+        "isextractable": True,
+        "mode": "HTTP_DOWNLOAD",
+        "templatefilter": "self"
+    },
+    "Windows 7 (64-bit)": {
+        "displaytext": "Windows 7 (64-bit)",
+        "name": "Windows 7 (64-bit)",
+        "passwordenabled": False,
+        "url": "http://people.apache.org/~sanjeev/windows7.vhd",
+        "format": "VHD",
+        "ostype": "Windows 7 (64-bit)",
+        "ispublic": "true",
+        "hypervisor": "XenServer"
+    },
+    "Windows Server 2012": {
+        "displaytext": "Windows Server 2012",
+        "name": "Windows Server 2012",
+        "passwordenabled": False,
+        "format": "OVA",
+        "ostype": "Windows Server 2012 (64-bit)",
+        "ispublic": "true",
+        "hypervisor": "Vmware"
+    },
+    "privatetemplate": {
+        "displaytext": "Public Template",
+        "name": "Public template",
+        "ostype": "CentOS 5.6 (64-bit)",
+        "isfeatured": True,
+        "ispublic": False,
+        "isextractable": True,
+        "mode": "HTTP_DOWNLOAD",
+        "templatefilter": "self"
+    },
+    "volume_from_snapshot": {
+        "diskname": 'Volume from snapshot',
+        "size": "1",
+        "zoneid": ""
+    },
+    "templatefilter": 'self',
+    "templates": {
+        "displaytext": 'Template',
+        "name": 'Template',
+        "ostype": "CentOS 5.3 (64-bit)",
+        "templatefilter": 'self',
+    },
+    "win2012template": {
+        "displaytext": "win2012",
+        "name": "win2012",
+        "passwordenabled": False,
+        "url": "http://people.apache.org/~sanjeev/new-test-win.ova",
+        "format": "OVA",
+        "ostype": "Windows 8 (64-bit)",
+    },
+    "rhel60template": {
+        "displaytext": "Rhel60",
+        "name": "Rhel60",
+        "passwordenabled": False,
+        "url": "http://people.apache.org/~sanjeev/Rhel6-64bit.ova",
+        "format": "OVA",
+        "ostype": "Red Hat Enterprise Linux 6.0 (64-bit)"
+    },
+    "security_group": {"name": "custom_Sec_Grp"},
+    "ingress_rule": {
+        "protocol": "TCP",
+        "startport": "22",
+        "endport": "22",
+        "cidrlist": "0.0.0.0/0"
+    },
+    "ingress_rule_ICMP": {
+        "name": 'ICMP',
+        "protocol": 'ICMP',
+        "startport": -1,
+        "endport": -1,
+        "cidrlist": '0.0.0.0/0',
+    },
+    "vpncustomergateway": {
+        "ipsecpsk": "secreatKey",
+        "ikepolicy": "aes128-sha1",
+        "ikelifetime": "86400",
+        "esppolicy": "aes128-sha1",
+        "epslifetime": "3600",
+        "dpd": "false"
+    },
+    "vlan_ip_range": {
+        "startip": "",
+        "endip": "",
+        "netmask": "",
+        "gateway": "",
+        "forvirtualnetwork": "false",
+        "vlan": "untagged",
+    },
+    "ostype": "CoreOS",
+    "sleep": 90,
+    "timeout": 10,
+    "page": 1,
+    "pagesize": 2,
+    "listall": 'true',
+    "advanced_sg": {
+        "zone": {
+            "name": "",
+            "dns1": "8.8.8.8",
+            "internaldns1": "192.168.100.1",
+            "networktype": "Advanced",
+            "securitygroupenabled": "true"
+        },
+        "securitygroupenabled": "true"
+    },
+    "vlan": "10",
+    "portableiprange_vlan": {
+        "part": ["4090-4091", "4092-4095"],
+        "full": "4090-4095"
+    },
+    "nfs": {
+        "url": "nfs://nfs/export/automation/1/testprimary",
+        "name": "Primary XEN"
+    },
+    "nfs2": {
+        "url": "nfs://nfs/export/automation/1/testprimary2",
+        "name": "Primary XEN 2"
+    },
+    "iscsi": {
+        "url":
+            "iscsi://192.168.100.21/iqn.2012-01.localdomain.clo-cstack-cos6:iser/1",
+        "name": "Primary iSCSI"
+    },
+    "volume": {"diskname": "Test Volume",
+               "size": 1
+               },
+    "volume_write_path": {
+        "diskname": "APP Data Volume",
+        "size": 1,   # in GBs
+        "xenserver": {"rootdiskdevice":"/dev/xvda",
+                      "datadiskdevice_1": '/dev/xvdb',
+                      "datadiskdevice_2": '/dev/xvdc',   # Data Disk
+                      },
+        "kvm":       {"rootdiskdevice": "/dev/vda",
+                      "datadiskdevice_1": "/dev/vdb",
+                      "datadiskdevice_2": "/dev/vdc"
+                      },
+        "vmware":    {"rootdiskdevice": "/dev/hda",
+                      "datadiskdevice_1": "/dev/hdb",
+                      "datadiskdevice_2": "/dev/hdc"
+                      }
+    },
+    "data_write_paths": {
+        "mount_dir": "/mnt/tmp",
+        "sub_dir": "test",
+        "sub_lvl_dir1": "test1",
+        "sub_lvl_dir2": "test2",
+        "random_data": "random.data",
+    },
+    "custom_volume": {
+        "customdisksize": 1,
+        "diskname": "Custom disk",
+    },
+    "recurring_snapshot": {
+        "maxsnaps": 2,
+        "timezone": "US/Arizona",
+        "schedule": 1
+    },
+    "volume_offerings": {
+        0: {"diskname": "TestDiskServ"},
+    },
+    "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc',
+                   '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1'],
+
+    # test_vpc_vpn.py
+    "vpn_user": {
+        "username": "test",
+        "password": "password",
+    },
+    "vpc": {
+        "name": "vpc_vpn",
+        "displaytext": "vpc-vpn",
+        "cidr": "10.1.1.0/24"
+    },
+    "ntwk": {
+        "name": "tier1",
+        "displaytext": "vpc-tier1",
+        "gateway": "10.1.1.1",
+        "netmask": "255.255.255.192"
+    },
+    "vpc2": {
+        "name": "vpc2_vpn",
+        "displaytext": "vpc2-vpn",
+        "cidr": "10.2.1.0/24"
+    },
+    "ntwk2": {
+        "name": "tier2",
+        "displaytext": "vpc-tier2",
+        "gateway": "10.2.1.1",
+        "netmask": "255.255.255.192"
+    },
+    "privateport": 22,
+    "publicport": 22,
+    "protocol": 'TCP',
+    "forvirtualnetwork": "true",
+    "customdisksize": 1,
+    "diskname": "Test Volume",
+    "sparse": {
+        "name": "Sparse Type Disk offering",
+        "displaytext":
+            "Sparse Type Disk offering",
+        "disksize": 1,  # in GB
+        "provisioningtype": "sparse"
+    },
+    "fat": {
+        "name": "Fat Type Disk offering",
+        "displaytext":
+            "Fat Type Disk offering",
+        "disksize": 1,  # in GB
+        "provisioningtype": "fat"
+    },
+    "sparse_disk_offering": {
+        "displaytext": "Sparse",
+        "name": "Sparse",
+        "provisioningtype": "sparse",
+        "disksize": 1
+    },
+    "host_anti_affinity": {
+        "name": "hostantiaffinity",
+        "type": "host anti-affinity",
+    },
+    "vgpu": {
+        "disk_offering": {
+            "displaytext": "Small",
+            "name": "Small",
+            "disksize": 1
+        },
+        "templateregister1": {
+            "displaytext": "win8withpv",
+            "name": "win8withpv",
+            "passwordenabled": False,
+            "url": "http://pleaseupdateURL/dummy.vhd",
+            "format": "VHD",
+            "ostype": "Windows 8 (64-bit)",
+            "ispublic": "true",
+            "hypervisor": "XenServer"
+        },
+        "Windows 8 (64-bit)": {
+            "displaytext": "Windows 8 (64-bit)",
+            "name": "win8withpv",
+            "passwordenabled": False,
+            "url": "http://pleaseupdateURL/dummy.vhd",
+            "format": "VHD",
+            "ostype": "Windows 8 (64-bit)",
+            "ispublic": "true",
+            "hypervisor": "XenServer"
+        },
+        "Windows Server 2012 (64-bit)": {
+            "displaytext": "Windows Server 2012 (64-bit)",
+            "name": "Windows Server 2012 (64-bit)",
+            "passwordenabled": False,
+            "url": "http://pleaseupdateURL/dummy.vhd",
+            "format": "VHD",
+            "ostype": "Windows Server 2012 (64-bit)",
+            "ispublic": "true",
+            "hypervisor": "XenServer"
+        },
+
+        "Windows 7 (64-bit)": {
+            "displaytext": "Windows 7 (64-bit)",
+            "name": "Windows 7 (64-bit)",
+            "passwordenabled": False,
+            "url": "http://pleaseupdateURL/dummy.vhd",
+            "format": "VHD",
+            "ostype": "Windows 7 (64-bit)",
+            "ispublic": "true",
+            "hypervisor": "XenServer"
+        },
+        "RHEL 7 (64-bit)": {
+            "displaytext": "RHEL7 (64-bit)",
+            "name": "RHEL 7 Insta1",
+            "passwordenabled": False,
+            "url": "http://people.apache.org/~sanjeev/RHEL764bitwithtools.vhd",
+            "format": "VHD" ,
+            "ostype": "RHEL 7 (64-bit)",
+            "ispublic": "true",
+            "hypervisor": "XenServer"
+        },
+        "clusters": {
+            "clustername": "Xen Cluster Vgpu",
+            "clustertype": "CloudManaged",
+            "hypervisor": "XenServer"
+        },
+        "hosts": {
+            "nonvgpuxenserver": {
+                "hypervisor": 'XenServer',
+                "clustertype": 'CloudManaged',
+                "url": 'http://10.102.192.57',
+                "username": "root",
+                "password": "freebsd",
+            },
+        },
+        "account": {
+            "email": "test@test.com",
+            "firstname": "Test",
+            "lastname": "User",
+            "username": "test",
+            # Random characters are appended in create account to
+            # ensure unique username generated each time
+            "password": "password",
+        },
+        "service_offerings":
+            {
+                "GRID K260Q":
+                    {
+                        "name": "vGPU260Q",
+                        "displaytext": "vGPU260Q",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,  # in MHz
+                        "memory": 3072,  # In MBs
+                    },
+                "GRID K240Q":
+                    {
+                        "name": "vGPU240Q",
+                        "displaytext": "vGPU240Q",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,  # in MHz
+                        "memory": 3072,  # In MBs
+                    },
+                "GRID K220Q":
+                    {
+                        "name": "vGPU220Q",
+                        "displaytext": "vGPU220Q",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,  # in MHz
+                        "memory": 3072,  # In MBs
+                    },
+                "GRID K200":
+                    {
+                        "name": "vGPU200",
+                        "displaytext": "vGPU200",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,  # in MHz
+                        "memory": 3072,  # In MBs
+                    },
+                "passthrough":
+                    {
+                        "name": "vGPU passthrough",
+                        "displaytext": "vGPU passthrough",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,  # in MHz
+                        "memory": 3072,  # In MBs
+                    },
+                "GRID K140Q":
+                    {
+                        # Small service offering ID to for change VM
+                        # service offering from medium to small
+                        "name": "vGPU140Q",
+                        "displaytext": "vGPU140Q",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,
+                        "memory": 3072,
+                    },
+                "GRID K120Q":
+                    {
+                        "name": "vGPU120Q",
+                        "displaytext": "vGPU120Q",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,
+                        "memory": 3072,
+                    },
+                "GRID K100":
+                    {
+                        "name": "vGPU100",
+                        "displaytext": "vGPU100",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,
+                        "memory": 3072,
+                    },
+                "nonvgpuoffering":
+                    {
+                        "name": "nonvgpuoffering",
+                        "displaytext": "nonvgpuoffering",
+                        "cpunumber": 2,
+                        "cpuspeed": 1600,
+                        "memory": 3072,
+                    }
+
+            },
+        "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc', '/dev/xvdd', '/dev/cdrom', '/dev/sr0',
+                       '/dev/cdrom1'],
+        # Disk device where ISO is attached to instance
+        "mount_dir": "/mnt/tmp",
+        "sleep": 180,
+        "timeout": 60,
+        "ostype": 'Windows 8 (64-bit)',
+        "nongpu_host_ip": "10.102.192.57"
+    },
+    "acl": {
+        #data for domains and accounts
+        "domain1": {
+            "name": "D1",
+        },
+        "accountD1": {
+            "email": "testD1@test.com",
+            "firstname": "testD1",
+            "lastname": "Admin",
+            "username": "testD1",
+            "password": "password",
+            "accounttype": "1",
+        },
+        "accountD1A": {
+            "email": "testD1A@test.com",
+            "firstname": "testD1A",
+            "lastname": "User",
+            "username": "testD1A",
+            "password": "password",
+        },
+        "accountD1B": {
+            "email": "testD1B@test.com",
+            "firstname": "testD1B",
+            "lastname": "User",
+            "username": "testD1B",
+            "password": "password",
+        },
+        "domain11": {
+            "name": "D11",
+        },
+        "accountD11": {
+            "email": "testD11@test.com",
+            "firstname": "testD11",
+            "lastname": "Admin",
+            "username": "testD11",
+            "password": "password",
+            "accounttype": "1",
+        },
+        "accountD11A": {
+            "email": "testD11A@test.com",
+            "firstname": "testD11A",
+            "lastname": "User",
+            "username": "testD11A",
+            "password": "password",
+        },
+        "accountD11B": {
+            "email": "test11B@test.com",
+            "firstname": "testD11B",
+            "lastname": "User",
+            "username": "testD11B",
+            "password": "password",
+        },
+        "domain111": {
+            "name": "D111",
+        },
+        "accountD111": {
+            "email": "testD111@test.com",
+            "firstname": "testD111",
+            "lastname": "Admin",
+            "username": "testD111",
+            "password": "password",
+        },
+        "accountD111A": {
+            "email": "testD111A@test.com",
+            "firstname": "testD111A",
+            "lastname": "User",
+            "username": "testD111A",
+            "password": "password",
+        },
+        "accountD111B": {
+            "email": "testD111B@test.com",
+            "firstname": "testD111B",
+            "lastname": "User",
+            "username": "testD111B",
+            "password": "password",
+        },
+        "domain12": {
+            "name": "D12",
+        },
+        "accountD12A": {
+            "email": "testD12A@test.com",
+            "firstname": "testD12A",
+            "lastname": "User",
+            "username": "testD12A",
+            "password": "password",
+        },
+        "accountD12B": {
+            "email": "testD12B@test.com",
+            "firstname": "testD12B",
+            "lastname": "User",
+            "username": "testD12B",
+            "password": "password",
+        },
+        "domain2": {
+            "name": "D2",
+        },
+        "accountD2": {
+            "email": "testD2@test.com",
+            "firstname": "testD2",
+            "lastname": "User",
+            "username": "testD2",
+            "password": "password",
+            "accounttype": "1",
+        },
+        "accountD2A": {
+            "email": "testD2A@test.com",
+            "firstname": "testD2A",
+            "lastname": "User",
+            "username": "testD2A",
+            "password": "password",
+        },
+        "accountROOTA": {
+            "email": "testROOTA@test.com",
+            "firstname": "testROOTA",
+            "lastname": "User",
+            "username": "testROOTA",
+            "password": "password",
+        },
+
+        "accountROOT": {
+            "email": "testROOTA@test.com",
+            "firstname": "testROOT",
+            "lastname": "admin",
+            "username": "testROOT",
+            "password": "password",
+        },
+        #data reqd for virtual machine creation
+        "vmD1": {
+            "name": "d1",
+            "displayname": "d1",
+        },
+        "vmD1A": {
+            "name": "d1a",
+            "displayname": "d1a",
+        },
+        "vmD1B": {
+            "name": "d1b",
+            "displayname": "d1b",
+        },
+        "vmD11": {
+            "name": "d11",
+            "displayname": "d11",
+        },
+        "vmD11A": {
+            "name": "d11a",
+            "displayname": "d11a",
+        },
+        "vmD11B": {
+            "name": "d11b",
+            "displayname": "d11b",
+        },
+        "vmD111": {
+            "name": "d111",
+            "displayname": "d111",
+        },
+        "vmD111A": {
+            "name": "d111a",
+            "displayname": "d111a",
+        },
+        "vmD111B": {
+            "name": "d111b",
+            "displayname": "d111b",
+        },
+        "vmD12A": {
+            "name": "d12a",
+            "displayname": "d12a",
+        },
+        "vmD12B": {
+            "name": "d12b",
+            "displayname": "d12b",
+        },
+        "vmD2A": {
+            "name": "d2a",
+            "displayname": "d2a",
+        },
+
+        "vmROOTA": {
+            "name": "roota",
+            "displayname": "roota",
+        },
+        "vmROOT": {
+            "name": "root",
+            "displayname": "root",
+        },
+
+        #data reqd for Network creation
+        "network_all": {
+            "name": "SharedNetwork-All",
+            "displaytext": "SharedNetwork-All",
+            "vlan": "4001",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.100",
+            "acltype": "Domain"
+        },
+        "network_domain_with_no_subdomain_access": {
+            "name": "SharedNetwork-Domain-nosubdomain",
+            "displaytext": "SharedNetwork-Domain-nosubdomain",
+            "vlan": "4002",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.100",
+            "acltype": "Domain",
+            "subdomainaccess": "false"
+        },
+        "network_domain_with_subdomain_access": {
+            "name": "SharedNetwork-Domain-withsubdomain",
+            "displaytext": "SharedNetwork-Domain-withsubdomain",
+            "vlan": "4003",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.100",
+            "acltype": "Domain",
+            "subdomainaccess": "true"
+        },
+        "network_account": {
+            "name": "SharedNetwork-Account",
+            "displaytext": "SharedNetwork-Account",
+            "vlan": "4004",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.100",
+            "acltype": "Account"
+        },
+
+        "network": {
+            "name": "Network-",
+            "displaytext": "Network-",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.59.200",
+            "endip": "10.223.59.240",
+            "vlan": "1000"
+        },
+        "netscaler": {
+            "ipaddress": "",
+            "username": "",
+            "password": "",
+            "networkdevicetype": "",
+            "publicinterface": "",
+            "privateinterface": "",
+            "numretries": "",
+            "lbdevicededicated": "False",
+            "lbdevicecapacity": 2,
+            "port": 22
+        },
+        "iscsi": {
+            "url": "",
+            "name": "Primary iSCSI"
+        },
+        "host": {
+            "publicport": 22,
+            "username": "root",
+            "password": "password",
+        },
+        "ldap_account": {
+            "email": "",
+            "firstname": "",
+            "lastname": "",
+            "username": "",
+            "password": "",
+        },
+        "ldap_configuration": {
+            "basedn": "",
+            "emailAttribute": "",
+            "userObject": "",
+            "usernameAttribute": "",
+            "hostname": "",
+            "port": "",
+            "ldapUsername": "",
+            "ldapPassword": ""
+        },
+        "systemVmDelay": 120,
+        "setUsageConfigurationThroughTestCase": False,
+        "vmware_cluster" : {
+            "hypervisor": 'VMware',
+            "clustertype": 'ExternalManaged',
+            "username": '',
+            "password": '',
+            "url": '',
+            "clustername": 'VMWare Cluster with Space in DC name',
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.100",
+        },
+        #small service offering
+        "service_offering": {
+            "small": {
+                "name": "Small Instance",
+                "displaytext": "Small Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,
+                "memory": 128,
+            },
+        },
+        "ostype": 'CentOS 5.6 (64-bit)',
+    },
+    "test_34_DeployVM_in_SecondSGNetwork": {
+        "zone": "advsg",
+        "config": "D:\ACS-Repo\setup\dev\\advancedsg.cfg",  #Absolute path to cfg file
+        #For sample configuration please refer to <ACS repo>/setup/dev/advancedsg.cfg
+        "template": "CentOS 5.3(64-bit) no GUI (Simulator)",
+        "dbSvr": {
+            "dbSvr": "10.146.0.133",
+            "passwd": "cloud",
+            "db": "cloud",
+            "port": 3306,
+            "user": "cloud"
+        },
+        "mgtSvr": [
+            {
+                "mgtSvrIp": "10.146.0.133",
+                "passwd": "password",
+                "user": "root",
+                "port": 8096
+            }
+        ],
+        "ipranges": [
+            {
+                "startip": "10.147.32.150",
+                "endip": "10.147.32.153",
+                "netmask": "255.255.255.0",
+                "vlan": "32",
+                "gateway": "10.147.32.1"
+            }
+        ]
+    },
+
+    "interop":
+        {
+            "VHD":
+                {
+                    "displaytext": "Windows 8 (64-bit)",
+                    "name": "win8withpvxen",
+                    "passwordenabled": False,
+                    "url": "http://people.apache.org/~sanjeev/79211594-1d4a-4dee-ae6c-c5c315ded2be.vhd",
+                    "format": "VHD" ,
+                    "ostype": "Windows 8 (64-bit)",
+                    "ispublic": "true",
+                    "hypervisor": "XenServer"
+
+                },
+            "OVA":
+                {
+                    "displaytext": "Windows 8 (64-bit)",
+                    "name": "win8withpvvmware",
+                    "passwordenabled": False,
+                    "url": "http://pleaseupdateURL/",
+                    "format": "OVA" ,
+                    "ostype": "Windows 8 (64-bit)",
+                    "ispublic": "true",
+                    "hypervisor": "VMware"
+                },
+            "template": {
+                "displaytext": "windowsxdtemplate",
+                "name": "windowsxdtemplate",
+                "passwordenabled": False,
+                "ostype": "Windows 8 (64-bit)"
+            },
+        },
+
+    "browser_upload_volume":{
+        "VHD": {
+            "diskname": "XenUploadVol",
+            "url": "http://people.apache.org/~sanjeev/rajani-thin-volume.vhd",
+            "checksum": "09b08b6abb1b903fca7711d3ac8d6598",
+        },
+        "OVA": {
+            "diskname": "VMwareUploadVol",
+            "url": "http://people.apache.org/~sanjeev/CentOS5.5(64bit)-vmware-autoscale.ova",
+            "checksum": "da997b697feaa2f1f6e0d4785b0cece2",
+        },
+        "QCOW2": {
+            "diskname": "KVMUploadVol",
+            "url": "http://people.apache.org/~sanjeev/rajani-thin-volume.qcow2",
+            "checksum": "02de0576dd3a61ab59c03fd795fc86ac",
+        },
+        'browser_resized_disk_offering': {
+            "displaytext": "Resizeddisk",
+            "name": "Resizeddisk",
+            "disksize": 3,
+        }
+    },
+    "browser_upload_template": {
+        "VHD": {
+            "templatename": "XenUploadtemplate",
+            "displaytext": "XenUploadtemplate",
+            "url": "http://people.apache.org/~sanjeev/centos56-x86_64.vhd.bz2",
+            "hypervisor":"XenServer",
+            "checksum": "09b08b6abb1b903fca7711d3ac8d6598",
+            "ostypeid":"74affaea-c658-11e4-ad38-a6d1374244b4"
+        },
+        "OVA": {
+            "templatename": "VMwareUploadtemplate",
+            "displaytext": "VMwareUploadtemplate",
+            "url": "http://people.apache.org/~sanjeev/CentOS5.3-x86_64.ova",
+            "checksum": "02de0576dd3a61ab59c03fd795fc86ac",
+            "hypervisor":"VMware",
+            "ostypeid":"74affaea-c658-11e4-ad38-a6d1374244b4"
+        },
+        "QCOW2": {
+            "templatename": "KVMUploadtemplate",
+            "displaytext": "VMwareUploadtemplate",
+            "url": "http://people.apache.org/~sanjeev/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2",
+            "checksum": "da997b697feaa2f1f6e0d4785b0cece2",
+            "hypervisor":"KVM",
+            "ostypeid":"2e02e376-cdf3-11e4-beb3-8aa6272b57ef"
+        },
+    },
+    "configurableData":
+        {
+            "portableIpRange": {
+                "gateway": "10.223.59.1",
+                "netmask": "255.255.255.0",
+                "startip": "10.223.59.200",
+                "endip": "10.223.59.240",
+                "vlan": "1000"
+            },
+            "netscaler": {
+                "ipaddress": "",
+                "username": "",
+                "password": "",
+                "networkdevicetype": "",
+                "publicinterface": "",
+                "privateinterface": "",
+                "numretries": "",
+                "lbdevicededicated": "False",
+                "lbdevicecapacity": 2,
+                "port": 22
+            },
+            "iscsi": {
+                "url": "",
+                "name": "Primary iSCSI"
+            },
+            "host": {
+                "publicport": 22,
+                "username": "root",
+                "password": "password",
+            },
+            "ldap_account": {
+                "email": "",
+                "firstname": "",
+                "lastname": "",
+                "username": "",
+                "password": "",
+            },
+            "link_ldap_details": {
+                "domain_name": "",
+                "accounttype": "",
+                "name": "",
+                "type": "",
+                "admin": "",
+                "linkLdapUsername": "",
+                "linkLdapPassword": "",
+                "linkLdapNestedUser": "",
+                "linkLdapNestedPassword": ""
+
+            },
+            "ldap_configuration": {
+                "basedn": "",
+                "emailAttribute": "",
+                "userObject": "",
+                "usernameAttribute": "",
+                "hostname": "",
+                "port": "",
+                "ldapUsername": "",
+                "ldapPassword": ""
+            },
+            "systemVmDelay": 120,
+            "setUsageConfigurationThroughTestCase": True,
+            "vmware_cluster": {
+                "hypervisor": 'VMware',
+                "clustertype": 'ExternalManaged',
+                "username": '',
+                "password": '',
+                "url": '',
+                "clustername": 'VMWare Cluster with Space in DC name',
+            },
+            "upload_volume": {
+                "diskname": "UploadVol",
+                "format": "VHD",
+                "url": "http://download.cloudstack.org/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
+                "checksum": "",
+            },
+            "bootableIso":
+                {
+                    "displaytext": "Test Bootable ISO",
+                    "name": "testISO",
+                    "bootable": True,
+                    "ispublic": False,
+                    "url": "http://people.apache.org/~sanjeev/CentOS-6.3-x86_64-bin-DVD1.iso",
+                    "ostype": 'CentOS 6.3 (64-bit)',
+                    "mode": 'HTTP_DOWNLOAD'
+                },
+            "setHostConfigurationForIngressRule": False,
+            "restartManagementServerThroughTestCase": False,
+            "vmxnet3template": {
+                "displaytext": "VMXNET3 Template",
+                "name": "VMXNET3 template",
+                "ostype": "CentOS 5.6 (64-bit)",
+                "isfeatured": True,
+                "ispublic": False,
+                "isextractable": True,
+                "mode": "HTTP_DOWNLOAD",
+                "templatefilter": "self",
+                "url": "http://people.apache.org/~sanjeev/systemvm64template-2014-09-30-4.3-vmware.ova",
+                "hypervisor": "vmware",
+                "format": "OVA",
+                "nicadapter": "vmxnet3",
+                "kvm": {
+                    "url": ""
+                },
+                "vmware": {
+                    "url": ""
+                },
+                "xenserver": {
+                    "url": ""
+                },
+                "hyperv": {
+                    "url": ""
+                },
+                "ostype": 'CentOS 5.3 (64-bit)',
+                "mode": 'HTTP_DOWNLOAD'
+            }
+        },
+    # Nuage VSP SDN plugin specific test data
+    "nuagevsp": {
+        # Services supported by the Nuage VSP plugin for Isolated networks
+        "isolated_network_offering": {
+            "name": 'nuage_marvin',
+            "displaytext": 'nuage_marvin',
+            "guestiptype": 'Isolated',
+            "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns',
+            "traffictype": 'GUEST',
+            "availability": 'Optional',
+            "serviceProviderList": {
+                "Dhcp": 'NuageVsp',
+                "StaticNat": 'NuageVsp',
+                "SourceNat": 'NuageVsp',
+                "Firewall": 'NuageVsp',
+                "Connectivity": 'NuageVsp',
+                "UserData": 'VirtualRouter',
+                "Dns": 'VirtualRouter'
+            },
+            "serviceCapabilityList": {
+                "SourceNat": {"SupportedSourceNatTypes": "perzone"}
+            }
+        },
+        # Services supported by the Nuage VSP plugin for VPC networks
+        "vpc_network_offering": {
+            "name": 'nuage_vpc_marvin',
+            "displaytext": 'nuage_vpc_marvin',
+            "guestiptype": 'Isolated',
+            "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
+            "traffictype": 'GUEST',
+            "availability": 'Optional',
+            "useVpc": 'on',
+            "ispersistent": 'True',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter",
+                "Dns": "VpcVirtualRouter"
+            },
+            "serviceCapabilityList": {
+                "SourceNat": {"SupportedSourceNatTypes": "perzone"}
+            }
+        },
+        "vpc_network_offering_internal_lb": {
+            "name": "nuage_vpc_marvin_internal_lb",
+            "displaytext": "nuage_vpc_marvin_internal_lb",
+            "guestiptype": 'Isolated',
+            "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
+            "traffictype": 'GUEST',
+            "availability": 'Optional',
+            "useVpc": 'on',
+            "ispersistent": 'True',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Lb": "InternalLbVm",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter",
+                "Dns": "VpcVirtualRouter"
+            },
+            "serviceCapabilityList": {
+                "SourceNat": {"SupportedSourceNatTypes": "perzone"},
+                "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+            }
+        },
+        # Services supported by the Nuage VSP plugin for VPCs
+        "vpc_offering": {
+            "name": 'Nuage VSP VPC offering',
+            "displaytext": 'Nuage VSP VPC offering',
+            "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter",
+                "Dns": "VpcVirtualRouter"
+            }
+        },
+        "vpc_offering_lb": {
+            "name": 'Nuage VSP VPC offering with Lb',
+            "displaytext": 'Nuage VSP VPC offering with Lb',
+            "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Lb": "InternalLbVm",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter",
+                "Dns": "VpcVirtualRouter"
+            }
+        },
+        "shared_nuage_network_offering": {
+            "name": 'nuage_marvin',
+            "displaytext": 'nuage_marvin',
+            "guestiptype": 'shared',
+            "supportedservices": 'Dhcp,Connectivity',
+            "traffictype": 'GUEST',
+            "specifyVlan": "False",
+            "specifyIpRanges": "True",
+            "availability": 'Optional',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Connectivity": "NuageVsp"
+            }
+        },
+        "shared_nuage_public_network_offering": {
+            "name": 'nuage_marvin',
+            "displaytext": 'nuage_marvin',
+            "guestiptype": 'shared',
+            "supportedservices": 'Dhcp,Connectivity',
+            "traffictype": 'GUEST',
+            "specifyVlan": "False",
+            "specifyIpRanges": "True",
+            "availability": 'Optional',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Connectivity": "NuageVsp"
+            },
+            "serviceCapabilityList": {
+                "Connectivity": {
+                    "PublicAccess": "true"
+                }
+            }
+
+        },
+        # Test data for Shared Network creation
+        "network_all": {
+            "name": "SharedNetwork-All-nuage",
+            "displaytext": "SharedNetwork-All-nuage",
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.21",
+            "endip": "10.223.1.100",
+            "acltype": "Domain"
+        },
+        "network_domain_with_no_subdomain_access": {
+            "name": "SharedNetwork-Domain-nosubdomain-nuage",
+            "displaytext": "SharedNetwork-Domain-nosubdomain-nuage",
+            "gateway": "10.222.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.222.1.2",
+            "endip": "10.222.1.100",
+            "acltype": "Domain",
+            "subdomainaccess": "false"
+        },
+        "network_domain_with_subdomain_access": {
+            "name": "SharedNetwork-Domain-withsubdomain-nuage",
+            "displaytext": "SharedNetwork-Domain-withsubdomain-nuage",
+            "gateway": "10.221.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.221.1.2",
+            "endip": "10.221.1.100",
+            "acltype": "Domain",
+            "subdomainaccess": "true"
+        },
+        "network_account": {
+            "name": "SharedNetwork-Account-nuage",
+            "displaytext": "SharedNetwork-Account-nuage",
+            "gateway": "10.220.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.220.1.2",
+            "endip": "10.220.1.100",
+            "acltype": "Account"
+        },
+        "publiciprange1": {
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.101",
+            "endip": "10.223.1.105",
+            "forvirtualnetwork": "false"
+        },
+        "publiciprange2": {
+            "gateway": "10.219.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.219.1.2",
+            "endip": "10.219.1.5",
+            "forvirtualnetwork": "false"
+        },
+        "publiciprange3": {
+            "gateway": "10.223.1.1",
+            "netmask": "255.255.255.0",
+            "startip": "10.223.1.2",
+            "endip": "10.223.1.20",
+            "forvirtualnetwork": "false"
+        }
+    }
+}
diff --git a/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py b/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py
new file mode 100644
index 00000000000..f4fcde84dba
--- /dev/null
+++ b/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py
@@ -0,0 +1,202 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+import jpype
+from jpype import *
+from jpype import java
+from jpype import javax
+
+J_STRING = "java.lang.String"
+
+
+class VsdDataCollector:
+    def __init__(self, name, host="localhost", port=1099, debug=False,
+                 output_channel=None):
+        self.jmx = ConnectionJmx(host, port, debug, output_channel)
+        self.jmx.create_management_object(name=name)
+        self.saved_stats = None
+        self.saved_vsd_calls = 0
+
+    def start_test(self):
+        self.saved_stats = self.jmx.get_attribute("VsdStatisticsReport")
+        self.saved_vsd_calls = self.jmx.get_attribute("VSDStatistics")
+        return
+
+    def end_test(self):
+        self.jmx.print_rapport(old_stats=self.saved_stats,
+                               old_vsd_count=self.saved_vsd_calls)
+        return
+
+
+class ConnectionJmx:
+
+    def __init__(self, host="localhost", port=1099, debug=False,
+                 output_channel=None):
+        self.host = host
+        self.port = port
+        self.url = "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi" % (host, port)
+        self.debug = debug
+        self.mbean = None
+        self.output_channel = output_channel
+        jpype.startJVM(jpype.get_default_jvm_path())
+        if debug:
+            self.__print_to_ouput_channel("JVM loaded")
+            self.__print_to_ouput_channel(jpype.get_default_jvm_path())
+
+        jmx_url = javax.management.remote.JMXServiceURL(self.url)
+        jmx_soc = javax.management.remote.JMXConnectorFactory.connect(
+            jmx_url, java.util.HashMap())
+        self.connection = jmx_soc.getMBeanServerConnection()
+        if self.debug:
+            self.__print_to_ouput_channel("Connection successful")
+
+    def __print_to_ouput_channel(self, text):
+        if self.output_channel:
+            self.output_channel.debug(text)
+        else:
+            print text
+
+    def create_management_object(self, domain="com.cloud",
+                                 type="NuageVspResource",
+                                 name="Nuage VSD - 0.0.0.0"):
+        if name is not None:
+            object_name = domain + ":type=" + type + ", name=" + name
+        else:
+            object_name = domain + ":" + type
+
+        if self.debug:
+            self.__print_to_ouput_channel(object_name)
+
+        self.mbean = javax.management.ObjectName(object_name)
+        return self.mbean
+
+    def get_vsd_statistics_by_request_and_entity_type(self,
+                                                      entity_type,
+                                                      request_type,
+                                                      mbean=None):
+        self._get_stats_by_entity_or_request_type(
+            mbean, [[entity_type, request_type]],
+            "getVsdStatisticsByEntityType")
+
+    def _jStringArray(self, elements):
+        return jpype.JArray(java.lang.String)(elements)
+
+    def get_vsd_statistics_by_request_type(self, request_type, mbean=None):
+        return self._get_stats_by_entity_or_request_type(
+            mbean, [request_type], "getVsdStatisticsByRequestType")
+
+    def get_vsd_statistics_by_entity_type(self, entity_type, mbean=None):
+        return self._get_stats_by_entity_or_request_type(
+            mbean, [entity_type], "getVsdStatisticsByEntityType")
+
+    def _get_stats_by_entity_or_request_type(self, vars, method, mbean=None):
+        if not mbean:
+            mbean = self.mbean
+        jarray = self._jStringArray(vars)
+        signature = self._jStringArray([J_STRING for _ in vars])
+        result = self.connection.invoke(mbean, method, jarray, signature)
+        if self.debug:
+            self.__print_to_ouput_channel(vars + ": " + str(result))
+        return result
+
+    def get_attribute(self, attribute, mbean=None):
+        if not mbean:
+            mbean = self.mbean
+
+        result = self.connection.getAttribute(mbean, attribute)
+        if self.debug:
+            self.__print_to_ouput_channel("Attribute " + attribute + ": " +
+                                          str(result))
+        return result
+
+    def print_rapport(self, mbean=None, old_stats=None, old_vsd_count=0):
+        if not mbean:
+            mbean = self.mbean
+        stat = self.get_attribute("VsdStatisticsReport", mbean)
+        number_of_vsd_calls = int(str(self.get_attribute("VSDStatistics",
+                                                         mbean)))
+        number_of_vsd_calls = number_of_vsd_calls - int(str(old_vsd_count))
+
+        self.__print_to_ouput_channel("\n================"
+                                      "RAPPORT:"
+                                      "================\n")
+        self.__print_to_ouput_channel("Total VSD calls: " +
+                                      str(number_of_vsd_calls))
+        self.__print_to_ouput_channel("For each Entity:\n")
+        self.__print_total_for_entity(stat, old_stats)
+        self.__print_to_ouput_channel("\nFor each Request:\n")
+        self.__print_total_per_request(stat, old_stats)
+        self.__print_to_ouput_channel("\nCombined:\n")
+        self.__print_total_per_entity_and_request(stat, old_stats)
+        self.__print_to_ouput_channel("\n============="
+                                      "END OF RAPPORT"
+                                      "=============")
+
+    def __print_total_per_request(self, stat, old_stat=None):
+        data = dict()
+
+        entries = ((entry.getKey(), entry.getValue().get())
+                   for requestmap in stat.values()
+                   for entry in requestmap.entrySet())
+
+        for request, value in entries:
+            if request in data:
+                data[request] += value
+            else:
+                data[request] = value
+
+        if old_stat:
+            old_entries = ((entry.getKey(), entry.getValue().get())
+                           for requestmap in old_stat.values()
+                           for entry in requestmap.entrySet())
+
+            for request, value in old_entries:
+                if request in data:
+                    data[request] -= value
+                else:
+                    data[request] = 0
+
+        for key, value in data.iteritems():
+            self.__print_to_ouput_channel(" " + str(key) + ": " + str(value))
+
+    def __print_total_per_entity_and_request(self, stat, old_stat=None):
+        for entity in stat:
+            self.__print_to_ouput_channel(entity + ":")
+            for request in stat[entity]:
+                previous = 0
+                if old_stat and old_stat[entity] and old_stat[entity][request]:
+                    previous = int(str(old_stat[entity][request]))
+
+                current = int(str(stat[entity][request]))
+
+                self.__print_to_ouput_channel(" " + str(request) + ":" +
+                                              str(current - previous))
+            self.__print_to_ouput_channel("--------------------"
+                                          "--------------------")
+
+    def __print_total_for_entity(self, stat, old_stat=None):
+        for entity in stat:
+            total = 0
+            for val in stat[entity]:
+                minus = 0
+                if old_stat and old_stat[entity] and old_stat[entity][val]:
+                    minus = int(str(old_stat[entity][val]))
+                total = str(stat[entity][val])
+
+                total = int(total) - minus
+            self.__print_to_ouput_channel(" " + str(entity) +
+                                          ": " + str(total))
diff --git a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
index 9e6cdde4dc9..ef4611f0a48 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
@@ -165,27 +165,28 @@ def verify_StaticNAT_traffic(self, network, public_ip, vpc=None,
                 time.sleep(60)
                 tries += 1
 
-        if not filename and not headers:
-            if non_default_nic:
-                self.debug("Failed to wget from VM via this NIC as it is not "
-                           "the default NIC")
-            else:
-                self.fail("Failed to wget from VM")
-
-        # Removing Ingress Firewall/Network ACL rule
-        self.debug("Removing the created Ingress Firewall/Network ACL "
-                   "rule in the network...")
-        public_http_rule.delete(self.api_client)
+        try:
+            if not filename and not headers:
+                if non_default_nic:
+                    self.debug("Failed to wget from VM via this NIC as it "
+                               "is not the default NIC")
+                else:
+                    self.fail("Failed to wget from VM")
+        finally:
+            # Removing Ingress Firewall/Network ACL rule
+            self.debug("Removing the created Ingress Firewall/Network ACL "
+                       "rule in the network...")
+            public_http_rule.delete(self.api_client)
 
-        # VSD verification
-        with self.assertRaises(Exception):
-            self.verify_vsd_firewall_rule(public_http_rule)
-        self.debug("Ingress Firewall/Network ACL rule successfully "
-                   "deleted in VSD")
+            # VSD verification
+            with self.assertRaises(Exception):
+                self.verify_vsd_firewall_rule(public_http_rule)
+            self.debug("Ingress Firewall/Network ACL rule successfully "
+                       "deleted in VSD")
 
-        self.debug("Successfully verified Static NAT traffic by performing "
-                   "wget traffic test with the given Static NAT enabled "
-                   "public IP - %s" % public_ip)
+            self.debug("Successfully verified Static NAT traffic by "
+                       "performing wget traffic test with the given Static "
+                       "NAT enabled public IP - %s" % public_ip)
 
     # wget_from_internet - From within the given VM (ssh client),
     # fetches index.html file of an Internet web server, wget www.google.com
@@ -240,30 +241,31 @@ def verify_StaticNAT_Internet_traffic(self, vm, network, public_ip,
 
         # SSH into VM
         ssh_client = None
-        if non_default_nic:
-            with self.assertRaises(Exception):
-                self.ssh_into_VM(vm, public_ip, negative_test=True)
-            self.debug("Can not SSH into the VM via this NIC as it is not the "
-                       "default NIC")
-        else:
-            ssh_client = self.ssh_into_VM(vm, public_ip)
-
-        # wget from Internet
-        test_result = None
-        if ssh_client and self.isInternetConnectivityAvailable:
-            timeout = 100 if negative_test else 300
-            test_result = self.wget_from_Internet(ssh_client, timeout)
-
-        # Removing Ingress Firewall/Network ACL rule
-        self.debug("Removing the created Ingress Firewall/Network ACL "
-                   "rule in the network...")
-        public_ssh_rule.delete(self.api_client)
+        try:
+            if non_default_nic:
+                with self.assertRaises(Exception):
+                    self.ssh_into_VM(vm, public_ip, negative_test=True)
+                self.debug("Can not SSH into the VM via this NIC as it is "
+                           "not the default NIC")
+            else:
+                ssh_client = self.ssh_into_VM(vm, public_ip)
+
+            # wget from Internet
+            test_result = None
+            if ssh_client and self.isInternetConnectivityAvailable:
+                timeout = 100 if negative_test else 300
+                test_result = self.wget_from_Internet(ssh_client, timeout)
+        finally:
+            # Removing Ingress Firewall/Network ACL rule
+            self.debug("Removing the created Ingress Firewall/Network ACL "
+                       "rule in the network...")
+            public_ssh_rule.delete(self.api_client)
 
-        # VSD verification
-        with self.assertRaises(Exception):
-            self.verify_vsd_firewall_rule(public_ssh_rule)
-        self.debug("Ingress Firewall/Network ACL rule successfully "
-                   "deleted in VSD")
+            # VSD verification
+            with self.assertRaises(Exception):
+                self.verify_vsd_firewall_rule(public_ssh_rule)
+            self.debug("Ingress Firewall/Network ACL rule successfully "
+                       "deleted in VSD")
 
         # Removing Egress Network ACL rule
         if vpc and self.http_proxy:
@@ -1579,7 +1581,7 @@ def test_08_nuage_StaticNAT_vm_nic_operations_traffic(self):
         self.verify_vsd_floating_ip(network_2, vm, public_ip_2.ipaddress)
 
         # Verifying Static NAT traffic
-        with self.assertRaises(Exception):
+        with self.assertRaises(AssertionError):
             self.verify_StaticNAT_traffic(network_1, public_ip_1)
         self.debug("Static NAT rule not enabled in this VM NIC")
         self.verify_StaticNAT_traffic(network_2, public_ip_2)
diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py
index 9b29e0c1bed..347d056c45f 100644
--- a/tools/marvin/setup.py
+++ b/tools/marvin/setup.py
@@ -57,7 +57,7 @@
           "ipmisim >= 0.7"
       ],
       extras_require={
-        "nuagevsp": ["libVSD", "PyYAML", "futures", "netaddr", "retries"]
+        "nuagevsp": ["libVSD", "PyYAML", "futures", "netaddr", "retries", "jpype1"]
       },
       py_modules=['marvin.marvinPlugin'],
       zip_safe=False,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Performance improvement: Caching of external id's
> -------------------------------------------------
>
>                 Key: CLOUDSTACK-10053
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10053
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: Network Devices
>    Affects Versions: 4.10.0.0
>         Environment: Nuage Vsp
>            Reporter: Frank Maximus
>            Assignee: Frank Maximus
>            Priority: Major
>             Fix For: 4.11.0.0
>
>
> Latest Nuage Vsp Client release 1.0.3 supports caching of the ids of the entities on VSD.
> We will store these external id's into the meta data of the networks and vpcs,
> and pass them to the client to improve performance.
> Also the latest client keeps track of the amount of API calls made to VSD,
> we will expose this information via JMX MBean.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


Mime
View raw message