mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CS-14956 Support for rate limiting policies in Nexus dvSwith feature for CloudStack
Removed global parameters that are not required. Cleanup. Reviewed-by: Devdeep
This commit is contained in:
		
							parent
							
								
									0e3bf8cabb
								
							
						
					
					
						commit
						4ad8845b28
					
				| @ -65,12 +65,6 @@ public interface VmwareManager { | ||||
| 
 | ||||
|     Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId); | ||||
| 
 | ||||
|     String getPrivateVSwitchTypeGlobalParameter(); | ||||
| 
 | ||||
|     String getPublicVSwitchTypeGlobalParameter(); | ||||
| 
 | ||||
|     String getGuestVSwitchTypeGlobalParameter(); | ||||
| 
 | ||||
|     String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType); | ||||
| 
 | ||||
|     String getPublicVSwitchName(long dcId, HypervisorType hypervisorType); | ||||
|  | ||||
| @ -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; | ||||
| @ -4053,11 +4051,8 @@ 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); | ||||
|             } | ||||
| 
 | ||||
| @ -4105,30 +4100,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa | ||||
|         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); | ||||
| 
 | ||||
|  | ||||
| @ -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), | ||||
|  | ||||
| @ -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,40 +226,28 @@ 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 | ||||
|         	{ | ||||
|         } 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 | ||||
|         	{ | ||||
|         } 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 | ||||
|         	{ | ||||
|         } else { | ||||
|             _guestNetworkVSwitchName = "guestEthernetPortProfile"; | ||||
|         } | ||||
|         } | ||||
| 
 | ||||
|         _serviceConsoleName = configDao.getValue(Config.VmwareServiceConsole.key()); | ||||
|         if(_serviceConsoleName == null) { | ||||
| @ -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("-", ""); | ||||
| @ -592,9 +565,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); | ||||
|  | ||||
| @ -127,27 +127,17 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer | ||||
| 
 | ||||
|             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."); | ||||
|             } | ||||
| 
 | ||||
|             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); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -6496,8 +6496,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) { | ||||
| @ -6524,8 +6525,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) { | ||||
| @ -6548,4 +6550,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     private PhysicalNetwork getOnePhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) { | ||||
|         List<PhysicalNetworkVO> 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); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user