Skip to content

Commit 5e41a83

Browse files
author
Sateesh Chodapuneedi
committed
This closes apache#373
CLOUDSTACK-3317 - DVS does not support management\storage network Added support for Management and Storage Network traffic over VMware DVS in CloudStack deployments. Also added support for storage VLAN over dvPortGroup. Signed-off-by: Sateesh Chodapuneedi <[email protected]> CLOUDSTACK-3317 - DVS does not support management\storage network Use non-zero dvport count while updating dvportgroups of system traffic. Updated configuration compare logic to avoid update dvportgroup operation unless required. This would help improve speed in vm/network deployment as the update calls would reduce. Also improved logging. Signed-off-by: Sateesh Chodapuneedi <[email protected]> Adding unit tests in class HypervisorHostHelperTest Signed-off-by: Sateesh Chodapuneedi <[email protected]> Added license header to new file being added to repo/branch. Signed-off-by: Sateesh Chodapuneedi <[email protected]>
1 parent 8f1e051 commit 5e41a83

7 files changed

Lines changed: 751 additions & 51 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,6 @@ public VmwareServerDiscoverer() {
268268
throw new InvalidParameterValueException(msg);
269269
}
270270
}
271-
} else {
272-
// Distributed virtual switch is not supported in Basic zone for now.
273-
// Private / Management network traffic is not yet supported over distributed virtual switch.
274-
if (guestTrafficLabelObj.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch) {
275-
String msg = "Detected that Guest traffic is over Distributed virtual switch in Basic zone. Only Standard vSwitch is supported in Basic zone.";
276-
s_logger.error(msg);
277-
throw new DiscoveredWithErrorException(msg);
278-
}
279271
}
280272

281273
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
@@ -414,7 +406,7 @@ public VmwareServerDiscoverer() {
414406
} catch (DiscoveredWithErrorException e) {
415407
throw e;
416408
} catch (Exception e) {
417-
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
409+
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost() + ". " + e);
418410
return null;
419411
} finally {
420412
if (context != null)

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,16 @@
9292
import com.cloud.hypervisor.vmware.mo.HostMO;
9393
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
9494
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
95+
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
9596
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
9697
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
9798
import com.cloud.hypervisor.vmware.util.VmwareContext;
9899
import com.cloud.hypervisor.vmware.util.VmwareHelper;
99100
import com.cloud.network.CiscoNexusVSMDeviceVO;
100101
import com.cloud.network.NetworkModel;
102+
import com.cloud.network.VmwareTrafficLabel;
101103
import com.cloud.network.Networks.BroadcastDomainType;
104+
import com.cloud.network.Networks.TrafficType;
102105
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
103106
import com.cloud.org.Cluster.ClusterType;
104107
import com.cloud.secstorage.CommandExecLogDao;
@@ -350,20 +353,24 @@ private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Excep
350353
}
351354

352355
// prepare at least one network on the vswitch to enable OVF importing
353-
String vSwitchName = privateTrafficLabel;
354-
String vlanId = null;
355-
String vlanToken;
356-
String[] tokens = privateTrafficLabel.split(",");
357-
if (tokens.length >= 2) {
358-
vSwitchName = tokens[0].trim();
359-
vlanToken = tokens[1].trim();
360-
if (!vlanToken.isEmpty()) {
361-
vlanId = vlanToken;
362-
}
363-
}
356+
String vSwitchName;
357+
String vlanId;
358+
String vSwitchType;
359+
VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(privateTrafficLabel, TrafficType.Management);
360+
vSwitchName = mgmtTrafficLabelObj.getVirtualSwitchName();
361+
vlanId = mgmtTrafficLabelObj.getVlanId();
362+
vSwitchType = mgmtTrafficLabelObj.getVirtualSwitchType().toString();
363+
364364
s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
365-
//The management network is probably always going to be a physical network with vlans, so assume BroadcastDomainType VLAN
366-
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null);
365+
VirtualSwitchType vsType = VirtualSwitchType.getType(vSwitchType);
366+
//The management network is probably always going to be a physical network with islation type of vlans, so assume BroadcastDomainType VLAN
367+
if (VirtualSwitchType.StandardVirtualSwitch == vsType) {
368+
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null);
369+
}
370+
else {
371+
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, null, 180000,
372+
vsType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, null);
373+
}
367374
}
368375

369376
@Override

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,13 @@ private String getVlanInfo(NicTO nicTo, String defaultVlan) {
24632463
} else if (nicTo.getBroadcastType() == BroadcastDomainType.Lswitch) {
24642464
// We don't need to set any VLAN id for an NVP logical switch
24652465
return null;
2466+
} else if (nicTo.getBroadcastType() == BroadcastDomainType.Storage) {
2467+
URI broadcastUri = nicTo.getBroadcastUri();
2468+
if (broadcastUri != null) {
2469+
String vlanId = BroadcastDomainType.getValue(broadcastUri);
2470+
s_logger.debug("Using VLAN [" + vlanId + "] from broadcast uri [" + broadcastUri + "]");
2471+
return vlanId;
2472+
}
24662473
}
24672474

24682475
s_logger.warn("Unrecognized broadcast type in VmwareResource, type: " + nicTo.getBroadcastType().toString() + ". Use vlan info from labeling: " + defaultVlan);
@@ -2525,24 +2532,18 @@ private Ternary<String, String, String> getTargetSwitch(NicTO nicTo) throws Clou
25252532

