You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/05/28 00:35:42 UTC
[34/50] [abbrv] git commit: CS-15080 - add support for private
network on a VLAN under VMware
CS-15080 - add support for private network on a VLAN under VMware
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ae2b599b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ae2b599b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ae2b599b
Branch: refs/heads/3.0.x
Commit: ae2b599b8dfe0f9790db76f6961e24e5a2d0aa44
Parents: d81f72e
Author: Kelven Yang <ke...@cloud.com>
Authored: Thu May 24 11:38:05 2012 -0700
Committer: Kelven Yang <ke...@cloud.com>
Committed: Thu May 24 11:40:43 2012 -0700
----------------------------------------------------------------------
.../hypervisor/vmware/resource/VmwareResource.java | 43 +++++++++------
1 files changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae2b599b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 8d6e8fe..6a1f3c7 100755
--- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -230,6 +230,7 @@ import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
import com.vmware.vim25.VirtualMachinePowerState;
import com.vmware.vim25.VirtualMachineRuntimeInfo;
import com.vmware.vim25.VirtualSCSISharing;
+import com.xensource.xenapi.VLAN;
public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService {
private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
@@ -1673,57 +1674,65 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return poolMors;
}
- private String getVlanInfo(NicTO nicTo) {
+ private String getVlanInfo(NicTO nicTo, String defaultVlan) {
if (nicTo.getBroadcastType() == BroadcastDomainType.Native) {
- return Vlan.UNTAGGED;
+ return defaultVlan;
}
if (nicTo.getBroadcastType() == BroadcastDomainType.Vlan) {
if (nicTo.getBroadcastUri() != null) {
return nicTo.getBroadcastUri().getHost();
} else {
- s_logger.warn("BroadcastType is not claimed as VLAN, but without vlan info in broadcast URI");
- return Vlan.UNTAGGED;
+ s_logger.warn("BroadcastType is not claimed as VLAN, but without vlan info in broadcast URI. Use vlan info from labeling: " + defaultVlan);
+ return defaultVlan;
}
}
- s_logger.warn("Unrecognized broadcast type in VmwareResource, type: " + nicTo.getBroadcastType().toString());
- return Vlan.UNTAGGED;
+ s_logger.warn("Unrecognized broadcast type in VmwareResource, type: " + nicTo.getBroadcastType().toString() + ". Use vlan info from labeling: " + defaultVlan);
+ return defaultVlan;
}
private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo) throws Exception {
- String switchName = getTargetSwitch(nicTo);
+ Pair<String, String> switchName = getTargetSwitch(nicTo);
String namePrefix = getNetworkNamePrefix(nicTo);
Pair<ManagedObjectReference, String> networkInfo = null;
- s_logger.info("Prepare network on vSwitch: " + switchName + " with name prefix: " + namePrefix);
+ s_logger.info("Prepare network on vSwitch: " + switchName.first() + " with name prefix: " + namePrefix);
if(!_nexusVSwitch) {
- networkInfo = HypervisorHostHelper.prepareNetwork(switchName, namePrefix, hostMo, getVlanInfo(nicTo),
+ networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
!namePrefix.startsWith("cloud.private"));
}
else {
- networkInfo = HypervisorHostHelper.prepareNetwork(switchName, namePrefix, hostMo, getVlanInfo(nicTo),
+ networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
}
return networkInfo;
}
- private String getTargetSwitch(NicTO nicTo) throws Exception {
- if(nicTo.getName() != null && !nicTo.getName().isEmpty())
- return nicTo.getName();
+ // return Pair<switch name, vlan tagging>
+ private Pair<String, String> getTargetSwitch(NicTO nicTo) throws Exception {
+ if(nicTo.getName() != null && !nicTo.getName().isEmpty()) {
+ String[] tokens = nicTo.getName().split(",");
+
+ if(tokens.length == 2) {
+ return new Pair<String, String>(tokens[0], tokens[1]);
+ } else {
+ return new Pair<String, String>(nicTo.getName(), Vlan.UNTAGGED);
+ }
+ }
if (nicTo.getType() == Networks.TrafficType.Guest) {
- return this._guestNetworkVSwitchName;
+ return new Pair<String, String>(this._guestNetworkVSwitchName, Vlan.UNTAGGED);
} else if (nicTo.getType() == Networks.TrafficType.Control || nicTo.getType() == Networks.TrafficType.Management) {
- return this._privateNetworkVSwitchName;
+ return new Pair<String, String>(this._privateNetworkVSwitchName, Vlan.UNTAGGED);
} else if (nicTo.getType() == Networks.TrafficType.Public) {
- return this._publicNetworkVSwitchName;
+ return new Pair<String, String>(this._publicNetworkVSwitchName, Vlan.UNTAGGED);
} else if (nicTo.getType() == Networks.TrafficType.Storage) {
- return this._privateNetworkVSwitchName;
+ return new Pair<String, String>(this._privateNetworkVSwitchName, Vlan.UNTAGGED);
} else if (nicTo.getType() == Networks.TrafficType.Vpn) {
throw new Exception("Unsupported traffic type: " + nicTo.getType().toString());
} else {