cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [2/7] git commit: updated refs/heads/master to 95ae796
Date Wed, 18 Nov 2015 11:11:16 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
new file mode 100644
index 0000000..143a741
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
@@ -0,0 +1,40 @@
+//
+// 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.util;
+
+import com.cloud.network.Network;
+import com.cloud.network.manager.NuageVspManager;
+import com.cloud.offering.NetworkOffering;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
+public class NuageVspUtil {
+
+    public static String getPreConfiguredDomainTemplateName(ConfigurationDao configDao, Network network, NetworkOffering networkOffering) {
+        String configKey;
+        if (network.getVpcId() != null) {
+            configKey = NuageVspManager.NuageVspVpcDomainTemplateName.key();
+        } else if (networkOffering.getGuestType() == Network.GuestType.Shared) {
+            configKey = NuageVspManager.NuageVspSharedNetworkDomainTemplateName.key();
+        } else {
+            configKey = NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName.key();
+        }
+        return configDao.getValue(configKey);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/NuageVspPluginClientLoader.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/NuageVspPluginClientLoader.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/NuageVspPluginClientLoader.java
index 76b9823..57935b9 100644
--- a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/NuageVspPluginClientLoader.java
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/NuageVspPluginClientLoader.java
@@ -19,28 +19,101 @@
 
 package net.nuage.vsp.acs;
 
+import net.nuage.vsp.acs.client.NuageVspApiClient;
+import net.nuage.vsp.acs.client.NuageVspElementClient;
+import net.nuage.vsp.acs.client.NuageVspGuruClient;
+import net.nuage.vsp.acs.client.NuageVspManagerClient;
+import net.nuage.vsp.acs.client.NuageVspSyncClient;
+import org.apache.log4j.Logger;
+
+import javax.naming.ConfigurationException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 
 public class NuageVspPluginClientLoader {
 
-    private static NuageVspPluginClientLoader nuageVspPluginClientClassloader;
-    private ClassLoader loader = null;
+    private ClassLoader _loader = null;
+    private static final Logger s_logger = Logger.getLogger(NuageVspPluginClientLoader.class);
+
+    private NuageVspApiClient _nuageVspApiClient;
+    private NuageVspElementClient _nuageVspElementClient;
+    private NuageVspGuruClient _nuageVspGuruClient;
+    private NuageVspManagerClient _nuageVspManagerClient;
+    private NuageVspSyncClient _nuageVspSyncClient;
+
+    private static final String NUAGE_PLUGIN_CLIENT_JAR_FILE = "/usr/share/nuagevsp/lib/nuage-vsp-acs-client.jar";
+    private static final String NUAGE_VSP_API_CLIENT_IMPL = "net.nuage.vsp.acs.client.impl.NuageVspApiClientImpl";
+    private static final String NUAGE_VSP_SYNC_CLIENT_IMPL = "net.nuage.vsp.acs.client.impl.NuageVspSyncClientImpl";
+    private static final String NUAGE_VSP_ELEMENT_CLIENT_IMPL = "net.nuage.vsp.acs.client.impl.NuageVspElementClientImpl";
+    private static final String NUAGE_VSP_GURU_CLIENT_IMPL = "net.nuage.vsp.acs.client.impl.NuageVspGuruClientImpl";
+    private static final String NUAGE_VSP_MANAGER_CLIENT_IMPL = "net.nuage.vsp.acs.client.impl.NuageVspManagerClientImpl";
 
     private NuageVspPluginClientLoader(String nuagePluginClientJarLocation) {
         try {
-            loader = URLClassLoader.newInstance(new URL[] {new URL("jar:file:" + nuagePluginClientJarLocation + "!/")},
+            _loader = URLClassLoader.newInstance(new URL[] {new URL("jar:file:" + nuagePluginClientJarLocation + "!/")},
                     getClass().getClassLoader());
         } catch (MalformedURLException e) {
-            e.printStackTrace();
+            throw new IllegalArgumentException(e);
         }
     }
 
-    public static ClassLoader getClassLoader(String nuagePluginClientJarLocation) {
-        if (nuageVspPluginClientClassloader == null) {
-            nuageVspPluginClientClassloader = new NuageVspPluginClientLoader(nuagePluginClientJarLocation);
+    public static NuageVspPluginClientLoader getClientLoader(String relativePath, String[] cmsUserInfo, int numRetries, int retryInterval,
+            String nuageVspCmsId) throws ConfigurationException {
+        NuageVspPluginClientLoader nuageVspPluginClientClassloader = new NuageVspPluginClientLoader(NUAGE_PLUGIN_CLIENT_JAR_FILE);
+        nuageVspPluginClientClassloader.loadClasses(relativePath, cmsUserInfo, numRetries, retryInterval, nuageVspCmsId);
+        return nuageVspPluginClientClassloader;
+    }
+
+    private void loadClasses(String relativePath, String[] cmsUserInfo, int numRetries, int retryInterval, String nuageVspCmsId) throws ConfigurationException {
+        try {
+            Class<?> nuageVspApiClientClass = Class.forName(NUAGE_VSP_API_CLIENT_IMPL, true, _loader);
+            Class<?> nuageVspSyncClientClass = Class.forName(NUAGE_VSP_SYNC_CLIENT_IMPL, true, _loader);
+            Class<?> nuageVspGuruClientClass = Class.forName(NUAGE_VSP_GURU_CLIENT_IMPL, true, _loader);
+            Class<?> nuageVspElementClientClass = Class.forName(NUAGE_VSP_ELEMENT_CLIENT_IMPL, true, _loader);
+            Class<?> nuageVspManagerClientClass = Class.forName(NUAGE_VSP_MANAGER_CLIENT_IMPL, true, _loader);
+
+            //Instantiate the instances
+            _nuageVspApiClient = (NuageVspApiClient)nuageVspApiClientClass.newInstance();
+            _nuageVspApiClient.setNuageVspHost(relativePath, cmsUserInfo, numRetries, retryInterval, nuageVspCmsId);
+            _nuageVspSyncClient = (NuageVspSyncClient)nuageVspSyncClientClass.newInstance();
+            _nuageVspSyncClient.setNuageVspApiClient(_nuageVspApiClient);
+            _nuageVspGuruClient = (NuageVspGuruClient)nuageVspGuruClientClass.newInstance();
+            _nuageVspGuruClient.setNuageVspApiClient(_nuageVspApiClient);
+            _nuageVspElementClient = (NuageVspElementClient)nuageVspElementClientClass.newInstance();
+            _nuageVspElementClient.setNuageVspApiClient(_nuageVspApiClient);
+            _nuageVspManagerClient = (NuageVspManagerClient)nuageVspManagerClientClass.newInstance();
+            _nuageVspManagerClient.setNuageVspApiClient(_nuageVspApiClient);
+        } catch (ClassNotFoundException cnfe) {
+            s_logger.error("Error while loading classes of Nuage VSP client", cnfe);
+            throw new ConfigurationException("Error while loading classes of Nuage VSP client");
+        } catch (InstantiationException ie) {
+            s_logger.error("Error while initializing classes of Nuage VSP client", ie);
+            throw new ConfigurationException("Error while initializing classes of Nuage VSP client");
+        } catch (IllegalAccessException iae) {
+            s_logger.error("Error while accessing classes of Nuage VSP client", iae);
+            throw new ConfigurationException("Error while accessing classes of Nuage VSP client");
         }
-        return nuageVspPluginClientClassloader.loader;
+
+    }
+
+    public NuageVspApiClient getNuageVspApiClient() {
+        return _nuageVspApiClient;
+    }
+
+    public NuageVspElementClient getNuageVspElementClient() {
+        return _nuageVspElementClient;
+    }
+
+    public NuageVspGuruClient getNuageVspGuruClient() {
+        return _nuageVspGuruClient;
+    }
+
+    public NuageVspManagerClient getNuageVspManagerClient() {
+        return _nuageVspManagerClient;
+    }
+
+    public NuageVspSyncClient getNuageVspSyncClient() {
+        return _nuageVspSyncClient;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspApiClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspApiClient.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspApiClient.java
index d584c6f..d80daf9 100644
--- a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspApiClient.java
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspApiClient.java
@@ -19,12 +19,14 @@
 
 package net.nuage.vsp.acs.client;
 
+import java.util.concurrent.ExecutionException;
+
 public interface NuageVspApiClient {
 
-    public void login() throws Exception;
+    void login() throws ExecutionException;
 
-    public void setNuageVspHost(String restRelativePath, String[] cmsUserInfo, int noofRetry, int retryInterval);
+    void setNuageVspHost(String restRelativePath, String[] cmsUserInfo, int noofRetry, int retryInterval, String nuageVspCmsId);
 
-    public String executeRestApi(String method, String resource, String resourceId, String childResource, Object entityDetails, String resourceFilter, String proxyUserUuid,
-            String proxyUserDomainuuid) throws Exception;
+    String executeRestApi(String method, String resource, String resourceId, String childResource, Object entityDetails, String resourceFilter, String proxyUserUuid,
+                                 String proxyUserDomainuuid) throws ExecutionException;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspElementClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspElementClient.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspElementClient.java
index 27c613b..acd4256 100644
--- a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspElementClient.java
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspElementClient.java
@@ -21,16 +21,22 @@ package net.nuage.vsp.acs.client;
 
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutionException;
 
 public interface NuageVspElementClient {
 
-    public void applyStaticNats(String networkDomainUuid, String vpcOrSubnetUuid, boolean isL3Network, List<Map<String, Object>> staticNatDetails) throws Exception;
+    boolean implement(long networkId, String networkDomainUuid, String networkUuid, String networkName, String vpcOrSubnetUuid, boolean isL2Network, boolean isL3Network,
+                             boolean isVpc, boolean isShared, String domainTemplateName, boolean isFirewallServiceSupported, List<String> dnsServers, List<Map<String, Object>> ingressFirewallRules,
+                             List<Map<String, Object>> egressFirewallRules, List<String> acsFipUuid, boolean egressDefaultPolicy) throws ExecutionException;
 
-    public void applyAclRules(String networkUuid, String networkDomainUuid, String vpcOrSubnetUuid, boolean isL3Network, List<Map<String, Object>> aclRules, boolean isVpc, long networkId)
-            throws Exception;
+    void applyStaticNats(String networkDomainUuid, String networkUuid, String vpcOrSubnetUuid, boolean isL3Network, boolean isVpc,
+                                List<Map<String, Object>> staticNatDetails) throws ExecutionException;
 
-    public void shutDownVpc(String domainUuid, String vpcUuid) throws Exception;
+    void applyAclRules(boolean isNetworkAcl, String networkUuid, String networkDomainUuid, String vpcOrSubnetUuid, String networkName, boolean isL2Network,
+                              List<Map<String, Object>> rules, long networkId, boolean egressDefaultPolicy, Boolean isAcsIngressAcl, boolean networkReset, String domainTemplateName) throws ExecutionException;
 
-    public <C extends NuageVspApiClient> void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
+    void shutdownVpc(String domainUuid, String vpcUuid, String domainTemplateName) throws ExecutionException;
+
+    <C extends NuageVspApiClient> void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspGuruClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspGuruClient.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspGuruClient.java
index 3c7f33d..2b3a63a 100644
--- a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspGuruClient.java
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspGuruClient.java
@@ -21,24 +21,23 @@ package net.nuage.vsp.acs.client;
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
+import java.util.concurrent.ExecutionException;
 
 public interface NuageVspGuruClient {
 
-    public void implement(String networkDomainName, String networkDomainPath, String networkDomainUuid, String networkAccountName, String networkAccountUuid, String networkName,
-            String networkCidr, String networkGateway, String networkUuid, boolean isL3Network, String vpcName, String vpcUuid, boolean defaultEgressPolicy,
-            Collection<String> ipAddressRange) throws Exception;
+    void implement(String networkDomainName, String networkDomainPath, String networkDomainUuid, String networkAccountName, String networkAccountUuid, String networkName,
+                          String networkCidr, String networkGateway, Long networkAclId, List<String> dnsServers, List<String> gatewaySystemIds, boolean isL3Network, boolean isVpc, boolean isSharedNetwork,
+                          String networkUuid, String vpcName, String vpcUuid, boolean defaultEgressPolicy, Collection<String[]> ipAddressRange, String domainTemplateName) throws ExecutionException;
 
-    public List<Map<String, String>> reserve(String nicUuid, String nicMacAddress, String networkUuid, boolean isL3Network, String vpcUuid, String networkDomainUuid,
-            String networksAccountUuid, boolean isDomainRouter, String domainRouterIp, String vmInstanceName, String vmUuid) throws Exception;
+    void reserve(String nicUuid, String nicMacAddress, String networkUuid, boolean isL3Network, boolean isSharedNetwork, String vpcUuid, String networkDomainUuid,
+                                             String networksAccountUuid, boolean isDomainRouter, String domainRouterIp, String vmInstanceName, String vmUuid, boolean useStaticIp, String staticIp, String staticNatIpUuid,
+                                             String staticNatIpAddress, boolean isStaticNatIpAllocated, boolean isOneToOneNat, String staticNatVlanUuid, String staticNatVlanGateway, String staticNatVlanNetmask) throws ExecutionException;
 
-    public void release(String networkUuid, String vmUuid, String vmInstanceName) throws Exception;
+    void deallocate(String networkUuid, String nicFrmDdUuid, String nicMacAddress, String nicIp4Address, boolean isL3Network, boolean isSharedNetwork,
+                           String vpcUuid, String networksDomainUuid, String vmInstanceName, String vmUuid, boolean isExpungingState) throws ExecutionException;
 
-    public void deallocate(String networkUuid, String nicFrmDdUuid, String nicMacAddress, String nicIp4Address, boolean isL3Network, String vpcUuid, String networksDomainUuid,
-            String vmInstanceName, String vmUuid) throws Exception;
+    void trash(String domainUuid, String networkUuid, boolean isL3Network, boolean isSharedNetwork, String vpcUuid, String domainTemplateName) throws ExecutionException;
 
-    public void trash(String domainUuid, String networkUuid, boolean isL3Network, String vpcUuid) throws Exception;
-
-    public void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
+    void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspManagerClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspManagerClient.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspManagerClient.java
new file mode 100644
index 0000000..f134111
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspManagerClient.java
@@ -0,0 +1,42 @@
+//
+// 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 net.nuage.vsp.acs.client;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+public interface NuageVspManagerClient {
+
+    Pair<Boolean, String> auditNuageVspCmsId(String nuageVspCmsId, boolean auditOnly) throws ExecutionException;
+
+    String registerNuageVspCmsId() throws ExecutionException;
+
+    boolean unregisterNuageVspCmsId(String nuageVspCmsId) throws ExecutionException;
+
+    boolean isSupportedApiVersion(String version);
+
+    Map<String, Object> getClientDefaults() throws ExecutionException;
+
+    boolean syncDomainWithNuageVsp(String domainUuid, String domainName, String domainPath, boolean add, boolean remove) throws ExecutionException;
+
+    <C extends NuageVspApiClient> void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspSyncClient.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspSyncClient.java b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspSyncClient.java
index b9400f1..951ee5a 100644
--- a/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspSyncClient.java
+++ b/plugins/network-elements/nuage-vsp/src/net/nuage/vsp/acs/client/NuageVspSyncClient.java
@@ -19,9 +19,11 @@
 
 package net.nuage.vsp.acs.client;
 
+import java.util.concurrent.ExecutionException;
+
 public interface NuageVspSyncClient {
 
-    public void syncWithNuageVsp(String nuageVspEntity) throws Exception;
+    void syncWithNuageVsp(String nuageVspEntity) throws ExecutionException;
 
-    public void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
+    void setNuageVspApiClient(NuageVspApiClient nuageVspApiClient);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/agent/api/CommandsTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/agent/api/CommandsTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/agent/api/CommandsTest.java
new file mode 100644
index 0000000..817ab7a
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/agent/api/CommandsTest.java
@@ -0,0 +1,151 @@
+//
+// 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;
+
+import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
+import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
+import com.cloud.agent.api.element.ImplementVspCommand;
+import com.cloud.agent.api.element.ShutDownVpcVspCommand;
+import com.cloud.agent.api.guru.DeallocateVmVspCommand;
+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.SupportedApiVersionCommand;
+import com.cloud.agent.api.sync.SyncDomainCommand;
+import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand;
+import com.cloud.agent.api.sync.SyncVspCommand;
+import com.google.common.collect.Maps;
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+public class CommandsTest {
+
+    @Test
+    public void testCommandEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException {
+        ApplyAclRuleVspCommand applyAclRuleVspCommand = fillBuilderObject(new ApplyAclRuleVspCommand.Builder()).build();
+        ApplyAclRuleVspCommand otherApplyAclRuleVspCommand = fillBuilderObject(new ApplyAclRuleVspCommand.Builder()).build();
+
+        ApplyStaticNatVspCommand applyStaticNatVspCommand = fillBuilderObject(new ApplyStaticNatVspCommand.Builder()).build();
+        ApplyStaticNatVspCommand otherApplyStaticNatVspCommand = fillBuilderObject(new ApplyStaticNatVspCommand.Builder()).build();
+
+        ImplementVspCommand implementVspCommand = fillBuilderObject(new ImplementVspCommand.Builder()).build();
+        ImplementVspCommand otherImplementVspCommand = fillBuilderObject(new ImplementVspCommand.Builder()).build();
+
+        ShutDownVpcVspCommand shutDownVpcVspCommand = fillBuilderObject(new ShutDownVpcVspCommand.Builder()).build();
+        ShutDownVpcVspCommand otherShutDownVpcVspCommand = fillBuilderObject(new ShutDownVpcVspCommand.Builder()).build();
+
+        DeallocateVmVspCommand deallocateVmVspCommand = fillBuilderObject(new DeallocateVmVspCommand.Builder()).build();
+        DeallocateVmVspCommand otherDeallocateVmVspCommand = fillBuilderObject(new DeallocateVmVspCommand.Builder()).build();
+
+        ImplementNetworkVspCommand implementNetworkVspCommand = fillBuilderObject(new ImplementNetworkVspCommand.Builder()).build();
+        ImplementNetworkVspCommand otherImplementNetworkVspCommand = fillBuilderObject(new ImplementNetworkVspCommand.Builder()).build();
+
+        ReserveVmInterfaceVspCommand reserveVmInterfaceVspCommand = fillBuilderObject(new ReserveVmInterfaceVspCommand.Builder()).build();
+        ReserveVmInterfaceVspCommand otherReserveVmInterfaceVspCommand = fillBuilderObject(new ReserveVmInterfaceVspCommand.Builder()).build();
+
+        TrashNetworkVspCommand trashNetworkVspCommand = fillBuilderObject(new TrashNetworkVspCommand.Builder()).build();
+        TrashNetworkVspCommand otherTrashNetworkVspCommand  = fillBuilderObject(new TrashNetworkVspCommand.Builder()).build();
+
+        SupportedApiVersionCommand supportedApiVersionCommand = new SupportedApiVersionCommand("3.2");
+        SupportedApiVersionCommand otherSupportedApiVersionCommand = new SupportedApiVersionCommand("3.2");
+
+        SyncDomainCommand syncDomainCommand = fillObject(SyncDomainCommand.class);
+        SyncDomainCommand otherSyncDomainCommand = fillObject(SyncDomainCommand.class);
+
+        SyncNuageVspCmsIdCommand syncNuageVspCmsIdCommand = fillObject(SyncNuageVspCmsIdCommand.class);
+        SyncNuageVspCmsIdCommand otherSyncNuageVspCmsIdCommand = fillObject(SyncNuageVspCmsIdCommand.class);
+
+        SyncVspCommand syncVspCommand = fillObject(SyncVspCommand.class);
+        SyncVspCommand otherSyncVspCommand = fillObject(SyncVspCommand.class);
+
+        PingNuageVspCommand pingNuageVspCommand = fillObject(PingNuageVspCommand.class);
+        PingNuageVspCommand otherPingNuageVspCommand = fillObject(PingNuageVspCommand.class);
+
+        VspResourceCommand vspResourceCommand = fillObject(VspResourceCommand.class);
+        VspResourceCommand otherVspResourceCommand = fillObject(VspResourceCommand.class);
+
+        new EqualsTester()
+                .addEqualityGroup(applyAclRuleVspCommand, otherApplyAclRuleVspCommand)
+                .addEqualityGroup(applyStaticNatVspCommand, otherApplyStaticNatVspCommand)
+                .addEqualityGroup(implementVspCommand, otherImplementVspCommand)
+                .addEqualityGroup(shutDownVpcVspCommand, otherShutDownVpcVspCommand)
+                .addEqualityGroup(deallocateVmVspCommand, otherDeallocateVmVspCommand)
+                .addEqualityGroup(implementNetworkVspCommand, otherImplementNetworkVspCommand)
+                .addEqualityGroup(reserveVmInterfaceVspCommand, otherReserveVmInterfaceVspCommand)
+                .addEqualityGroup(trashNetworkVspCommand, otherTrashNetworkVspCommand)
+                .addEqualityGroup(supportedApiVersionCommand, otherSupportedApiVersionCommand)
+                .addEqualityGroup(syncDomainCommand, otherSyncDomainCommand)
+                .addEqualityGroup(syncNuageVspCmsIdCommand, otherSyncNuageVspCmsIdCommand)
+                .addEqualityGroup(syncVspCommand, otherSyncVspCommand)
+                .addEqualityGroup(pingNuageVspCommand, otherPingNuageVspCommand)
+                .addEqualityGroup(vspResourceCommand, otherVspResourceCommand)
+                .testEquals();
+    }
+
+    private <T extends CmdBuilder> T fillBuilderObject(T obj) throws IllegalAccessException, InvocationTargetException {
+        Class clazz = obj.getClass();
+        for (Method method : clazz.getDeclaredMethods()) {
+            if (method.getParameterTypes().length == 1) {
+                Class paramType = method.getParameterTypes()[0];
+                if (isNumericType(paramType)) {
+                    if (Long.class.isAssignableFrom(paramType)) {
+                        method.invoke(obj, Long.valueOf(method.getName().length()));
+                    } else {
+                        method.invoke(obj, method.getName().length());
+                    }
+                } else if (String.class.isAssignableFrom(paramType)) {
+                    method.invoke(obj, method.getName());
+                } else if (Boolean.class.isAssignableFrom(paramType) || boolean.class.isAssignableFrom(paramType)) {
+                    method.invoke(obj, method.getName().length() % 2 == 0);
+                }
+            }
+        }
+        return obj;
+    }
+
+    private <T> T fillObject(Class<T> clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException {
+        Constructor constructor = clazz.getDeclaredConstructors()[0];
+        Object[] constructorArgs = new Object[constructor.getParameterTypes().length];
+        for (int i = 0; i < constructor.getParameterTypes().length; i++) {
+            Class constructorArgType = constructor.getParameterTypes()[i];
+            if (isNumericType(constructorArgType)) {
+                constructorArgs[i] = constructorArgType.getName().length();
+            } else if (String.class.isAssignableFrom(constructorArgType)) {
+                constructorArgs[i] = constructorArgType.getName();
+            } else if (Boolean.class.isAssignableFrom(constructorArgType) || boolean.class.isAssignableFrom(constructorArgType)) {
+                constructorArgs[i] = constructorArgType.getName().length() % 2 == 0;
+            } else if (Map.class.isAssignableFrom(constructorArgType)) {
+                constructorArgs[i] = Maps.newHashMap();
+            } else {
+                constructorArgs[i] = null;
+            }
+        }
+        return (T) constructor.newInstance(constructorArgs);
+    }
+
+    private boolean isNumericType(Class type) {
+        return Number.class.isAssignableFrom(type) || int.class.isAssignableFrom(type) || long.class.isAssignableFrom(type);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
index 08d685f..bbdf764 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
@@ -19,35 +19,10 @@
 
 package com.cloud.network.element;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
 import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
-import com.cloud.agent.api.element.ApplyAclRuleVspAnswer;
-import com.cloud.agent.api.element.ApplyStaticNatVspAnswer;
 import com.cloud.deploy.DeployDestination;
-import com.cloud.domain.Domain;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.exception.CloudException;
@@ -64,11 +39,20 @@ import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.NuageVspDeviceVO;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.dao.FirewallRulesDao;
+import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NuageVspDao;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
+import com.cloud.network.manager.NuageVspManager;
 import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.Vpc;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -76,6 +60,31 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.user.Account;
 import com.cloud.vm.ReservationContext;
+import com.google.common.collect.Lists;
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+
+import javax.naming.ConfigurationException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName;
+import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
+import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class NuageVspElementTest {
 
@@ -90,8 +99,13 @@ public class NuageVspElementTest {
     DomainDao domainDao = mock(DomainDao.class);
     NetworkOfferingDao ntwkOfferingDao = mock(NetworkOfferingDao.class);
     NetworkOfferingServiceMapDao ntwkOfferingSrvcDao = mock(NetworkOfferingServiceMapDao.class);
+    ConfigurationDao configDao = mock(ConfigurationDao.class);
+    NuageVspManager nuageVspManager = mock(NuageVspManager.class);
+    FirewallRulesDao firewallRulesDao = mock(FirewallRulesDao.class);
+    IPAddressDao ipAddressDao = mock(IPAddressDao.class);
+    PhysicalNetworkDao physNetDao = mock(PhysicalNetworkDao.class);
 
-    Answer<Object> genericAnswer = new Answer<Object>() {
+    org.mockito.stubbing.Answer<Object> genericAnswer = new org.mockito.stubbing.Answer<Object>() {
         public Object answer(InvocationOnMock invocation) {
             return null;
         }
@@ -108,15 +122,23 @@ public class NuageVspElementTest {
         element._ntwkOfferingSrvcDao = ntwkOfferingSrvcDao;
         element._domainDao = domainDao;
         element._ntwkOfferingDao = ntwkOfferingDao;
+        element._configDao = configDao;
+        element._nuageVspManager = nuageVspManager;
+        element._firewallRulesDao = firewallRulesDao;
+        element._ipAddressDao = ipAddressDao;
+        element._physicalNetworkDao = physNetDao;
 
         // Standard responses
         when(networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
+        when(configDao.getValue(NuageVspIsolatedNetworkDomainTemplateName.key())).thenReturn("IsolatedDomainTemplate");
+        when(configDao.getValue(NuageVspVpcDomainTemplateName.key())).thenReturn("VpcDomainTemplate");
+        when(configDao.getValue(NuageVspSharedNetworkDomainTemplateName.key())).thenReturn("SharedDomainTemplate");
 
         element.configure("NuageVspTestElement", Collections.<String, Object> emptyMap());
     }
 
     @Test
-    public void testCcanHandle() {
+    public void testCanHandle() {
         final Network net = mock(Network.class);
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
         when(net.getId()).thenReturn(NETWORK_ID);
@@ -150,7 +172,10 @@ public class NuageVspElementTest {
         final Network network = mock(Network.class);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
         when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getVpcId()).thenReturn(null);
         when(network.getBroadcastUri()).thenReturn(new URI(""));
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getDomainId()).thenReturn(NETWORK_ID);
         when(networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
         when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true);
 
@@ -161,14 +186,27 @@ public class NuageVspElementTest {
 
         DeployDestination deployDest = mock(DeployDestination.class);
 
-        final Domain dom = mock(Domain.class);
+        final DomainVO dom = mock(DomainVO.class);
         when(dom.getName()).thenReturn("domain");
+        when(domainDao.findById(NETWORK_ID)).thenReturn(dom);
         final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
         final ReservationContext context = mock(ReservationContext.class);
         when(context.getDomain()).thenReturn(dom);
         when(context.getAccount()).thenReturn(acc);
 
+        final HostVO host = mock(HostVO.class);
+        when(host.getId()).thenReturn(NETWORK_ID);
+        final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
+        when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
+        when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
+        when(hostDao.findById(NETWORK_ID)).thenReturn(host);
+
+        when(firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Ingress)).thenReturn(new ArrayList<FirewallRuleVO>());
+        when(firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Egress)).thenReturn(new ArrayList<FirewallRuleVO>());
+        when(ipAddressDao.listStaticNatPublicIps(NETWORK_ID)).thenReturn(new ArrayList<IPAddressVO>());
+        when(nuageVspManager.getDnsDetails(network)).thenReturn(new ArrayList<String>());
+
         assertTrue(element.implement(network, offering, deployDest, context));
     }
 
@@ -215,7 +253,7 @@ public class NuageVspElementTest {
         when(hostDao.findById(NETWORK_ID)).thenReturn(host);
 
         when(domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
-        final ApplyStaticNatVspAnswer answer = mock(ApplyStaticNatVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
         assertTrue(element.applyStaticNats(network, new ArrayList<StaticNat>()));
@@ -244,7 +282,7 @@ public class NuageVspElementTest {
 
         when(domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
 
-        final ApplyAclRuleVspAnswer answer = mock(ApplyAclRuleVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
         assertTrue(element.applyFWRules(network, new ArrayList<FirewallRule>()));
@@ -272,9 +310,44 @@ public class NuageVspElementTest {
         when(hostDao.findById(NETWORK_ID)).thenReturn(host);
 
         when(domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
-        final ApplyAclRuleVspAnswer answer = mock(ApplyAclRuleVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
         assertTrue(element.applyNetworkACLs(network, new ArrayList<NetworkACLItem>()));
     }
+
+    @Test
+    public void testShutdownVpc() throws Exception {
+        final Vpc vpc = mock(Vpc.class);
+        when(vpc.getUuid()).thenReturn("aaaaaa");
+        when(vpc.getState()).thenReturn(Vpc.State.Inactive);
+        when(vpc.getDomainId()).thenReturn(NETWORK_ID);
+        when(vpc.getZoneId()).thenReturn(NETWORK_ID);
+
+        final DomainVO dom = mock(DomainVO.class);
+        when(dom.getName()).thenReturn("domain");
+        when(domainDao.findById(NETWORK_ID)).thenReturn(dom);
+        final Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        final ReservationContext context = mock(ReservationContext.class);
+        when(context.getDomain()).thenReturn(dom);
+        when(context.getAccount()).thenReturn(acc);
+
+        PhysicalNetworkVO physNet = mock(PhysicalNetworkVO.class);
+        when(physNet.getIsolationMethods()).thenReturn(Lists.newArrayList(PhysicalNetwork.IsolationMethod.VSP.name()));
+        when(physNet.getId()).thenReturn(NETWORK_ID);
+        when(physNetDao.listByZone(NETWORK_ID)).thenReturn(Lists.newArrayList(physNet));
+
+        final HostVO host = mock(HostVO.class);
+        when(host.getId()).thenReturn(NETWORK_ID);
+        final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
+        when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
+        when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
+        when(hostDao.findById(NETWORK_ID)).thenReturn(host);
+
+        final Answer answer = mock(Answer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+        assertTrue(element.shutdownVpc(vpc, context));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
----------------------------------------------------------------------
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 f879f09..18c088f 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
@@ -19,29 +19,9 @@
 
 package com.cloud.network.guru;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
-import org.junit.Before;
-import org.junit.Test;
-
 import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
-import com.cloud.agent.api.guru.ImplementNetworkVspAnswer;
-import com.cloud.agent.api.guru.ReleaseVmVspAnswer;
-import com.cloud.agent.api.guru.ReserveVmInterfaceVspAnswer;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
@@ -63,11 +43,13 @@ import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.NuageVspDeviceVO;
+import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.dao.NuageVspDao;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkVO;
+import com.cloud.network.manager.NuageVspManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -79,9 +61,28 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName;
+import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
+import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class NuageVspGuestNetworkGuruTest {
     private static final long NETWORK_ID = 42L;
@@ -98,6 +99,9 @@ public class NuageVspGuestNetworkGuruTest {
     NuageVspDao nuageVspDao = mock(NuageVspDao.class);
     HostDao hostDao = mock(HostDao.class);
     NetworkDao networkDao = mock(NetworkDao.class);
+    ConfigurationDao configDao = mock(ConfigurationDao.class);
+    IPAddressDao ipAddressDao = mock(IPAddressDao.class);
+    NuageVspManager nuageVspManager = mock(NuageVspManager.class);
 
     NetworkDao netdao = mock(NetworkDao.class);
     NuageVspGuestNetworkGuru guru;
@@ -105,7 +109,7 @@ public class NuageVspGuestNetworkGuruTest {
     @Before
     public void setUp() {
         guru = new NuageVspGuestNetworkGuru();
-        ((GuestNetworkGuru)guru)._physicalNetworkDao = physnetdao;
+        guru._physicalNetworkDao = physnetdao;
         guru._physicalNetworkDao = physnetdao;
         guru._nuageVspDao = nuageVspDao;
         guru._dcDao = dcdao;
@@ -119,12 +123,19 @@ public class NuageVspGuestNetworkGuruTest {
         guru._domainDao = domainDao;
         guru._nicDao = nicDao;
         guru._ntwkOfferingDao = ntwkOfferDao;
+        guru._configDao = configDao;
+        guru._ipAddressDao = ipAddressDao;
+        guru._nuageVspManager = nuageVspManager;
 
         final DataCenterVO dc = mock(DataCenterVO.class);
         when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
         when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
 
         when(dcdao.findById((Long)any())).thenReturn(dc);
+
+        when(configDao.getValue(NuageVspIsolatedNetworkDomainTemplateName.key())).thenReturn("IsolatedDomainTemplate");
+        when(configDao.getValue(NuageVspVpcDomainTemplateName.key())).thenReturn("VpcDomainTemplate");
+        when(configDao.getValue(NuageVspSharedNetworkDomainTemplateName.key())).thenReturn("SharedDomainTemplate");
     }
 
     @Test
@@ -146,10 +157,10 @@ public class NuageVspGuestNetworkGuruTest {
         when(offering.getTrafficType()).thenReturn(TrafficType.Management);
         assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
 
-        // Not supported: GuestType Shared
+        // Supported: GuestType Shared
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Shared);
-        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
 
         // Not supported: Basic networking
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -236,7 +247,8 @@ public class NuageVspGuestNetworkGuruTest {
 
     @Test
     public void testReserve() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
-        final Network network = mock(Network.class);
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getId()).thenReturn(NETWORK_ID);
         when(network.getUuid()).thenReturn("aaaaaa");
         when(network.getDataCenterId()).thenReturn(NETWORK_ID);
         when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
@@ -262,10 +274,15 @@ public class NuageVspGuestNetworkGuruTest {
         when(nicvo.getUuid()).thenReturn("aaaa-fffff");
         when(nicDao.findById(NETWORK_ID)).thenReturn(nicvo);
 
-        final VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
+        final VirtualMachine vm = mock(VirtualMachine.class);
+        when(vm.getId()).thenReturn(NETWORK_ID);
         when(vm.getType()).thenReturn(VirtualMachine.Type.User);
-        when(vm.getInstanceName()).thenReturn("");
-        when(vm.getUuid()).thenReturn("aaaa-bbbbb");
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+        when(vmProfile.getType()).thenReturn(VirtualMachine.Type.User);
+        when(vmProfile.getInstanceName()).thenReturn("");
+        when(vmProfile.getUuid()).thenReturn("aaaa-bbbbb");
+        when(vmProfile.getVirtualMachine()).thenReturn(vm);
 
         NicProfile nicProfile = mock(NicProfile.class);
         when(nicProfile.getUuid()).thenReturn("aaa-bbbb");
@@ -283,51 +300,20 @@ public class NuageVspGuestNetworkGuruTest {
         when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
         when(hostDao.findById(NETWORK_ID)).thenReturn(host);
 
+        when(networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
+        when(ipAddressDao.findByVmIdAndNetworkId(NETWORK_ID, NETWORK_ID)).thenReturn(null);
         when(domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
-        final ReserveVmInterfaceVspAnswer answer = mock(ReserveVmInterfaceVspAnswer.class);
-        when(answer.getResult()).thenReturn(true);
-        when(answer.getInterfaceDetails()).thenReturn(new ArrayList<Map<String, String>>());
-        when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
-
-        guru.reserve(nicProfile, network, vm, mock(DeployDestination.class), mock(ReservationContext.class));
-    }
-
-    @Test
-    public void testRelease() {
-        final NicProfile nicProfile = mock(NicProfile.class);
-        when(nicProfile.getNetworkId()).thenReturn(NETWORK_ID);
-        final NetworkVO network = mock(NetworkVO.class);
-        when(network.getUuid()).thenReturn("aaaaaa-ffffff");
-        when(network.getName()).thenReturn("aaaaaa");
-        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
-        when(networkDao.findById(NETWORK_ID)).thenReturn(network);
-
-        final VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
-        when(vm.getType()).thenReturn(VirtualMachine.Type.User);
-        when(vm.getInstanceName()).thenReturn("");
-        when(vm.getUuid()).thenReturn("aaaa-bbbbb");
-
-        final VirtualMachine virtualMachine = mock(VirtualMachine.class);
-        when(vm.getVirtualMachine()).thenReturn(virtualMachine);
-        when(virtualMachine.getState()).thenReturn(State.Stopping);
-
-        final HostVO host = mock(HostVO.class);
-        when(host.getId()).thenReturn(NETWORK_ID);
-        final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
-        when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
-        when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
-        when(hostDao.findById(NETWORK_ID)).thenReturn(host);
 
-        final ReleaseVmVspAnswer answer = mock(ReleaseVmVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
-        guru.release(nicProfile, vm, "aaaaa-fffff");
+        guru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), mock(ReservationContext.class));
     }
 
     @Test
     public void testImplementNetwork() throws URISyntaxException, InsufficientVirtualNetworkCapacityException {
-        final Network network = mock(Network.class);
+        final NetworkVO network = mock(NetworkVO.class);
         when(network.getId()).thenReturn(NETWORK_ID);
         when(network.getUuid()).thenReturn("aaaaaa");
         when(network.getDataCenterId()).thenReturn(NETWORK_ID);
@@ -371,8 +357,11 @@ public class NuageVspGuestNetworkGuruTest {
         when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
         when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
         when(hostDao.findById(NETWORK_ID)).thenReturn(host);
+        when(networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
+        when(nuageVspManager.getDnsDetails(network)).thenReturn(new ArrayList<String>());
+        when(nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<String>());
 
-        final ImplementNetworkVspAnswer answer = mock(ImplementNetworkVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
@@ -383,4 +372,95 @@ public class NuageVspGuestNetworkGuruTest {
         guru.implement(network, offering, deployDest, reserveContext);
     }
 
+    @Test
+    public void testDeallocate() throws Exception {
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getUuid()).thenReturn("aaaaaa");
+        when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getVpcId()).thenReturn(null);
+        when(network.getDomainId()).thenReturn(NETWORK_ID);
+        when(networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
+
+        final NetworkOfferingVO offering = mock(NetworkOfferingVO.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(ntwkOfferDao.findById(NETWORK_ID)).thenReturn(offering);
+
+        final DomainVO domain = mock(DomainVO.class);
+        when(domain.getUuid()).thenReturn("aaaaaa");
+        when(domainDao.findById(NETWORK_ID)).thenReturn(domain);
+
+        final NicVO nic = mock(NicVO.class);
+        when(nic.getId()).thenReturn(NETWORK_ID);
+        when(nic.getIPv4Address()).thenReturn("10.10.10.10");
+        when(nic.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
+        when(nicDao.findById(NETWORK_ID)).thenReturn(nic);
+
+        final NicProfile nicProfile = mock(NicProfile.class);
+        when(nicProfile.getId()).thenReturn(NETWORK_ID);
+        when(nicProfile.getIPv4Address()).thenReturn("10.10.10.10");
+        when(nicProfile.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
+
+        final VirtualMachine vm = mock(VirtualMachine.class);
+        when(vm.getType()).thenReturn(VirtualMachine.Type.User);
+        when(vm.getState()).thenReturn(VirtualMachine.State.Expunging);
+
+        final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
+        when(vmProfile.getUuid()).thenReturn("aaaaaa");
+        when(vmProfile.getInstanceName()).thenReturn("Test-VM");
+        when(vmProfile.getVirtualMachine()).thenReturn(vm);
+
+        final HostVO host = mock(HostVO.class);
+        when(host.getId()).thenReturn(NETWORK_ID);
+        final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
+        when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
+        when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
+        when(hostDao.findById(NETWORK_ID)).thenReturn(host);
+
+        final Answer answer = mock(Answer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        guru.deallocate(network, nicProfile, vmProfile);
+    }
+
+    @Test
+    public void testTrash() throws Exception {
+        final NetworkVO network = mock(NetworkVO.class);
+        when(network.getId()).thenReturn(NETWORK_ID);
+        when(network.getUuid()).thenReturn("aaaaaa");
+        when(network.getName()).thenReturn("trash");
+        when(network.getDomainId()).thenReturn(NETWORK_ID);
+        when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
+        when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
+        when(network.getVpcId()).thenReturn(null);
+        when(networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
+
+        final NetworkOfferingVO offering = mock(NetworkOfferingVO.class);
+        when(offering.getId()).thenReturn(NETWORK_ID);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(ntwkOfferDao.findById(NETWORK_ID)).thenReturn(offering);
+
+        final DomainVO domain = mock(DomainVO.class);
+        when(domain.getUuid()).thenReturn("aaaaaa");
+        when(domainDao.findById(NETWORK_ID)).thenReturn(domain);
+
+        final HostVO host = mock(HostVO.class);
+        when(host.getId()).thenReturn(NETWORK_ID);
+        final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
+        when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
+        when(nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] {nuageVspDevice}));
+        when(hostDao.findById(NETWORK_ID)).thenReturn(host);
+        when(nuageVspManager.getDnsDetails(network)).thenReturn(new ArrayList<String>());
+        when(nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<String>());
+
+        final Answer answer = mock(Answer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
+        assertTrue(guru.trash(network, offering));
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/network/manager/NuageVspManagerTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/manager/NuageVspManagerTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/manager/NuageVspManagerTest.java
index a8bed6d..a29e3d7 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/manager/NuageVspManagerTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/manager/NuageVspManagerTest.java
@@ -19,16 +19,9 @@
 
 package com.cloud.network.manager;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-
-import javax.naming.ConfigurationException;
-
-import org.junit.Before;
-import org.junit.Test;
-
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer;
 import com.cloud.api.commands.DeleteNuageVspDeviceCmd;
 import com.cloud.api.commands.ListNuageVspDevicesCmd;
 import com.cloud.host.HostVO;
@@ -42,6 +35,18 @@ import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.resource.ResourceManager;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.ConfigurationException;
+import java.util.ArrayList;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class NuageVspManagerTest {
     private static final long NETWORK_ID = 42L;
@@ -53,6 +58,8 @@ public class NuageVspManagerTest {
     NuageVspDao nuageVspDao = mock(NuageVspDao.class);
     NetworkDao networkDao = mock(NetworkDao.class);
     HostDao hostDao = mock(HostDao.class);
+    AgentManager agentManager = mock(AgentManager.class);
+    ConfigurationDao configDao = mock(ConfigurationDao.class);
 
     NuageVspManagerImpl manager;
 
@@ -67,6 +74,8 @@ public class NuageVspManagerTest {
         manager._nuageVspDao = nuageVspDao;
         manager._networkDao = networkDao;
         manager._hostDao = hostDao;
+        manager._agentMgr = agentManager;
+        manager._configDao = configDao;
     }
 
     @Test
@@ -91,6 +100,14 @@ public class NuageVspManagerTest {
         final DeleteNuageVspDeviceCmd cmd = mock(DeleteNuageVspDeviceCmd.class);
         when(cmd.getNuageVspDeviceId()).thenReturn(NETWORK_ID);
 
+        ConfigurationVO cmsIdConfig = mock(ConfigurationVO.class);
+        when(cmsIdConfig.getValue()).thenReturn("1:1");
+        when(configDao.findByName("nuagevsp.cms.id")).thenReturn(cmsIdConfig);
+
+        final SyncNuageVspCmsIdAnswer answer = mock(SyncNuageVspCmsIdAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
+
         manager.deleteNuageVspDevice(cmd);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/network/resource/NuageVspResourceTest.java
----------------------------------------------------------------------
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 db359b6..770e13f 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
@@ -19,46 +19,35 @@
 
 package com.cloud.network.resource;
 
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.nuage.vsp.acs.client.NuageVspApiClient;
-import net.nuage.vsp.acs.client.NuageVspElementClient;
-import net.nuage.vsp.acs.client.NuageVspGuruClient;
-import net.nuage.vsp.acs.client.NuageVspSyncClient;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
+import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.element.ApplyAclRuleVspAnswer;
 import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
-import com.cloud.agent.api.element.ApplyStaticNatVspAnswer;
 import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
-import com.cloud.agent.api.element.ShutDownVpcVspAnswer;
 import com.cloud.agent.api.element.ShutDownVpcVspCommand;
-import com.cloud.agent.api.guru.DeallocateVmVspAnswer;
 import com.cloud.agent.api.guru.DeallocateVmVspCommand;
-import com.cloud.agent.api.guru.ImplementNetworkVspAnswer;
 import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
-import com.cloud.agent.api.guru.ReleaseVmVspAnswer;
-import com.cloud.agent.api.guru.ReleaseVmVspCommand;
-import com.cloud.agent.api.guru.ReserveVmInterfaceVspAnswer;
 import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
-import com.cloud.agent.api.guru.TrashNetworkVspAnswer;
 import com.cloud.agent.api.guru.TrashNetworkVspCommand;
-import com.cloud.agent.api.sync.SyncVspAnswer;
 import com.cloud.agent.api.sync.SyncVspCommand;
 import com.cloud.host.Host;
+import com.google.common.collect.Maps;
+import net.nuage.vsp.acs.client.NuageVspApiClient;
+import net.nuage.vsp.acs.client.NuageVspElementClient;
+import net.nuage.vsp.acs.client.NuageVspGuruClient;
+import net.nuage.vsp.acs.client.NuageVspSyncClient;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+
+import javax.naming.ConfigurationException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
 
 public class NuageVspResourceTest {
     NuageVspResource _resource;
@@ -66,9 +55,10 @@ public class NuageVspResourceTest {
     NuageVspElementClient _mockNuageVspElementClient = mock(NuageVspElementClient.class);
     NuageVspGuruClient _mockNuageVspGuruClient = mock(NuageVspGuruClient.class);
     NuageVspSyncClient _mockNuageVspSyncClient = mock(NuageVspSyncClient.class);
-    Map<String, Object> _parameters;
+    NuageVspResource.Configuration _resourceConfiguration;
+    Map<String, Object> _hostDetails;
 
-    Answer<Object> genericAnswer = new Answer<Object>() {
+    org.mockito.stubbing.Answer<Object> genericAnswer = new org.mockito.stubbing.Answer<Object>() {
         public Object answer(InvocationOnMock invocation) {
             return null;
         }
@@ -88,34 +78,36 @@ public class NuageVspResourceTest {
 
             }
 
-            protected void isNuageVspApiLoaded() throws Exception {
+            protected void isNuageVspApiLoaded() throws ConfigurationException {
             }
 
-            protected void isNuageVspGuruLoaded() throws Exception {
+            protected void isNuageVspGuruLoaded() throws ConfigurationException {
             }
 
-            protected void isNuageVspElementLoaded() throws Exception {
+            protected void isNuageVspElementLoaded() throws ConfigurationException {
             }
 
-            protected void isNuageVspSyncLoaded() throws Exception {
+            protected void isNuageVspSyncLoaded() throws ConfigurationException {
             }
 
-            protected void login() throws Exception {
+            protected void login() throws ConfigurationException {
             }
 
         };
 
-        _parameters = new HashMap<String, Object>();
-        _parameters.put("name", "nuagevsptestdevice");
-        _parameters.put("guid", "aaaaa-bbbbb-ccccc");
-        _parameters.put("zoneId", "blublub");
-        _parameters.put("hostname", "nuagevsd");
-        _parameters.put("cmsuser", "cmsuser");
-        _parameters.put("cmsuserpass", "cmsuserpass");
-        _parameters.put("port", "8443");
-        _parameters.put("apirelativepath", "nuage/api/v1_0");
-        _parameters.put("retrycount", "3");
-        _parameters.put("retryinterval", "3");
+        _resourceConfiguration = new NuageVspResource.Configuration()
+                .name("nuagevsptestdevice")
+                .guid("aaaaa-bbbbb-ccccc")
+                .zoneId("blublub")
+                .hostName("nuagevsd")
+                .cmsUser("cmsuser")
+                .cmsUserPassword("cmsuserpass")
+                .port("8443")
+                .apiVersion("v3_2")
+                .apiRelativePath("nuage/api/v3_2")
+                .retryCount("3")
+                .retryInterval("3");
+        _hostDetails = Maps.<String, Object>newHashMap(_resourceConfiguration.build());
     }
 
     @Test(expected = Exception.class)
@@ -125,7 +117,7 @@ public class NuageVspResourceTest {
 
     @Test
     public void resourceConfigure() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
         assertTrue("nuagevsptestdevice".equals(_resource.getName()));
         assertTrue(_resource.getType() == Host.Type.L2Networking);
@@ -133,7 +125,7 @@ public class NuageVspResourceTest {
 
     @Test
     public void testInitialization() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
         StartupCommand[] sc = _resource.initialize();
         assertTrue(sc.length == 1);
@@ -144,7 +136,7 @@ public class NuageVspResourceTest {
 
     @Test
     public void testPingCommandStatus() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
         PingCommand ping = _resource.getCurrentStatus(42);
         assertTrue(ping != null);
@@ -154,99 +146,102 @@ public class NuageVspResourceTest {
 
     @Test
     public void testImplementNetworkVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
-
-        ImplementNetworkVspCommand impNtwkCmd = new ImplementNetworkVspCommand("networkDomainName", "networkDomainPath", "networkDomainUuid", "networkAccountName",
-                "networkAccountUuid", "networkName", "networkCidr", "networkGateway", "networkUuid", true, "vpcName", "vpcUuid", true, new ArrayList<String>());
-        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).implement("networkDomainName", "networkDomainPath", "networkDomainUuid", "networkAccountName", "networkAccountUuid",
-                "networkName", "networkCidr", "networkGateway", "networkUuid", true, "vpcName", "vpcUuid", true, new ArrayList<String>());
-        ImplementNetworkVspAnswer implNtwkAns = (ImplementNetworkVspAnswer)_resource.executeRequest(impNtwkCmd);
+        _resource.configure("NuageVspResource", _hostDetails);
+
+        ImplementNetworkVspCommand.Builder cmdBuilder = new ImplementNetworkVspCommand.Builder().networkDomainName("networkDomainName").networkDomainPath("networkDomainPath")
+                .networkDomainUuid("networkDomainUuid").networkAccountName("networkAccountName").networkAccountUuid("networkAccountUuid").networkName("networkName")
+                .networkCidr("networkCidr").networkGateway("networkGateway").networkAclId(0L).dnsServers(new ArrayList<String>()).gatewaySystemIds(new ArrayList<String>())
+                .networkUuid("networkUuid").isL3Network(true).isVpc(true).isSharedNetwork(true).vpcName("vpcName").vpcUuid("vpcUuid").defaultEgressPolicy(true)
+                .ipAddressRange(new ArrayList<String[]>()).domainTemplateName("domainTemplateName");
+        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).implement("networkDomainName", "networkDomainPath", "networkDomainUuid", "networkAccountName",
+                "networkAccountUuid", "networkName", "networkCidr", "networkGateway", 0L, new ArrayList<String>(), new ArrayList<String>(), true, true, true, "networkUuid",
+                "vpcName", "vpcUuid", true, new ArrayList<String[]>(), "domainTemplateName");
+        com.cloud.agent.api.Answer implNtwkAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(implNtwkAns.getResult());
     }
 
     @Test
     public void testReserveVmInterfaceVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
-
-        ReserveVmInterfaceVspCommand rsrvVmInfCmd = new ReserveVmInterfaceVspCommand("nicUuid", "nicMacAddress", "networkUuid", true, "vpcUuid", "networkDomainUuid",
-                "networksAccountUuid", false, "domainRouterIp", "vmInstanceName", "vmUuid", "vmUserName", "vmUserDomainName");
-        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).reserve("nicUuid", "nicMacAddress", "networkUuid", true, "vpcUuid", "networkDomainUuid", "networksAccountUuid",
-                false, "domainRouterIp", "vmInstanceName", "vmUuid");
-        ReserveVmInterfaceVspAnswer rsrvVmInfAns = (ReserveVmInterfaceVspAnswer)_resource.executeRequest(rsrvVmInfCmd);
+        _resource.configure("NuageVspResource", _hostDetails);
+
+        ReserveVmInterfaceVspCommand.Builder cmdBuilder = new ReserveVmInterfaceVspCommand.Builder().nicUuid("nicUuid").nicMacAddress("nicMacAddress")
+                .networkUuid("networkUuid").isL3Network(true).isSharedNetwork(true).vpcUuid("vpcUuid").networkDomainUuid("networkDomainUuid")
+                .networksAccountUuid("networksAccountUuid").isDomainRouter(false).domainRouterIp("domainRouterIp").vmInstanceName("vmInstanceName").vmUuid("vmUuid")
+                .vmUserName("vmUserName").vmUserDomainName("vmUserDomainName").useStaticIp(true).staticIp("staticIp").staticNatIpUuid("staticNatIpUuid")
+                .staticNatIpAddress("staticNatIpAddress").isStaticNatIpAllocated(true).isOneToOneNat(true).staticNatVlanUuid("staticNatVlanUuid")
+                .staticNatVlanGateway("staticNatVlanGateway").staticNatVlanNetmask("staticNatVlanNetmask");
+        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).reserve("nicUuid", "nicMacAddress", "networkUuid", true, true, "vpcUuid", "networkDomainUuid",
+                "networksAccountUuid", false, "domainRouterIp", "vmInstanceName", "vmUuid", true, "staticIp", "staticNatIpUuid", "staticNatIpAddress",
+                true, true, "staticNatVlanUuid", "staticNatVlanGateway", "staticNatVlanNetmask");
+        Answer rsrvVmInfAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(rsrvVmInfAns.getResult());
     }
 
     @Test
-    public void testReleaseVmVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
-
-        ReleaseVmVspCommand releaseVmCmd = new ReleaseVmVspCommand("networkUuid", "vmUuid", "vmInstanceName");
-        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).release("networkUuid", "vmUuid", "vmInstanceName");
-        ReleaseVmVspAnswer releaseVmAns = (ReleaseVmVspAnswer)_resource.executeRequest(releaseVmCmd);
-        assertTrue(releaseVmAns.getResult());
-    }
-
-    @Test
     public void testDeallocateVmVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
-
-        DeallocateVmVspCommand dellocateVmCmd = new DeallocateVmVspCommand("networkUuid", "nicFrmDdUuid", "nicMacAddress", "nicIp4Address", true, "vpcUuid", "networksDomainUuid",
-                "vmInstanceName", "vmUuid");
-        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).deallocate("networkUuid", "nicFrmDdUuid", "nicMacAddress", "nicIp4Address", true, "vpcUuid", "networksDomainUuid",
-                "vmInstanceName", "vmUuid");
-        DeallocateVmVspAnswer dellocateVmAns = (DeallocateVmVspAnswer)_resource.executeRequest(dellocateVmCmd);
+        _resource.configure("NuageVspResource", _hostDetails);
+
+        DeallocateVmVspCommand.Builder cmdBuilder = new DeallocateVmVspCommand.Builder().networkUuid("networkUuid").nicFromDbUuid("nicFromDbUuid")
+                .nicMacAddress("nicMacAddress").nicIp4Address("nicIp4Address").isL3Network(true).isSharedNetwork(true).vpcUuid("vpcUuid")
+                .networksDomainUuid("networksDomainUuid").vmInstanceName("vmInstanceName").vmUuid("vmUuid").isExpungingState(true);
+        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).deallocate("networkUuid", "nicFrmDdUuid", "nicMacAddress", "nicIp4Address", true, true, "vpcUuid", "networksDomainUuid",
+                "vmInstanceName", "vmUuid", true);
+        Answer dellocateVmAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(dellocateVmAns.getResult());
     }
 
     @Test
     public void testTrashNetworkVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
-        TrashNetworkVspCommand trashNtwkCmd = new TrashNetworkVspCommand("domainUuid", "networkUuid", true, "vpcUuid");
-        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).trash("domainUuid", "networkUuid", true, "vpcUuid");
-        TrashNetworkVspAnswer trashNtwkAns = (TrashNetworkVspAnswer)_resource.executeRequest(trashNtwkCmd);
+        TrashNetworkVspCommand.Builder cmdBuilder = new TrashNetworkVspCommand.Builder().domainUuid("domainUuid").networkUuid("networkUuid")
+                .isL3Network(true).isSharedNetwork(true).vpcUuid("vpcUuid").domainTemplateName("domainTemplateName");
+        doAnswer(genericAnswer).when(_mockNuageVspGuruClient).trash("domainUuid", "networkUuid", true, true, "vpcUuid", "domainTemplateName");
+        Answer trashNtwkAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(trashNtwkAns.getResult());
     }
 
     @Test
     public void testApplyStaticNatVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
-        ApplyStaticNatVspCommand applyNatCmd = new ApplyStaticNatVspCommand("networkDomainUuid", "vpcOrSubnetUuid", true, new ArrayList<Map<String, Object>>());
-        doAnswer(genericAnswer).when(_mockNuageVspElementClient).applyStaticNats("networkDomainUuid", "vpcOrSubnetUuid", true, new ArrayList<Map<String, Object>>());
-        ApplyStaticNatVspAnswer applyNatAns = (ApplyStaticNatVspAnswer)_resource.executeRequest(applyNatCmd);
+        ApplyStaticNatVspCommand.Builder cmdBuilder = new ApplyStaticNatVspCommand.Builder().networkDomainUuid("networkDomainUuid").networkUuid("networkUuid")
+                .vpcOrSubnetUuid("vpcOrSubnetUuid").isL3Network(true).isVpc(true).staticNatDetails(new ArrayList<Map<String, Object>>());
+        doAnswer(genericAnswer).when(_mockNuageVspElementClient).applyStaticNats("networkDomainUuid", "networkUuid", "vpcOrSubnetUuid", true, true, new ArrayList<Map<String, Object>>());
+        Answer applyNatAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(applyNatAns.getResult());
     }
 
     @Test
     public void testApplyAclRuleVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
-
-        ApplyAclRuleVspCommand applyAclCmd = new ApplyAclRuleVspCommand("networkUuid", "networkDomainUuid", "vpcOrSubnetUuid", true, new ArrayList<Map<String, Object>>(), false,
-                100);
-        doAnswer(genericAnswer).when(_mockNuageVspElementClient).applyAclRules("networkUuid", "networkDomainUuid", "vpcOrSubnetUuid", true, new ArrayList<Map<String, Object>>(),
-                false, 100);
-        ApplyAclRuleVspAnswer applyAclAns = (ApplyAclRuleVspAnswer)_resource.executeRequest(applyAclCmd);
+        _resource.configure("NuageVspResource", _hostDetails);
+
+        ApplyAclRuleVspCommand.Builder cmdBuilder = new ApplyAclRuleVspCommand.Builder().networkAcl(true).networkUuid("networkUuid").networkDomainUuid("networkDomainUuid")
+                .vpcOrSubnetUuid("vpcOrSubnetUuid").networkName("networkName").isL2Network(true).aclRules(new ArrayList<Map<String, Object>>()).networkId(100)
+                .egressDefaultPolicy(false).acsIngressAcl(true).networkReset(true).domainTemplateName("domainTemplateName");
+        doAnswer(genericAnswer).when(_mockNuageVspElementClient).applyAclRules(true, "networkUuid", "networkDomainUuid", "vpcOrSubnetUuid", "networkName", true,
+        new ArrayList<Map<String, Object>>(), 100, false, true, true, "domainTemplateName");
+        Answer applyAclAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(applyAclAns.getResult());
     }
 
     @Test
     public void testShutDownVpcVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
-        ShutDownVpcVspCommand shutVpcCmd = new ShutDownVpcVspCommand("domainUuid", "vpcUuid");
-        doAnswer(genericAnswer).when(_mockNuageVspElementClient).shutDownVpc("domainUuid", "vpcUuid");
-        ShutDownVpcVspAnswer shutVpcAns = (ShutDownVpcVspAnswer)_resource.executeRequest(shutVpcCmd);
+        ShutDownVpcVspCommand.Builder cmdBuilder = new ShutDownVpcVspCommand.Builder().domainUuid("domainUuid").vpcUuid("vpcUuid").domainTemplateName("domainTemplateName");
+        doAnswer(genericAnswer).when(_mockNuageVspElementClient).shutdownVpc("domainUuid", "vpcUuid", "domainTemplateName");
+        Answer shutVpcAns = _resource.executeRequest(cmdBuilder.build());
         assertTrue(shutVpcAns.getResult());
     }
 
     @Test
     public void testSyncVspCommand() throws Exception {
-        _resource.configure("NuageVspResource", _parameters);
+        _resource.configure("NuageVspResource", _hostDetails);
 
         SyncVspCommand shutVpcCmd = new SyncVspCommand("nuageVspEntity");
         doAnswer(genericAnswer).when(_mockNuageVspSyncClient).syncWithNuageVsp("nuageVspEntity");
-        SyncVspAnswer shutVpcAns = (SyncVspAnswer)_resource.executeRequest(shutVpcCmd);
+        Answer shutVpcAns = _resource.executeRequest(shutVpcCmd);
         assertTrue(shutVpcAns.getResult());
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/plugins/network-elements/nuage-vsp/test/com/cloud/network/sync/NuageVspSyncTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/sync/NuageVspSyncTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/sync/NuageVspSyncTest.java
index f9e503d..23430d4 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/sync/NuageVspSyncTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/sync/NuageVspSyncTest.java
@@ -19,23 +19,22 @@
 
 package com.cloud.network.sync;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-
 import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
-import com.cloud.agent.api.sync.SyncVspAnswer;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.network.NuageVspDeviceVO;
 import com.cloud.network.dao.NuageVspDao;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class NuageVspSyncTest {
     private static final long NETWORK_ID = 42L;
@@ -64,7 +63,7 @@ public class NuageVspSyncTest {
         when(host.getId()).thenReturn(NETWORK_ID);
         when(hostDao.findById(NETWORK_ID)).thenReturn(host);
 
-        final SyncVspAnswer answer = mock(SyncVspAnswer.class);
+        final Answer answer = mock(Answer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 69e70e6..ccbc0b0 100644
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -4602,10 +4602,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     @Override
     public boolean isOfferingForVpc(final NetworkOffering offering) {
         final boolean vpcProvider = _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(), Provider.VPCVirtualRouter) ||
-                _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(), Provider.JuniperContrailVpcRouter) ||
-                _ntwkOffServiceMapDao.getDistinctProviders(offering.getId()).contains(Provider.NuageVsp.getName());
+                _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(), Provider.JuniperContrailVpcRouter);
+        final boolean nuageVpcProvider = _ntwkOffServiceMapDao.getDistinctProviders(offering.getId()).contains(Provider.NuageVsp.getName())
+                && offering.getIsPersistent();
 
-        return vpcProvider;
+        return vpcProvider || nuageVpcProvider;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/645f8758/server/src/com/cloud/network/guru/DirectNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index 9686f80..018ab90 100644
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -21,6 +21,7 @@ import java.util.List;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.log4j.Logger;
 
@@ -98,6 +99,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
     NicDao _nicDao;
     @Inject
     IpAddressManager _ipAddrMgr;
+    @Inject
+    NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
 
     private static final TrafficType[] TrafficTypes = {TrafficType.Guest};
 
@@ -118,7 +121,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
 
     protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
         // this guru handles only Guest networks in Advance zone with source nat service disabled
-        if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == GuestType.Shared) {
+        if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == GuestType.Shared
+                && !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NuageVsp)) {
             return true;
         } else {
             s_logger.trace("We only take care of Guest networks of type " + GuestType.Shared);


Mime
View raw message