25262533
String switchName = null;
25272534
VirtualSwitchType switchType = VirtualSwitchType.StandardVirtualSwitch;
2528-
String vlanToken = Vlan.UNTAGGED;
2535+
String vlanId = Vlan.UNTAGGED;
25292536

2530-
// Get switch details from the nicTO object
25312537
if(nicTo.getName() != null && !nicTo.getName().isEmpty()) {
2532-
String[] tokens = nicTo.getName().split(",");
25332538
// Format of network traffic label is <VSWITCH>,<VLANID>,<VSWITCHTYPE>
25342539
// If all 3 fields are mentioned then number of tokens would be 3.
25352540
// If only <VSWITCH>,<VLANID> are mentioned then number of tokens would be 2.
2536-
switchName = tokens[0];
2537-
if(tokens.length == 2 || tokens.length == 3) {
2538-
vlanToken = tokens[1];
2539-
if (vlanToken.isEmpty()) {
2540-
vlanToken = Vlan.UNTAGGED;
2541-
}
2542-
if (tokens.length == 3) {
2543-
switchType = VirtualSwitchType.getType(tokens[2]);
2544-
}
2545-
}
2541+
// Get switch details from the nicTO object
2542+
String networkName = nicTo.getName();
2543+
VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(networkName, trafficType);
2544+
switchName = mgmtTrafficLabelObj.getVirtualSwitchName();
2545+
vlanId = mgmtTrafficLabelObj.getVlanId();
2546+
switchType = mgmtTrafficLabelObj.getVirtualSwitchType();
25462547
} else {
25472548
if (trafficType == TrafficType.Guest && _guestTrafficInfo != null) {
25482549
switchType = _guestTrafficInfo.getVirtualSwitchType();
@@ -2558,7 +2559,15 @@ private Ternary<String, String, String> getTargetSwitch(NicTO nicTo) throws Clou
25582559
switchName = _privateNetworkVSwitchName;
25592560
}
25602561

2561-
return new Ternary<String,String,String>(switchName, switchType.toString(), vlanToken);
2562+
if (switchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
2563+
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
2564+
throw new CloudException("Unable to configure NIC " + nicTo.toString() + " as traffic type " + trafficType.toString() +
2565+
" is not supported over virtual switch type " + switchType +
2566+
". Please specify only supported type of virtual switches i.e. {vmwaresvs, vmwaredvs} in physical network traffic label.");
2567+
}
2568+
}
2569+
2570+
return new Ternary<String, String, String>(switchName, switchType.toString(), vlanId);
25622571
}
25632572

25642573
private String getNetworkNamePrefix(NicTO nicTo) throws Exception {

plugins/hypervisors/vmware/src/com/cloud/network/VmwareTrafficLabel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package com.cloud.network;
1818

19+
import com.cloud.dc.Vlan;
1920
import com.cloud.exception.InvalidParameterValueException;
2021
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
2122
import com.cloud.network.Networks.TrafficType;
@@ -32,7 +33,7 @@ public class VmwareTrafficLabel implements TrafficLabel {
3233
TrafficType _trafficType = TrafficType.None;
3334
VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
3435
String _vSwitchName = DEFAULT_VSWITCH_NAME;
35-
String _vlanId = null;
36+
String _vlanId = Vlan.UNTAGGED;
3637

3738
public VmwareTrafficLabel(String networkLabel, TrafficType trafficType, VirtualSwitchType defVswitchType) {
3839
_trafficType = trafficType;

vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,13 +908,20 @@ public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String mana
908908

909909
if (getHostType() == VmwareHostType.ESXi) {
910910
List<VirtualNicManagerNetConfig> netConfigs =
911-
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
911+
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
912912
assert (netConfigs != null);
913913

914+
String dvPortGroupKey;
915+
String portGroup;
914916
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
915917
if (netConfig.getNicType().equals("management")) {
916918
for (HostVirtualNic nic : netConfig.getCandidateVnic()) {
917-
if (nic.getPortgroup().equals(managementPortGroup)) {
919+
portGroup = nic.getPortgroup();
920+
if (portGroup == null || portGroup.isEmpty()) {
921+
dvPortGroupKey = nic.getSpec().getDistributedVirtualPort().getPortgroupKey();
922+
portGroup = getNetworkName(dvPortGroupKey);
923+
}
924+
if (portGroup.equalsIgnoreCase(managementPortGroup)) {
918925
summary.setHostIp(nic.getSpec().getIp().getIpAddress());
919926
summary.setHostNetmask(nic.getSpec().getIp().getSubnetMask());
920927
summary.setHostMacAddress(nic.getSpec().getMac());
@@ -1059,4 +1066,20 @@ public String getHostManagementIp(String managementPortGroup) throws Exception {
10591066

10601067
return null;
10611068
}
1069+
1070+
public List<ManagedObjectReference> getHostNetworks() throws Exception {
1071+
return _context.getVimClient().getDynamicProperty(_mor, "network");
1072+
}
1073+
1074+
public String getNetworkName(String netMorVal) throws Exception {
1075+
String networkName = "";
1076+
List<ManagedObjectReference> hostNetworks = getHostNetworks();
1077+
for (ManagedObjectReference hostNetwork : hostNetworks) {
1078+
if (hostNetwork.getValue().equals(netMorVal)) {
1079+
networkName = _context.getVimClient().getDynamicProperty(hostNetwork, "name");
1080+
break;
1081+
}
1082+
}
1083+
return networkName;
1084+
}
10621085
}

0 commit comments

Comments
 (0)