Skip to content

Commit 98dc68d

Browse files
committed
CLOUDSTACK-728 For Nicira NVP a specified port-group must be used,
instead of a dynamically configured one. Refactor bits of the HypervisorHostHelper to better support multiple BroadcastDomainTypes Cleanup some parts of the code that was using tab indents and removed some dead code.
1 parent 079f920 commit 98dc68d

4 files changed

Lines changed: 599 additions & 580 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import com.cloud.hypervisor.vmware.util.VmwareHelper;
9393
import com.cloud.network.CiscoNexusVSMDeviceVO;
9494
import com.cloud.network.NetworkModel;
95+
import com.cloud.network.Networks.BroadcastDomainType;
9596
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
9697
import com.cloud.org.Cluster.ClusterType;
9798
import com.cloud.secstorage.CommandExecLogDao;
@@ -346,7 +347,8 @@ private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Excep
346347
}
347348
}
348349
s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
349-
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
350+
//The management network is probably always going to be a physical network with vlans, so assume BroadcastDomainType VLAN
351+
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan);
350352
}
351353

352354
@Override

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

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
import com.cloud.network.LoadBalancerConfigurator;
230230
import com.cloud.network.Networks;
231231
import com.cloud.network.Networks.BroadcastDomainType;
232+
import com.cloud.network.Networks.IsolationType;
232233
import com.cloud.network.Networks.TrafficType;
233234
import com.cloud.network.VmwareTrafficLabel;
234235
import com.cloud.network.rules.FirewallRule;
@@ -1787,12 +1788,15 @@ private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final Str
17871788
if (_publicTrafficInfo != null) {
17881789
vSwitchType = _publicTrafficInfo.getVirtualSwitchType();
17891790
}
1791+
/** FIXME We have no clue which network this nic is on and that means that we can't figure out the BroadcastDomainType
1792+
* so we assume that it's VLAN for now
1793+
*/
17901794
if (VirtualSwitchType.StandardVirtualSwitch == vSwitchType) {
17911795
networkInfo = HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
1792-
vmMo.getRunningHost(), vlanId, null, null, _ops_timeout, true);
1796+
vmMo.getRunningHost(), vlanId, null, null, _ops_timeout, true, BroadcastDomainType.Vlan);
17931797
} else {
1794-
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
1795-
vmMo.getRunningHost(), vlanId, null, null, null, this._ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false);
1798+
networkInfo = HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
1799+
vmMo.getRunningHost(), vlanId, null, null, null, _ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan);
17961800
}
17971801

17981802
int nicIndex = allocPublicNicIndex(vmMo);
@@ -2953,7 +2957,7 @@ private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO ho
29532957
if (VirtualSwitchType.StandardVirtualSwitch == switchType) {
29542958
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix,
29552959
hostMo, getVlanInfo(nicTo, switchName.second()), nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
2956-
!namePrefix.startsWith("cloud.private"));
2960+
!namePrefix.startsWith("cloud.private"), nicTo.getBroadcastType());
29572961
}
29582962
else {
29592963
String vlanId = getVlanInfo(nicTo, switchName.second());
@@ -2967,7 +2971,8 @@ hostMo, getVlanInfo(nicTo, switchName.second()), nicTo.getNetworkRateMbps(), nic
29672971
svlanId = getPvlanInfo(nicTo);
29682972
}
29692973
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, vlanId, svlanId,
2970-
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus);
2974+
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType,
2975+
_portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus, nicTo.getBroadcastType());
29712976
}
29722977

29732978
return networkInfo;
@@ -5329,73 +5334,6 @@ private VirtualMachineGuestOsIdentifier translateGuestOsIdentifier(String cpuArc
53295334
return VirtualMachineGuestOsIdentifier.OTHER_GUEST;
53305335
}
53315336

