diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 0916813bb8c..d0d676f2e1b 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -299,15 +299,19 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer if (guestTrafficLabel != null) { s_logger.info("Detected guest network label : " + guestTrafficLabel); } - vsmIp = _urlParams.get("vsmipaddress"); - String vsmUser = _urlParams.get("vsmusername"); - String vsmPassword = _urlParams.get("vsmpassword"); - String clusterName = cluster.getName(); - try { - vsmInfo = _nexusElement.validateAndAddVsm(vsmIp, vsmUser, vsmPassword, clusterId, clusterName); - } catch (ResourceInUseException ex) { - DiscoveryException discEx = new DiscoveryException(ex.getLocalizedMessage() + ". The resource is " + ex.getResourceName()); - throw discEx; + // Before proceeding with validation of Nexus 1000v VSM check if an instance of Nexus 1000v VSM is already associated with this cluster. + boolean clusterHasVsm = _vmwareMgr.hasNexusVSM(clusterId); + if (!clusterHasVsm) { + vsmIp = _urlParams.get("vsmipaddress"); + String vsmUser = _urlParams.get("vsmusername"); + String vsmPassword = _urlParams.get("vsmpassword"); + String clusterName = cluster.getName(); + try { + vsmInfo = _nexusElement.validateAndAddVsm(vsmIp, vsmUser, vsmPassword, clusterId, clusterName); + } catch (ResourceInUseException ex) { + DiscoveryException discEx = new DiscoveryException(ex.getLocalizedMessage() + ". The resource is " + ex.getResourceName()); + throw discEx; + } } vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId); } diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java index 27975eea8ea..35e275e004e 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java @@ -77,4 +77,6 @@ public interface VmwareManager { public int getVcenterSessionTimeout(); boolean isLegacyZone(long dcId); + + boolean hasNexusVSM(Long clusterId); } diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index 3fd1a9cd1b3..3121bfb1644 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@ -1218,4 +1218,19 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw // Returning list of VmwareDatacenterVO objects, in-line with future requirements, if any, like participation of multiple VMware DCs in a zone. return vmwareDcList; } + + @Override + public boolean hasNexusVSM(Long clusterId) { + ClusterVSMMapVO vsmMapVo = null; + + vsmMapVo = _vsmMapDao.findByClusterId(clusterId); + if (vsmMapVo == null) { + s_logger.info("There is no instance of Nexus 1000v VSM associated with this cluster [Id:" + clusterId + "] yet."); + return false; + } + else { + s_logger.info("An instance of Nexus 1000v VSM [Id:" + vsmMapVo.getVsmId() + "] associated with this cluster [Id:" + clusterId + "]"); + return true; + } + } }