From 2cc3efbdd1c98350f0966b4ce650dd4e1447e64e Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Wed, 28 Sep 2016 01:19:27 +0530 Subject: [PATCH] CLOUDSTACK-9475: Attaching to PVLAN on VMware dvSwtich fails on VR reboot handle casting VmwareDistributedVirtualSwitchVlanSpec, to appropriate class corresponding to vlan and pvlan. For pvvlan cast to VmwareDistributedVirtualSwitchPvlanSpec for vlan cast to VmwareDistributedVirtualSwitchVlanIdSpec --- .../vmware/mo/HypervisorHostHelper.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 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 67b4c5e6901..76a303768b2 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -833,12 +833,21 @@ public class HypervisorHostHelper { } } - VmwareDistributedVirtualSwitchVlanIdSpec oldVlanSpec = (VmwareDistributedVirtualSwitchVlanIdSpec)(( - VMwareDVSPortSetting)currentDvPortgroupInfo.getDefaultPortConfig()).getVlan(); - VmwareDistributedVirtualSwitchVlanIdSpec newVlanSpec = (VmwareDistributedVirtualSwitchVlanIdSpec)(( - VMwareDVSPortSetting)newDvPortGroupSpec.getDefaultPortConfig()).getVlan(); - int oldVlanId = oldVlanSpec.getVlanId(); - int newVlanId = newVlanSpec.getVlanId(); + int oldVlanId, newVlanId; + VmwareDistributedVirtualSwitchVlanSpec oldVlanSpec = (VmwareDistributedVirtualSwitchVlanSpec)((VMwareDVSPortSetting)currentDvPortgroupInfo.getDefaultPortConfig()).getVlan(); + VmwareDistributedVirtualSwitchVlanSpec newVlanSpec = (VmwareDistributedVirtualSwitchVlanSpec)((VMwareDVSPortSetting)newDvPortGroupSpec.getDefaultPortConfig()).getVlan(); + if (oldVlanSpec instanceof VmwareDistributedVirtualSwitchPvlanSpec && newVlanSpec instanceof VmwareDistributedVirtualSwitchPvlanSpec) { + VmwareDistributedVirtualSwitchPvlanSpec oldpVlanSpec = (VmwareDistributedVirtualSwitchPvlanSpec) oldVlanSpec; + VmwareDistributedVirtualSwitchPvlanSpec newpVlanSpec = (VmwareDistributedVirtualSwitchPvlanSpec) newVlanSpec; + oldVlanId = oldpVlanSpec.getPvlanId(); + newVlanId = newpVlanSpec.getPvlanId(); + } else { + VmwareDistributedVirtualSwitchVlanIdSpec oldVlanIdSpec = (VmwareDistributedVirtualSwitchVlanIdSpec) oldVlanSpec; + VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = (VmwareDistributedVirtualSwitchVlanIdSpec) newVlanSpec; + oldVlanId = oldVlanIdSpec.getVlanId(); + newVlanId = newVlanIdSpec.getVlanId(); + } + if (oldVlanId != newVlanId) { s_logger.info("Detected that new VLAN [" + newVlanId + "] of dvPortGroup [" + dvPortGroupName + "] is different from current VLAN [" + oldVlanId + "]");