Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,6 @@ public VmwareServerDiscoverer() {
throw new InvalidParameterValueException(msg);
}
}
} else {
// Distributed virtual switch is not supported in Basic zone for now.
// Private / Management network traffic is not yet supported over distributed virtual switch.
if (guestTrafficLabelObj.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch) {
String msg = "Detected that Guest traffic is over Distributed virtual switch in Basic zone. Only Standard vSwitch is supported in Basic zone.";
s_logger.error(msg);
throw new DiscoveredWithErrorException(msg);
}
}

privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
Expand Down Expand Up @@ -414,7 +406,7 @@ public VmwareServerDiscoverer() {
} catch (DiscoveredWithErrorException e) {
throw e;
} catch (Exception e) {
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost() + ". " + e);
return null;
} finally {
if (context != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,16 @@
import com.cloud.hypervisor.vmware.mo.HostMO;
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
import com.cloud.hypervisor.vmware.util.VmwareContext;
import com.cloud.hypervisor.vmware.util.VmwareHelper;
import com.cloud.network.CiscoNexusVSMDeviceVO;
import com.cloud.network.NetworkModel;
import com.cloud.network.VmwareTrafficLabel;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
import com.cloud.org.Cluster.ClusterType;
import com.cloud.secstorage.CommandExecLogDao;
Expand Down Expand Up @@ -350,20 +353,24 @@ private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Excep
}

// prepare at least one network on the vswitch to enable OVF importing
String vSwitchName = privateTrafficLabel;
String vlanId = null;
String vlanToken;
String[] tokens = privateTrafficLabel.split(",");
if (tokens.length >= 2) {
vSwitchName = tokens[0].trim();
vlanToken = tokens[1].trim();
if (!vlanToken.isEmpty()) {
vlanId = vlanToken;
}
}
String vSwitchName;
String vlanId;
String vSwitchType;
VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(privateTrafficLabel, TrafficType.Management);
vSwitchName = mgmtTrafficLabelObj.getVirtualSwitchName();
vlanId = mgmtTrafficLabelObj.getVlanId();
vSwitchType = mgmtTrafficLabelObj.getVirtualSwitchType().toString();

s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
//The management network is probably always going to be a physical network with vlans, so assume BroadcastDomainType VLAN
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null);
VirtualSwitchType vsType = VirtualSwitchType.getType(vSwitchType);
//The management network is probably always going to be a physical network with islation type of vlans, so assume BroadcastDomainType VLAN
if (VirtualSwitchType.StandardVirtualSwitch == vsType) {
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null);
}
else {
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, null, 180000,
vsType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, null);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2463,6 +2463,13 @@ private String getVlanInfo(NicTO nicTo, String defaultVlan) {
} else if (nicTo.getBroadcastType() == BroadcastDomainType.Lswitch) {
// We don't need to set any VLAN id for an NVP logical switch
return null;
} else if (nicTo.getBroadcastType() == BroadcastDomainType.Storage) {
URI broadcastUri = nicTo.getBroadcastUri();
if (broadcastUri != null) {
String vlanId = BroadcastDomainType.getValue(broadcastUri);
s_logger.debug("Using VLAN [" + vlanId + "] from broadcast uri [" + broadcastUri + "]");
return vlanId;
}
}

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

String switchName = null;
VirtualSwitchType switchType = VirtualSwitchType.StandardVirtualSwitch;
String vlanToken = Vlan.UNTAGGED;
String vlanId = Vlan.UNTAGGED;

// Get switch details from the nicTO object
if(nicTo.getName() != null && !nicTo.getName().isEmpty()) {
String[] tokens = nicTo.getName().split(",");
// Format of network traffic label is <VSWITCH>,<VLANID>,<VSWITCHTYPE>
// If all 3 fields are mentioned then number of tokens would be 3.
// If only <VSWITCH>,<VLANID> are mentioned then number of tokens would be 2.
switchName = tokens[0];
if(tokens.length == 2 || tokens.length == 3) {
vlanToken = tokens[1];
if (vlanToken.isEmpty()) {
vlanToken = Vlan.UNTAGGED;
}
if (tokens.length == 3) {
switchType = VirtualSwitchType.getType(tokens[2]);
}
}
// Get switch details from the nicTO object
String networkName = nicTo.getName();
VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(networkName, trafficType);
switchName = mgmtTrafficLabelObj.getVirtualSwitchName();
vlanId = mgmtTrafficLabelObj.getVlanId();
switchType = mgmtTrafficLabelObj.getVirtualSwitchType();
} else {
if (trafficType == TrafficType.Guest && _guestTrafficInfo != null) {
switchType = _guestTrafficInfo.getVirtualSwitchType();
Expand All @@ -2558,7 +2559,15 @@ private Ternary<String, String, String> getTargetSwitch(NicTO nicTo) throws Clou
switchName = _privateNetworkVSwitchName;
}

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

return new Ternary<String, String, String>(switchName, switchType.toString(), vlanId);
}

private String getNetworkNamePrefix(NicTO nicTo) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.
package com.cloud.network;

import com.cloud.dc.Vlan;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
import com.cloud.network.Networks.TrafficType;
Expand All @@ -32,7 +33,7 @@ public class VmwareTrafficLabel implements TrafficLabel {
TrafficType _trafficType = TrafficType.None;
VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
String _vSwitchName = DEFAULT_VSWITCH_NAME;
String _vlanId = null;
String _vlanId = Vlan.UNTAGGED;

public VmwareTrafficLabel(String networkLabel, TrafficType trafficType, VirtualSwitchType defVswitchType) {
_trafficType = trafficType;
Expand Down
27 changes: 25 additions & 2 deletions vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
Original file line number Diff line number Diff line change
Expand Up @@ -908,13 +908,20 @@ public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String mana

if (getHostType() == VmwareHostType.ESXi) {
List<VirtualNicManagerNetConfig> netConfigs =
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
assert (netConfigs != null);

String dvPortGroupKey;
String portGroup;
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
if (netConfig.getNicType().equals("management")) {
for (HostVirtualNic nic : netConfig.getCandidateVnic()) {
if (nic.getPortgroup().equals(managementPortGroup)) {
portGroup = nic.getPortgroup();
if (portGroup == null || portGroup.isEmpty()) {
dvPortGroupKey = nic.getSpec().getDistributedVirtualPort().getPortgroupKey();
portGroup = getNetworkName(dvPortGroupKey);
}
if (portGroup.equalsIgnoreCase(managementPortGroup)) {
summary.setHostIp(nic.getSpec().getIp().getIpAddress());
summary.setHostNetmask(nic.getSpec().getIp().getSubnetMask());
summary.setHostMacAddress(nic.getSpec().getMac());
Expand Down Expand Up @@ -1059,4 +1066,20 @@ public String getHostManagementIp(String managementPortGroup) throws Exception {

return null;
}

public List<ManagedObjectReference> getHostNetworks() throws Exception {
return _context.getVimClient().getDynamicProperty(_mor, "network");
}

public String getNetworkName(String netMorVal) throws Exception {
String networkName = "";
List<ManagedObjectReference> hostNetworks = getHostNetworks();
for (ManagedObjectReference hostNetwork : hostNetworks) {
if (hostNetwork.getValue().equals(netMorVal)) {
networkName = _context.getVimClient().getDynamicProperty(hostNetwork, "name");
break;
}
}
return networkName;
}
}
Loading