bug : CS-15080 - check traffic label at host discovery stage also

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8340ed52
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8340ed52
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8340ed52

Branch: refs/heads/3.0.x
Commit: 8340ed52d4fcee1cf8b9964af2f87f8a0eb54b20
Parents: 98f488e
Author: Kelven Yang <[email protected]>
Authored: Fri May 25 10:18:26 2012 -0700
Committer: Kelven Yang <[email protected]>
Committed: Fri May 25 10:18:42 2012 -0700

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/VmwareManagerImpl.java |   17 +++++-------
 .../hypervisor/vmware/VmwareServerDiscoverer.java  |   21 ++++++--------
 2 files changed, 16 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8340ed52/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java 
b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java
index 69651c9..f6ab8af 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) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8340ed52/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java 
b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index db8ad87..06796c3 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<String, String> 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);

Reply via email to