5332-
private void prepareNetworkForVmTargetHost(HostMO hostMo, VirtualMachineMO vmMo) throws Exception {
5333-
assert (vmMo != null);
5334-
assert (hostMo != null);
5335-
5336-
String[] networks = vmMo.getNetworks();
5337-
for (String networkName : networks) {
5338-
HostPortGroupSpec portGroupSpec = hostMo.getHostPortGroupSpec(networkName);
5339-
HostNetworkTrafficShapingPolicy shapingPolicy = null;
5340-
if (portGroupSpec != null) {
5341-
shapingPolicy = portGroupSpec.getPolicy().getShapingPolicy();
5342-
}
5343-
5344-
if (networkName.startsWith("cloud.private")) {
5345-
String[] tokens = networkName.split("\\.");
5346-
if (tokens.length == 3) {
5347-
Integer networkRateMbps = null;
5348-
if (shapingPolicy != null && shapingPolicy.isEnabled() != null && shapingPolicy.isEnabled().booleanValue()) {
5349-
networkRateMbps = (int) (shapingPolicy.getPeakBandwidth().longValue() / (1024 * 1024));
5350-
}
5351-
String vlanId = null;
5352-
if(!"untagged".equalsIgnoreCase(tokens[2]))
5353-
vlanId = tokens[2];
5354-
5355-
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private",
5356-
hostMo, vlanId, networkRateMbps, null, _ops_timeout, false);
5357-
} else {
5358-
s_logger.info("Skip suspecious cloud network " + networkName);
5359-
}
5360-
} else if (networkName.startsWith("cloud.public")) {
5361-
String[] tokens = networkName.split("\\.");
5362-
if (tokens.length == 3) {
5363-
Integer networkRateMbps = null;
5364-
if (shapingPolicy != null && shapingPolicy.isEnabled() != null && shapingPolicy.isEnabled().booleanValue()) {
5365-
networkRateMbps = (int) (shapingPolicy.getPeakBandwidth().longValue() / (1024 * 1024));
5366-
}
5367-
String vlanId = null;
5368-
if(!"untagged".equalsIgnoreCase(tokens[2]))
5369-
vlanId = tokens[2];
5370-
5371-
HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), "cloud.public",
5372-
hostMo, vlanId, networkRateMbps, null, _ops_timeout, false);
5373-
} else {
5374-
s_logger.info("Skip suspecious cloud network " + networkName);
5375-
}
5376-
} else if (networkName.startsWith("cloud.guest")) {
5377-
String[] tokens = networkName.split("\\.");
5378-
if (tokens.length >= 3) {
5379-
Integer networkRateMbps = null;
5380-
if (shapingPolicy != null && shapingPolicy.isEnabled() != null && shapingPolicy.isEnabled().booleanValue()) {
5381-
networkRateMbps = (int) (shapingPolicy.getPeakBandwidth().longValue() / (1024 * 1024));
5382-
}
5383-
5384-
String vlanId = null;
5385-
if(!"untagged".equalsIgnoreCase(tokens[2]))
5386-
vlanId = tokens[2];
5387-
5388-
HypervisorHostHelper.prepareNetwork(_guestTrafficInfo.getVirtualSwitchName(), "cloud.guest",
5389-
hostMo, vlanId, networkRateMbps, null, _ops_timeout, false);
5390-
} else {
5391-
s_logger.info("Skip suspecious cloud network " + networkName);
5392-
}
5393-
} else {
5394-
s_logger.info("Skip non-cloud network " + networkName + " when preparing target host");
5395-
}
5396-
}
5397-
}
5398-
53995337
private HashMap<String, State> getVmStates() throws Exception {
54005338
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
54015339
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] { "name", "runtime.powerState", "config.template" });

vmware-base/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<artifactId>cloud-utils</artifactId>
3333
<version>${project.version}</version>
3434
</dependency>
35+
<dependency>
36+
<groupId>org.apache.cloudstack</groupId>
37+
<artifactId>cloud-api</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
3540
<dependency>
3641
<groupId>com.google.code.gson</groupId>
3742
<artifactId>gson</artifactId>

0 commit comments

Comments
 (0)