CLOUDSTACK-1767 VMWare DVS - cannot use untagged portgroups

Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>
This commit is contained in:
Sateesh Chodapuneedi 2013-06-25 19:43:20 +05:30
parent b3927ffe96
commit c36a952f15
4 changed files with 33 additions and 36 deletions

View File

@ -336,12 +336,15 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
// 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) {
if(tokens.length >= 2) {
vSwitchName = tokens[0].trim();
vlanId = tokens[1].trim();
vlanToken = tokens[1].trim();
if (!vlanToken.isEmpty()) {
vlanId = vlanToken;
}
}
s_logger.info("Preparing network on host " + hostMo.getContext().toString() + " for " + privateTrafficLabel);
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
}

View File

@ -2981,7 +2981,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
// 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.
if(tokens.length == 2 || tokens.length == 3) {
return new Pair<String, String>(tokens[0], tokens[1]);
String vlanToken = tokens[1];
if (vlanToken.isEmpty()) {
vlanToken = Vlan.UNTAGGED;
}
return new Pair<String, String>(tokens[0], vlanToken);
} else {
return new Pair<String, String>(nicTo.getName(), Vlan.UNTAGGED);
}

View File

@ -74,7 +74,10 @@ public class VmwareTrafficLabel implements TrafficLabel {
_vSwitchName = tokens[VMWARE_LABEL_FIELD_INDEX_NAME].trim();
}
if (tokens.length > VMWARE_LABEL_FIELD_INDEX_VLANID) {
_vlanId = tokens[VMWARE_LABEL_FIELD_INDEX_VLANID].trim();
String vlanToken = tokens[VMWARE_LABEL_FIELD_INDEX_VLANID].trim();
if (!vlanToken.isEmpty()) {
_vlanId = vlanToken;
}
}
if (tokens.length > VMWARE_LABEL_FIELD_INDEX_VSWITCH_TYPE) {
_vSwitchType = VirtualSwitchType.getType(tokens[VMWARE_LABEL_FIELD_INDEX_VSWITCH_TYPE].trim());

View File

@ -461,7 +461,7 @@ public class HypervisorHostHelper {
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
//VMwareDVSPvlanConfigSpec pvlanSpec = null;
DVSSecurityPolicy secPolicy;
VMwareDVSPortSetting dvsPortSetting;
VMwareDVSPortSetting dvsPortSetting = null;
DVPortgroupConfigSpec dvPortGroupSpec;
DVPortgroupConfigInfo dvPortgroupInfo;
//DVSConfigInfo dvsInfo;
@ -551,30 +551,21 @@ public class HypervisorHostHelper {
}
// Next, create the port group. For this, we need to create a VLAN spec.
if (vid == null) {
vlanSpec = createDVPortVlanSpec();
} else {
if (spvlanid == null) {
// Create vlan spec.
vlanSpec = createDVPortVlanIdSpec(vid);
} else {
// Create a pvlan spec. The pvlan spec is different from the pvlan config spec
// that we created earlier. The pvlan config spec is used to configure the switch
// with a <primary vlanId, secondary vlanId> tuple. The pvlan spec is used
// to configure a port group (i.e., a network) with a secondary vlan id. We don't
// need to mention more than the secondary vlan id because one secondary vlan id
// can be associated with only one primary vlan id. Give vCenter the secondary vlan id,
// and it will find out the associated primary vlan id and do the rest of the
// port group configuration.
pvlanSpec = createDVPortPvlanIdSpec(spvlanid);
}
}
// NOTE - VmwareDistributedVirtualSwitchPvlanSpec extends VmwareDistributedVirtualSwitchVlanSpec.
if (pvlanSpec != null) {
if (vid == null || spvlanid == null) {
vlanSpec = createDVPortVlanIdSpec(vid);
dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec);
} else if (spvlanid != null) {
// Create a pvlan spec. The pvlan spec is different from the pvlan config spec
// that we created earlier. The pvlan config spec is used to configure the switch
// with a <primary vlanId, secondary vlanId> tuple. The pvlan spec is used
// to configure a port group (i.e., a network) with a secondary vlan id. We don't
// need to mention more than the secondary vlan id because one secondary vlan id
// can be associated with only one primary vlan id. Give vCenter the secondary vlan id,
// and it will find out the associated primary vlan id and do the rest of the
// port group configuration.
pvlanSpec = createDVPortPvlanIdSpec(spvlanid);
dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, pvlanSpec);
} else {
dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, vlanSpec);
}
dvPortGroupSpec = createDvPortGroupSpec(networkName, dvsPortSetting, numPorts, autoExpandSupported);
@ -804,15 +795,11 @@ public class HypervisorHostHelper {
pvlanConfigSpec.setOperation(operation.toString());
return pvlanConfigSpec;
}
public static VmwareDistributedVirtualSwitchVlanIdSpec createDVPortVlanIdSpec(int vlanId) {
VmwareDistributedVirtualSwitchVlanIdSpec vlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
vlanIdSpec.setVlanId(vlanId);
return vlanIdSpec;
}
public static VmwareDistributedVirtualSwitchVlanSpec createDVPortVlanSpec() {
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = new VmwareDistributedVirtualSwitchVlanSpec();
return vlanSpec;
public static VmwareDistributedVirtualSwitchVlanIdSpec createDVPortVlanIdSpec(Integer vlanId) {
VmwareDistributedVirtualSwitchVlanIdSpec vlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
vlanIdSpec.setVlanId(vlanId == null ? 0 : vlanId.intValue());
return vlanIdSpec;
}
public static DVSSecurityPolicy createDVSSecurityPolicy() {