From cdbcc6663718fc92c20e576c3e958d6c2276aca0 Mon Sep 17 00:00:00 2001 From: Vijayendra Bhamidipati Date: Fri, 12 Jul 2013 05:02:26 -0700 Subject: [PATCH] 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. --- .../vmware/mo/HypervisorHostHelper.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java index dc1486a2ee5..dd0f88902d4 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -604,19 +604,29 @@ public class HypervisorHostHelper { private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch, Integer vid, Integer spvlanid) throws Exception { Map vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch); - if (vlanmap.size() != 0) { - // Then either vid or pvlanid or both are already being used. - if (vlanmap.containsKey(vid) && vlanmap.get(vid) != HypervisorHostHelper.PvlanType.promiscuous) { + if (!vlanmap.isEmpty()) { + // Then either vid or pvlanid or both are already being used. Check how. + // 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. - 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); throw new Exception(msg); } - if ((vid != spvlanid) && vlanmap.containsKey(spvlanid) && vlanmap.get(spvlanid) != HypervisorHostHelper.PvlanType.isolated) { - // This PVLAN ID is already setup as a non-isolated vlan id on the DVS. Throw an exception. - String msg = "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); + // Next the secondary pvlan id. + if (spvlanid.equals(vid)) { + if (vlanmap.containsKey(spvlanid) && !vlanmap.get(spvlanid).equals(HypervisorHostHelper.PvlanType.promiscuous)) { + 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); + } + } 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); + } } }