Skip to content

Commit 4ad8845

Browse files
Sateesh ChodapuneediVijayendra Bhamidipati
authored andcommitted
CS-14956 Support for rate limiting policies in Nexus dvSwith feature for CloudStack
Removed global parameters that are not required. Cleanup. Reviewed-by: Devdeep
1 parent 0e3bf8c commit 4ad8845

File tree

6 files changed

+50
-110
lines changed

6 files changed

+50
-110
lines changed

core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, l
6565

6666
Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId);
6767

68-
String getPrivateVSwitchTypeGlobalParameter();
69-
70-
String getPublicVSwitchTypeGlobalParameter();
71-
72-
String getGuestVSwitchTypeGlobalParameter();
73-
7468
String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
7569

7670
String getPublicVSwitchName(long dcId, HypervisorType hypervisorType);

core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
258258
protected String _privateNetworkVSwitchName;
259259
protected String _publicNetworkVSwitchName;
260260
protected String _guestNetworkVSwitchName;
261-
protected VirtualSwitchType _privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
262-
protected VirtualSwitchType _publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
263-
protected VirtualSwitchType _guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
261+
protected VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
264262
protected boolean _nexusVSwitch = false;
265263

266264
protected float _cpuOverprovisioningFactor = 1;
@@ -4053,12 +4051,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
40534051
s_logger.info("Stocking credentials while configuring resource.");
40544052
context.registerStockObject("vsmcredentials", vsmCredentials);
40554053
}
4056-
if (mgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus"))
4057-
_privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
4058-
if (mgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus"))
4059-
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
4060-
if (mgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus"))
4061-
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
4054+
_privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
4055+
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
4056+
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
40624057
}
40634058

40644059
} catch (Exception e) {
@@ -4104,31 +4099,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
41044099
value = params.get("vmware.use.nexus.vswitch").toString();
41054100
if(value != null && value.equalsIgnoreCase("true"))
41064101
_nexusVSwitch = true;
4107-
4108-
value = (String)params.get("private.network.vswitch.type");
4109-
if(value != null && value.equalsIgnoreCase("standard"))
4110-
_privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4111-
else if(value != null && value.equalsIgnoreCase("nexus"))
4112-
_privateNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4113-
else
4114-
_privateNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4115-
4116-
value = (String)params.get("public.network.vswitch.type");
4117-
if(value != null && value.equalsIgnoreCase("standard"))
4118-
_publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4119-
else if(value != null && value.equalsIgnoreCase("nexus"))
4120-
_publicNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4121-
else
4122-
_publicNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4123-
4124-
value = (String)params.get("guest.network.vswitch.type");
4125-
if(value != null && value.equalsIgnoreCase("standard"))
4126-
_guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4127-
else if(value != null && value.equalsIgnoreCase("nexus"))
4128-
_guestNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4129-
else
4130-
_guestNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4131-
4102+
41324103
s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
41334104
+ _guestNetworkVSwitchName);
41344105

server/src/com/cloud/configuration/Config.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ public enum Config {
243243
VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
244244
VmwareGuestNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.guest.vswitch", null, "Specify the vSwitch on host for guest network", null),
245245
VmwareUseNexusVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.nexus.vswitch", "false", "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", null),
246-
VmwarePrivateNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.private.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for private traffic", null),
247-
VmwarePublicNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.public.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for public traffic", null),
248-
VmwareGuestNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.guest.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for guest traffic", null),
249246
VmwareServiceConsole("Advanced", ManagementServer.class, String.class, "vmware.service.console", "Service Console", "Specify the service console network name(for ESX hosts)", null),
250247
VmwareManagementPortGroup("Advanced", ManagementServer.class, String.class, "vmware.management.portgroup", "Management Network", "Specify the management network name(for ESXi hosts)", null),
251248
VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null),

server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
130130
String _privateNetworkVSwitchName;
131131
String _publicNetworkVSwitchName;
132132
String _guestNetworkVSwitchName;
133-
String _privateNetworkVSwitchType;
134-
String _publicNetworkVSwitchType;
135-
String _guestNetworkVSwitchType;
136133
boolean _nexusVSwitchActive;
137134
String _serviceConsoleName;
138135
String _managemetPortGroupName;
@@ -229,41 +226,29 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
229226
}
230227

