diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java index f3d2b50191a..6506d7d0cef 100755 --- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java +++ b/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java @@ -65,12 +65,6 @@ public interface VmwareManager { Map getNexusVSMCredentialsByClusterId(Long clusterId); - String getPrivateVSwitchTypeGlobalParameter(); - - String getPublicVSwitchTypeGlobalParameter(); - - String getGuestVSwitchTypeGlobalParameter(); - String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType); String getPublicVSwitchName(long dcId, HypervisorType hypervisorType); diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 1de54a99ab1..b52d441a486 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -258,9 +258,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa protected String _privateNetworkVSwitchName; protected String _publicNetworkVSwitchName; protected String _guestNetworkVSwitchName; - protected VirtualSwitchType _privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; - protected VirtualSwitchType _publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; - protected VirtualSwitchType _guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; + protected VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch; protected boolean _nexusVSwitch = false; protected float _cpuOverprovisioningFactor = 1; @@ -4052,12 +4050,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa 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); + _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); + _publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); + _guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); } } catch (Exception e) { @@ -4103,31 +4098,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa value = params.get("vmware.use.nexus.vswitch").toString(); if(value != null && value.equalsIgnoreCase("true")) _nexusVSwitch = true; - - value = (String)params.get("private.network.vswitch.type"); - if(value != null && value.equalsIgnoreCase("standard")) - _privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; - else if(value != null && value.equalsIgnoreCase("nexus")) - _privateNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch; - else - _privateNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch; - - value = (String)params.get("public.network.vswitch.type"); - if(value != null && value.equalsIgnoreCase("standard")) - _publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; - else if(value != null && value.equalsIgnoreCase("nexus")) - _publicNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch; - else - _publicNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch; - - value = (String)params.get("guest.network.vswitch.type"); - if(value != null && value.equalsIgnoreCase("standard")) - _guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch; - else if(value != null && value.equalsIgnoreCase("nexus")) - _guestNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch; - else - _guestNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch; - + s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: " + _guestNetworkVSwitchName); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 984f2193cea..a151feabce1 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -243,9 +243,6 @@ public enum Config { VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null), VmwareGuestNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.guest.vswitch", null, "Specify the vSwitch on host for guest network", null), VmwareUseNexusVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.nexus.vswitch", "false", "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", null), - VmwarePrivateNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.private.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for private traffic", null), - VmwarePublicNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.public.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for public traffic", null), - VmwareGuestNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.guest.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for guest traffic", null), VmwareServiceConsole("Advanced", ManagementServer.class, String.class, "vmware.service.console", "Service Console", "Specify the service console network name(for ESX hosts)", null), VmwareManagementPortGroup("Advanced", ManagementServer.class, String.class, "vmware.management.portgroup", "Management Network", "Specify the management network name(for ESXi hosts)", null), VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null), diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java index ff4e4fbe450..8ff7633dd3a 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java @@ -130,9 +130,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis String _privateNetworkVSwitchName; String _publicNetworkVSwitchName; String _guestNetworkVSwitchName; - String _privateNetworkVSwitchType; - String _publicNetworkVSwitchType; - String _guestNetworkVSwitchType; boolean _nexusVSwitchActive; String _serviceConsoleName; String _managemetPortGroupName; @@ -229,41 +226,29 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } _privateNetworkVSwitchName = configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key()); - _privateNetworkVSwitchType = configDao.getValue(Config.VmwarePrivateNetworkVSwitchType.key()); - if(_privateNetworkVSwitchName == null) { - if(_privateNetworkVSwitchType == null || _privateNetworkVSwitchType.equalsIgnoreCase("standard")) { - _privateNetworkVSwitchName = "vSwitch0"; - } - else - { - _privateNetworkVSwitchName = "privateEthernetPortProfile"; - } + + if (_privateNetworkVSwitchName == null) { + _privateNetworkVSwitchName = "vSwitch0"; + } else { + _privateNetworkVSwitchName = "privateEthernetPortProfile"; } _publicNetworkVSwitchName = configDao.getValue(Config.VmwarePublicNetworkVSwitch.key()); - _publicNetworkVSwitchType = configDao.getValue(Config.VmwarePublicNetworkVSwitchType.key()); - if(_publicNetworkVSwitchName == null) { - if(_publicNetworkVSwitchType == null || _publicNetworkVSwitchType.equalsIgnoreCase("standard")) { - _publicNetworkVSwitchName = "vSwitch0"; - } - else - { - _publicNetworkVSwitchName = "publicEthernetPortProfile"; - } - } - _guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key()); - _guestNetworkVSwitchType = configDao.getValue(Config.VmwareGuestNetworkVSwitchType.key()); - if(_guestNetworkVSwitchName == null) { - if(_guestNetworkVSwitchType == null || _guestNetworkVSwitchType.equalsIgnoreCase("standard")) { - _guestNetworkVSwitchName = "vSwitch0"; - } - else - { - _guestNetworkVSwitchName = "guestEthernetPortProfile"; - } + if (_publicNetworkVSwitchName == null) { + _publicNetworkVSwitchName = "vSwitch0"; + } else { + _publicNetworkVSwitchName = "publicEthernetPortProfile"; } - + + _guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key()); + + if (_guestNetworkVSwitchName == null) { + _guestNetworkVSwitchName = "vSwitch0"; + } else { + _guestNetworkVSwitchName = "guestEthernetPortProfile"; + } + _serviceConsoleName = configDao.getValue(Config.VmwareServiceConsole.key()); if(_serviceConsoleName == null) { _serviceConsoleName = "Service Console"; @@ -363,18 +348,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis return _nexusVSwitchActive; } - public String getPrivateVSwitchTypeGlobalParameter() { - return _privateNetworkVSwitchType; - } - - public String getPublicVSwitchTypeGlobalParameter() { - return _publicNetworkVSwitchType; - } - - public String getGuestVSwitchTypeGlobalParameter() { - return _guestNetworkVSwitchType; - } - @Override public String composeWorkerName() { return UUID.randomUUID().toString().replace("-", ""); @@ -588,9 +561,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis params.put("private.network.vswitch.name", _privateNetworkVSwitchName); params.put("public.network.vswitch.name", _publicNetworkVSwitchName); params.put("guest.network.vswitch.name", _guestNetworkVSwitchName); - params.put("private.network.vswitch.type", _privateNetworkVSwitchType); - params.put("public.network.vswitch.type", _publicNetworkVSwitchType); - params.put("guest.network.vswitch.type", _guestNetworkVSwitchType); params.put("vmware.use.nexus.vswitch", _nexusVSwitchActive); params.put("service.console.name", _serviceConsoleName); params.put("management.portgroup.name", _managemetPortGroupName); diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 06796c3878f..65a10688608 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -122,27 +122,17 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer if (_vmwareMgr.getNexusVSwitchGlobalParameter()) { DataCenterVO zone = _dcDao.findById(dcId); NetworkType zoneType = zone.getNetworkType(); - - if (zoneType != NetworkType.Basic && _vmwareMgr.getPublicVSwitchTypeGlobalParameter() != null && _vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { - // Get physical network label + if (zoneType != NetworkType.Basic) { 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."); + // Get physical network label + guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); + if (guestTrafficLabel != null) { + s_logger.info("Detected guest network label : " + guestTrafficLabel); } - - if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter() != null && _vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { - // Get physical network label - guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); - if (guestTrafficLabel != null) { - s_logger.info("Detected guest network label : " + guestTrafficLabel); - } - } - - // Get credentials vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 57d58ce72e5..fd3a4721035 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -6434,8 +6434,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public String getDefaultPublicTrafficLabel(long dcId, HypervisorType hypervisorType) { try { - PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public); - PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Public); + PhysicalNetwork publicPhyNetwork = getOnePhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public); + PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(publicPhyNetwork.getId(), + TrafficType.Public); if (publicTraffic != null) { String label = null; switch (hypervisorType) { @@ -6462,8 +6463,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public String getDefaultGuestTrafficLabel(long dcId, HypervisorType hypervisorType) { try { - PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Guest); - PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Guest); + PhysicalNetwork guestPhyNetwork = getOnePhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Guest); + PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(guestPhyNetwork.getId(), + TrafficType.Guest); if (guestTraffic != null) { String label = null; switch (hypervisorType) { @@ -6486,4 +6488,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } return null; } + + private PhysicalNetwork getOnePhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) { + List networkList = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, trafficType); + + if (networkList.isEmpty()) { + throw new InvalidParameterValueException("Unable to find the default physical network with traffic=" + + trafficType + " in zone id=" + zoneId + ". "); + } + + if (networkList.size() > 1) { + s_logger.info("More than one physical networks exist in zone id=" + zoneId + " with traffic type=" + + trafficType + ". "); + } + + return networkList.get(0); + } }