CLOUDSTACK-3311: PVLAN - vmware dvswitch - stop/start nd reboot Virtual router FAIL

Description:

    Fix logic to check for secondary pvlan id already existing on vmware DVS, and
    fix int to Integer comparison.
This commit is contained in:
Vijayendra Bhamidipati 2013-07-12 05:02:26 -07:00 committed by Sheng Yang
parent a9549a7f81
commit cdbcc66637

View File

@ -604,19 +604,29 @@ public class HypervisorHostHelper {
private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch, private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
Integer vid, Integer spvlanid) throws Exception { Integer vid, Integer spvlanid) throws Exception {
Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch); Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch);
if (vlanmap.size() != 0) { if (!vlanmap.isEmpty()) {
// Then either vid or pvlanid or both are already being used. // Then either vid or pvlanid or both are already being used. Check how.
if (vlanmap.containsKey(vid) && vlanmap.get(vid) != HypervisorHostHelper.PvlanType.promiscuous) { // First the primary pvlan id.
if (vlanmap.containsKey(vid) && !vlanmap.get(vid).equals(HypervisorHostHelper.PvlanType.promiscuous)) {
// This VLAN ID is already setup as a non-promiscuous vlan id on the DVS. Throw an exception. // This VLAN ID is already setup as a non-promiscuous vlan id on the DVS. Throw an exception.
String msg = "VLAN ID " + vid + " is already in use as a " + vlanmap.get(vid).toString() + " VLAN on the DVSwitch"; String msg = "Specified primary PVLAN ID " + vid + " is already in use as a " + vlanmap.get(vid).toString() + " VLAN on the DVSwitch";
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} }
if ((vid != spvlanid) && vlanmap.containsKey(spvlanid) && vlanmap.get(spvlanid) != HypervisorHostHelper.PvlanType.isolated) { // Next the secondary pvlan id.
// This PVLAN ID is already setup as a non-isolated vlan id on the DVS. Throw an exception. if (spvlanid.equals(vid)) {
String msg = "PVLAN ID " + spvlanid + " is already in use as a " + vlanmap.get(spvlanid).toString() + " VLAN in the DVSwitch"; if (vlanmap.containsKey(spvlanid) && !vlanmap.get(spvlanid).equals(HypervisorHostHelper.PvlanType.promiscuous)) {
s_logger.error(msg); String msg = "Specified secondary PVLAN ID " + spvlanid + " is already in use as a " + vlanmap.get(spvlanid).toString() + " VLAN in the DVSwitch";
throw new Exception(msg); s_logger.error(msg);
throw new Exception(msg);
}
} else {
if (vlanmap.containsKey(spvlanid) && !vlanmap.get(spvlanid).equals(HypervisorHostHelper.PvlanType.isolated)) {
// This PVLAN ID is already setup as a non-isolated vlan id on the DVS. Throw an exception.
String msg = "Specified secondary PVLAN ID " + spvlanid + " is already in use as a " + vlanmap.get(spvlanid).toString() + " VLAN in the DVSwitch";
s_logger.error(msg);
throw new Exception(msg);
}
} }
} }