231228
_privateNetworkVSwitchName = configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key());
232-
_privateNetworkVSwitchType = configDao.getValue(Config.VmwarePrivateNetworkVSwitchType.key());
233-
if(_privateNetworkVSwitchName == null) {
234-
if(_privateNetworkVSwitchType == null || _privateNetworkVSwitchType.equalsIgnoreCase("standard")) {
235-
_privateNetworkVSwitchName = "vSwitch0";
236-
}
237-
else
238-
{
239-
_privateNetworkVSwitchName = "privateEthernetPortProfile";
240-
}
229+
230+
if (_privateNetworkVSwitchName == null) {
231+
_privateNetworkVSwitchName = "vSwitch0";
232+
} else {
233+
_privateNetworkVSwitchName = "privateEthernetPortProfile";
241234
}
242235

243236
_publicNetworkVSwitchName = configDao.getValue(Config.VmwarePublicNetworkVSwitch.key());
244-
_publicNetworkVSwitchType = configDao.getValue(Config.VmwarePublicNetworkVSwitchType.key());
245-
if(_publicNetworkVSwitchName == null) {
246-
if(_publicNetworkVSwitchType == null || _publicNetworkVSwitchType.equalsIgnoreCase("standard")) {
247-
_publicNetworkVSwitchName = "vSwitch0";
248-
}
249-
else
250-
{
251-
_publicNetworkVSwitchName = "publicEthernetPortProfile";
252-
}
253-
}
254237

255-
_guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key());
256-
_guestNetworkVSwitchType = configDao.getValue(Config.VmwareGuestNetworkVSwitchType.key());
257-
if(_guestNetworkVSwitchName == null) {
258-
if(_guestNetworkVSwitchType == null || _guestNetworkVSwitchType.equalsIgnoreCase("standard")) {
259-
_guestNetworkVSwitchName = "vSwitch0";
260-
}
261-
else
262-
{
263-
_guestNetworkVSwitchName = "guestEthernetPortProfile";
264-
}
238+
if (_publicNetworkVSwitchName == null) {
239+
_publicNetworkVSwitchName = "vSwitch0";
240+
} else {
241+
_publicNetworkVSwitchName = "publicEthernetPortProfile";
265242
}
266-
243+
244+
_guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key());
245+
246+
if (_guestNetworkVSwitchName == null) {
247+
_guestNetworkVSwitchName = "vSwitch0";
248+
} else {
249+
_guestNetworkVSwitchName = "guestEthernetPortProfile";
250+
}
251+
267252
_serviceConsoleName = configDao.getValue(Config.VmwareServiceConsole.key());
268253
if(_serviceConsoleName == null) {
269254
_serviceConsoleName = "Service Console";
@@ -363,18 +348,6 @@ public boolean getNexusVSwitchGlobalParameter() {
363348
return _nexusVSwitchActive;
364349
}
365350

366-
public String getPrivateVSwitchTypeGlobalParameter() {
367-
return _privateNetworkVSwitchType;
368-
}
369-
370-
public String getPublicVSwitchTypeGlobalParameter() {
371-
return _publicNetworkVSwitchType;
372-
}
373-
374-
public String getGuestVSwitchTypeGlobalParameter() {
375-
return _guestNetworkVSwitchType;
376-
}
377-
378351
@Override
379352
public String composeWorkerName() {
380353
return UUID.randomUUID().toString().replace("-", "");
@@ -592,9 +565,6 @@ public void setupResourceStartupParams(Map<String, Object> params) {
592565
params.put("private.network.vswitch.name", _privateNetworkVSwitchName);
593566
params.put("public.network.vswitch.name", _publicNetworkVSwitchName);
594567
params.put("guest.network.vswitch.name", _guestNetworkVSwitchName);
595-
params.put("private.network.vswitch.type", _privateNetworkVSwitchType);
596-
params.put("public.network.vswitch.type", _publicNetworkVSwitchType);
597-
params.put("guest.network.vswitch.type", _guestNetworkVSwitchType);
598568
params.put("vmware.use.nexus.vswitch", _nexusVSwitchActive);
599569
params.put("service.console.name", _serviceConsoleName);
600570
params.put("management.portgroup.name", _managemetPortGroupName);

server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,17 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
127127

128128
DataCenterVO zone = _dcDao.findById(dcId);
129129
NetworkType zoneType = zone.getNetworkType();
130-
131-
if (zoneType != NetworkType.Basic && _vmwareMgr.getPublicVSwitchTypeGlobalParameter() != null && _vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
132-
// Get physical network label
130+
if (zoneType != NetworkType.Basic) {
133131
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
134132
if (publicTrafficLabel != null) {
135133
s_logger.info("Detected public network label : " + publicTrafficLabel);
136134
}
137135
}
138-
else {
139-
s_logger.info("Skipping detection of public traffic label as zone type is Basic.");
140-
}
141-
142-
if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter() != null && _vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
143-
// Get physical network label
144-
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
145-
if (guestTrafficLabel != null) {
146-
s_logger.info("Detected guest network label : " + guestTrafficLabel);
147-
}
136+
// Get physical network label
137+
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
138+
if (guestTrafficLabel != null) {
139+
s_logger.info("Detected guest network label : " + guestTrafficLabel);
148140
}
149-
150-
// Get credentials
151141
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
152142
}
153143

server/src/com/cloud/network/NetworkManagerImpl.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6496,8 +6496,9 @@ public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfil
64966496
@Override
64976497
public String getDefaultPublicTrafficLabel(long dcId, HypervisorType hypervisorType) {
64986498
try {
6499-
PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public);
6500-
PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Public);
6499+
PhysicalNetwork publicPhyNetwork = getOnePhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public);
6500+
PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(publicPhyNetwork.getId(),
6501+
TrafficType.Public);
65016502
if (publicTraffic != null) {
65026503
String label = null;
65036504
switch (hypervisorType) {
@@ -6524,8 +6525,9 @@ public String getDefaultPublicTrafficLabel(long dcId, HypervisorType hypervisorT
65246525
@Override
65256526
public String getDefaultGuestTrafficLabel(long dcId, HypervisorType hypervisorType) {
65266527
try {
6527-
PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Guest);
6528-
PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Guest);
6528+
PhysicalNetwork guestPhyNetwork = getOnePhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Guest);
6529+
PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(guestPhyNetwork.getId(),
6530+
TrafficType.Guest);
65296531
if (guestTraffic != null) {
65306532
String label = null;
65316533
switch (hypervisorType) {
@@ -6548,4 +6550,20 @@ public String getDefaultGuestTrafficLabel(long dcId, HypervisorType hypervisorTy
65486550
}
65496551
return null;
65506552
}
6553+
6554+
private PhysicalNetwork getOnePhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) {
6555+
List<PhysicalNetworkVO> networkList = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, trafficType);
6556+
6557+
if (networkList.isEmpty()) {
6558+
throw new InvalidParameterValueException("Unable to find the default physical network with traffic="
6559+
+ trafficType + " in zone id=" + zoneId + ". ");
6560+
}
6561+
6562+
if (networkList.size() > 1) {
6563+
s_logger.info("More than one physical networks exist in zone id=" + zoneId + " with traffic type="
6564+
+ trafficType + ". ");
6565+
}
6566+
6567+
return networkList.get(0);
6568+
}
65516569
}

0 commit comments

Comments
 (0)