Updated Branches:
  refs/heads/4.2-forward 61ebfad44 -> eaea8f8c5

CLOUDSTACK-4435 [VMWARE]System VM's are failed to start with Nexus enabled Zone

Since introducing pool of session contexts we no more have a dedicated context 
for each VMware hypervisor host.
Hence vsm credentials stored in session context cannot be retrieved always 
correctly. Fix is to register the vsm credentials after fetching context and 
the context gets recycled after use.

Signed-off-by: Sateesh Chodapuneedi <[email protected]>


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

Branch: refs/heads/4.2-forward
Commit: eaea8f8c5f21257f036d4c13ba1ec50c69664a52
Parents: 61ebfad
Author: Sateesh Chodapuneedi <[email protected]>
Authored: Thu Aug 29 14:52:20 2013 +0530
Committer: Sateesh Chodapuneedi <[email protected]>
Committed: Thu Aug 29 14:52:20 2013 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java   | 15 +++++----------
 .../hypervisor/vmware/mo/HypervisorHostHelper.java   |  7 ++++++-
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaea8f8c/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 7ff4918..16b829a 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -46,7 +46,6 @@ import java.util.concurrent.TimeUnit;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.configuration.Config;
 import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
@@ -202,6 +201,7 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
 import com.cloud.agent.api.to.StorageFilerTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.configuration.Config;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.Vlan;
 import com.cloud.exception.InternalErrorException;
@@ -219,7 +219,6 @@ import com.cloud.hypervisor.vmware.mo.DatastoreMO;
 import com.cloud.hypervisor.vmware.mo.DiskControllerType;
 import com.cloud.hypervisor.vmware.mo.FeatureKeyConstants;
 import com.cloud.hypervisor.vmware.mo.HostDatastoreSystemMO;
-import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
 import com.cloud.hypervisor.vmware.mo.HostMO;
 import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO;
 import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
@@ -362,6 +361,7 @@ public class VmwareResource implements StoragePoolResource, 
ServerResource, Vmwa
     protected String _privateNetworkVSwitchName;
     protected VmwareTrafficLabel _guestTrafficInfo = new 
VmwareTrafficLabel(TrafficType.Guest);
     protected VmwareTrafficLabel _publicTrafficInfo = new 
VmwareTrafficLabel(TrafficType.Public);
+    protected Map<String, String> _vsmCredentials = null;
     protected int _portsPerDvPortGroup;
     protected boolean _fullCloneFlag = false;
     protected boolean _instanceNameFlag = false;
@@ -1956,7 +1956,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                }
         } else {
             networkInfo = 
HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), 
"cloud.public",
-                    vmMo.getRunningHost(), vlanId, null, null, null, 
_ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false, 
BroadcastDomainType.Vlan);
+                    vmMo.getRunningHost(), vlanId, null, null, null, 
_ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false, 
BroadcastDomainType.Vlan, _vsmCredentials);
         }
 
         int nicIndex = allocPublicNicIndex(vmMo);
@@ -3525,7 +3525,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
             }
             networkInfo = 
HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, 
vlanId, svlanId,
                     nicTo.getNetworkRateMbps(), 
nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType,
-                    _portsPerDvPortGroup, nicTo.getGateway(), 
configureVServiceInNexus, nicTo.getBroadcastType());
+                    _portsPerDvPortGroup, nicTo.getGateway(), 
configureVServiceInNexus, nicTo.getBroadcastType(), _vsmCredentials);
         }
 
         return networkInfo;
@@ -6660,14 +6660,9 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                    VmwareHypervisorHost hostMo = this.getHyperHost(context);
                    _hostName = hostMo.getHyperHostName();
        
-                   Map<String, String> vsmCredentials;
                    if (_guestTrafficInfo.getVirtualSwitchType() == 
VirtualSwitchType.NexusDistributedVirtualSwitch ||
                            _publicTrafficInfo.getVirtualSwitchType() == 
VirtualSwitchType.NexusDistributedVirtualSwitch) {
-                       vsmCredentials = 
mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
-                       if (vsmCredentials != null) {
-                           s_logger.info("Stocking credentials while 
configuring resource.");
-                           context.registerStockObject("vsmcredentials", 
vsmCredentials);
-                       }
+                       _vsmCredentials = 
mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
                        _privateNetworkVSwitchName = 
mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
                    }
        

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaea8f8c/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
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 43c59fc..014a9f8 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -444,7 +444,8 @@ public class HypervisorHostHelper {
 
     public static Pair<ManagedObjectReference, String> prepareNetwork(String 
physicalNetwork, String namePrefix,
             HostMO hostMo, String vlanId, String secondaryvlanId, Integer 
networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs,
-            VirtualSwitchType vSwitchType, int numPorts, String gateway, 
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) 
throws Exception {
+            VirtualSwitchType vSwitchType, int numPorts, String gateway, 
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType,
+            Map<String, String> vsmCredentials) throws Exception {
         ManagedObjectReference morNetwork = null;
         VmwareContext context = hostMo.getContext();
         ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
@@ -577,6 +578,10 @@ public class HypervisorHostHelper {
             // TODO(sateesh): Optionally let user specify the burst coefficient
             long burstSize = 5 * averageBandwidth / 8;
 
+            if (vsmCredentials != null) {
+                s_logger.info("Stocking credentials of Nexus VSM");
+                context.registerStockObject("vsmcredentials", vsmCredentials);
+            }
             if (!dataCenterMo.hasDvPortGroup(networkName)) {
                 s_logger.info("Port profile " + networkName + " not found.");
                 createPortProfile(context, physicalNetwork, networkName, vid, 
networkRateMbps, peakBandwidth, burstSize, gateway, configureVServiceInNexus);

Reply via email to