From 95766bef1ddff113f74559116fe460f6e42e02da Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 25 May 2012 10:55:21 -0700 Subject: [PATCH] bug : CS-15080 - check traffic label at host discovery stage also Reviewed-by: anthony --- .../hypervisor/vmware/VmwareManagerImpl.java | 17 +++++++-------- .../vmware/VmwareServerDiscoverer.java | 21 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java index 69651c9aa19..f6ab8afa305 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java @@ -403,11 +403,9 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis mor = serviceContext.getHostMorByPath(hostInventoryPath); String privateTrafficLabel = null; - if (_nexusVSwitchActive) { - privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel"); - if (privateTrafficLabel == null) { - privateTrafficLabel = _privateNetworkVSwitchName; - } + privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel"); + if (privateTrafficLabel == null) { + privateTrafficLabel = _privateNetworkVSwitchName; } if(mor != null) { @@ -428,12 +426,11 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } // prepare at least one network on the vswitch to enable OVF importing - String managementPortGroupName = getManagementPortGroupByHost(hostMo); - assert(managementPortGroupName != null); - HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName); String vlanId = null; - if(spec.getVlanId() != 0) { - vlanId = String.valueOf(spec.getVlanId()); + if(privateTrafficLabel != null) { + String[] tokens = privateTrafficLabel.split(","); + if(tokens.length == 2) + vlanId = tokens[1]; } if(!_nexusVSwitchActive) { diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index db8ad872260..06796c3878f 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -113,15 +113,13 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer String publicTrafficLabel = null; String guestTrafficLabel = null; Map vsmCredentials = null; + + privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware); + if (privateTrafficLabel != null) { + s_logger.info("Detected private network label : " + privateTrafficLabel); + } + if (_vmwareMgr.getNexusVSwitchGlobalParameter()) { - if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter() != null && _vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { - // Get physical network label - privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware); - if (privateTrafficLabel != null) { - s_logger.info("Detected private network label : " + privateTrafficLabel); - } - } - DataCenterVO zone = _dcDao.findById(dcId); NetworkType zoneType = zone.getNetworkType(); @@ -151,11 +149,10 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer VmwareContext context = null; try { context = VmwareContextFactory.create(url.getHost(), username, password); + if (privateTrafficLabel != null) + context.registerStockObject("privateTrafficLabel", privateTrafficLabel); + if (_vmwareMgr.getNexusVSwitchGlobalParameter()) { - if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { - if (privateTrafficLabel != null) - context.registerStockObject("privateTrafficLabel", privateTrafficLabel); - } if (vsmCredentials != null) { s_logger.info("Stocking credentials of Nexus VSM"); context.registerStockObject("vsmcredentials", vsmCredentials);