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 <sateesh@apache.org>
(cherry picked from commit eaea8f8c5f)

Signed-off-by: animesh <animesh@apache.org>
This commit is contained in:
Sateesh Chodapuneedi 2013-08-29 14:52:20 +05:30 committed by animesh
parent 30c5388253
commit f09afea067
2 changed files with 11 additions and 11 deletions

View File

@ -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);
}

View File

@ -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);