From 67bfe23d284de00599bf7227250742158d8d2042 Mon Sep 17 00:00:00 2001 From: Sateesh Chodapuneedi Date: Wed, 16 May 2012 19:42:35 +0530 Subject: [PATCH] CS-9919 Support for Nexus Swiches (Cisco Vswitches) Avoid detection of public traffic label for basic zones. Check switch types along with global parameter for enabling a particular vmware vswitch types. Move credentials information into resource and load during resource configuration. Cleanup. Conflicts: server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java --- .../vmware/manager/VmwareManager.java | 2 -- .../vmware/resource/VmwareResource.java | 26 +++++++------------ .../hypervisor/vmware/VmwareManagerImpl.java | 17 ------------ .../vmware/VmwareServerDiscoverer.java | 16 +++++++++++- .../com/cloud/network/NetworkManagerImpl.java | 4 +-- 5 files changed, 26 insertions(+), 39 deletions(-) diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java index ade3c41081a..b2a24c2a32f 100755 --- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java +++ b/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java @@ -61,8 +61,6 @@ public interface VmwareManager { boolean beginExclusiveOperation(int timeOutSeconds); void endExclusiveOperation(); - Map getNexusVSMCredentials(String hostGuid); - boolean getNexusVSwitchGlobalParameter(); Map getNexusVSMCredentialsByClusterId(Long clusterId); diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 5a4d1ac3666..d1d3a81ccab 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -4032,16 +4032,20 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa VmwareHypervisorHost hostMo = this.getHyperHost(context); _hostName = hostMo.getHyperHostName(); - _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); - _publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); - _guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); + Map vsmCredentials; if (mgr.getNexusVSwitchGlobalParameter()) { - vsmCredentials = mgr.getNexusVSMCredentials(_guid); + vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster)); if (vsmCredentials != null) { s_logger.info("Stocking credentials while configuring resource."); context.registerStockObject("vsmcredentials", vsmCredentials); } + if (mgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) + _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); + if (mgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) + _publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); + if (mgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) + _guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); } } catch (Exception e) { @@ -4175,19 +4179,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } catch (Exception e) { s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e); throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress); - } - if(_nexusVSwitch) - { - VmwareManager mgr = _serviceContext.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); - Map nexusVSwitchCredentials = mgr.getNexusVSMCredentials(_guid); - if(nexusVSwitchCredentials != null) - { - _serviceContext.registerStockObject("vsmcredentials", nexusVSwitchCredentials); - //_serviceContext.registerStockObject("vsmip", nexusVSwitchCredentials.get("vsmip")); - //_serviceContext.registerStockObject("vsmusername", nexusVSwitchCredentials.get("vsmusername")); - //_serviceContext.registerStockObject("vsmpassword", nexusVSwitchCredentials.get("vsmpassword")); - } - } + } } return _serviceContext; } diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java index ac90fb8ba7a..01b4263f339 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java @@ -871,23 +871,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } } } - - @DB - public Map getNexusVSMCredentials(String hostGuid) { - s_logger.info("Reading credentials from DB."); - HostVO host = _hostDao.findByGuid(hostGuid); - Map vsmCredentials = null; - long clusterId; - if (host != null) { - clusterId = host.getClusterId(); - s_logger.info("cluster is : " + clusterId); - vsmCredentials = getNexusVSMCredentialsByClusterId(clusterId); - } - else { - s_logger.info("Found invalid host object for hostGuid : " + hostGuid); - } - return vsmCredentials; - } @Override @DB public boolean processAnswers(long agentId, long seq, Answer[] answers) { diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 803b64218f1..5ce2532b1f2 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -31,7 +31,10 @@ import com.cloud.alert.AlertManager; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; +import com.cloud.dc.DataCenter.NetworkType; +import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; +import com.cloud.dc.dao.DataCenterDao; import com.cloud.exception.DiscoveredWithErrorException; import com.cloud.exception.DiscoveryException; import com.cloud.host.HostVO; @@ -73,6 +76,9 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer @Inject VMTemplateDao _tmpltDao; @Inject ClusterDetailsDao _clusterDetailsDao; @Inject HostDao _hostDao; + @Inject + DataCenterDao _dcDao; + @Inject ResourceManager _resourceMgr; @Inject CiscoNexusVSMDeviceDao _nexusDao; @@ -118,13 +124,21 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer s_logger.info("Detected private network label : " + privateTrafficLabel); } } - if (_vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { + + DataCenterVO zone = _dcDao.findById(dcId); + NetworkType zoneType = zone.getNetworkType(); + + if (zoneType != NetworkType.Basic && _vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { // Get physical network label publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware); if (publicTrafficLabel != null) { s_logger.info("Detected public network label : " + publicTrafficLabel); } } + else { + s_logger.info("Skipping detection of public traffic label as zone type is Basic."); + } + if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { // Get physical network label guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 371dad2403e..96f9fda9018 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -6514,7 +6514,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } catch (Exception ex) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage()); + s_logger.debug("Failed to retrieve the default label for public traffic." + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to: " + ex.getMessage()); } } return null; @@ -6542,7 +6542,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } catch (Exception ex) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage()); + s_logger.debug("Failed to retrieve the default label for guest traffic." + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to: " + ex.getMessage()); } } return null;