mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5069. Added global config 'vmware.vcenter.session.timeout' to make the vCenter session timeout value configurable.
This commit is contained in:
parent
8321ea4d78
commit
90fb76a72c
@ -368,6 +368,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||||||
_cmdExecLogDao.persist(execLog);
|
_cmdExecLogDao.persist(execLog);
|
||||||
cmd.setContextParam("execid", String.valueOf(execLog.getId()));
|
cmd.setContextParam("execid", String.valueOf(execLog.getId()));
|
||||||
cmd.setContextParam("noderuninfo", String.format("%d-%d", _clusterMgr.getManagementNodeId(), _clusterMgr.getCurrentRunId()));
|
cmd.setContextParam("noderuninfo", String.format("%d-%d", _clusterMgr.getManagementNodeId(), _clusterMgr.getCurrentRunId()));
|
||||||
|
cmd.setContextParam("vCenterSessionTimeout", String.valueOf(_vmwareMgr.getVcenterSessionTimeout()));
|
||||||
|
|
||||||
if(cmd instanceof BackupSnapshotCommand ||
|
if(cmd instanceof BackupSnapshotCommand ||
|
||||||
cmd instanceof CreatePrivateTemplateFromVolumeCommand ||
|
cmd instanceof CreatePrivateTemplateFromVolumeCommand ||
|
||||||
|
|||||||
@ -69,5 +69,7 @@ public interface VmwareManager {
|
|||||||
|
|
||||||
public String getRootDiskController();
|
public String getRootDiskController();
|
||||||
|
|
||||||
|
public int getVcenterSessionTimeout();
|
||||||
|
|
||||||
boolean isLegacyZone(long dcId);
|
boolean isLegacyZone(long dcId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,6 +177,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
int _additionalPortRangeStart;
|
int _additionalPortRangeStart;
|
||||||
int _additionalPortRangeSize;
|
int _additionalPortRangeSize;
|
||||||
int _routerExtraPublicNics = 2;
|
int _routerExtraPublicNics = 2;
|
||||||
|
int _vCenterSessionTimeout = 1200000; // Timeout in milliseconds
|
||||||
|
|
||||||
String _reserveCpu = "false";
|
String _reserveCpu = "false";
|
||||||
|
|
||||||
@ -279,6 +280,9 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
|
|
||||||
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
|
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
|
||||||
|
|
||||||
|
_vCenterSessionTimeout = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareVcenterSessionTimeout.key()), 1200) * 1000;
|
||||||
|
s_logger.info("VmwareManagerImpl config - vmware.vcenter.session.timeout: " + _vCenterSessionTimeout);
|
||||||
|
|
||||||
_reserveCpu = _configDao.getValue(Config.VmwareReserveCpu.key());
|
_reserveCpu = _configDao.getValue(Config.VmwareReserveCpu.key());
|
||||||
if(_reserveCpu == null || _reserveCpu.isEmpty()) {
|
if(_reserveCpu == null || _reserveCpu.isEmpty()) {
|
||||||
_reserveCpu = "false";
|
_reserveCpu = "false";
|
||||||
@ -985,6 +989,11 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
return _rootDiskController;
|
return _rootDiskController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVcenterSessionTimeout() {
|
||||||
|
return _vCenterSessionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Class<?>> getCommands() {
|
public List<Class<?>> getCommands() {
|
||||||
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||||
|
|||||||
@ -63,6 +63,7 @@ public class VmwareContextFactory {
|
|||||||
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
|
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
|
||||||
|
|
||||||
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
||||||
|
vimClient.setVcenterSessionTimeout(s_vmwareMgr.getVcenterSessionTimeout());
|
||||||
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
||||||
|
|
||||||
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
||||||
@ -83,13 +84,14 @@ public class VmwareContextFactory {
|
|||||||
if(context == null) {
|
if(context == null) {
|
||||||
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
||||||
} else {
|
} else {
|
||||||
if(!context.validate()) {
|
// Validate current context and verify if vCenter session timeout value of the context matches the timeout value set by Admin
|
||||||
|
if(!context.validate() || (context.getVimClient().getVcenterSessionTimeout() != s_vmwareMgr.getVcenterSessionTimeout())) {
|
||||||
s_logger.info("Validation of the context faild. dispose and create a new one");
|
s_logger.info("Validation of the context faild. dispose and create a new one");
|
||||||
context.close();
|
context.close();
|
||||||
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(context != null) {
|
if(context != null) {
|
||||||
context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);
|
context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public class VmwareSecondaryStorageContextFactory {
|
|||||||
|
|
||||||
private static VmwareContextPool s_pool;
|
private static VmwareContextPool s_pool;
|
||||||
|
|
||||||
|
public static int s_vCenterSessionTimeout = 1200000; // Timeout in milliseconds
|
||||||
|
|
||||||
public static void initFactoryEnvironment() {
|
public static void initFactoryEnvironment() {
|
||||||
System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
|
System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
|
||||||
s_pool = new VmwareContextPool();
|
s_pool = new VmwareContextPool();
|
||||||
@ -43,6 +45,7 @@ public class VmwareSecondaryStorageContextFactory {
|
|||||||
|
|
||||||
String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
|
String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
|
||||||
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
||||||
|
vimClient.setVcenterSessionTimeout(s_vCenterSessionTimeout);
|
||||||
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
||||||
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
||||||
assert(context != null);
|
assert(context != null);
|
||||||
@ -58,7 +61,8 @@ public class VmwareSecondaryStorageContextFactory {
|
|||||||
if(context == null) {
|
if(context == null) {
|
||||||
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
||||||
} else {
|
} else {
|
||||||
if(!context.validate()) {
|
// Validate current context and verify if vCenter session timeout value of the context matches the timeout value set by Admin
|
||||||
|
if(!context.validate() || (context.getVimClient().getVcenterSessionTimeout() != s_vCenterSessionTimeout)) {
|
||||||
s_logger.info("Validation of the context faild. dispose and create a new one");
|
s_logger.info("Validation of the context faild. dispose and create a new one");
|
||||||
context.close();
|
context.close();
|
||||||
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
||||||
@ -76,4 +80,9 @@ public class VmwareSecondaryStorageContextFactory {
|
|||||||
public static void invalidate(VmwareContext context) {
|
public static void invalidate(VmwareContext context) {
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setVcenterSessionTimeout(int timeout) {
|
||||||
|
s_vCenterSessionTimeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
import com.cloud.serializer.GsonHelper;
|
import com.cloud.serializer.GsonHelper;
|
||||||
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@ -206,6 +207,8 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vCenterSessionTimeout = NumbersUtil.parseInt(cmd.getContextParam("vCenterSessionTimeout"), 1200000);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_resource.ensureOutgoingRuleForAddress(vCenterAddress);
|
_resource.ensureOutgoingRuleForAddress(vCenterAddress);
|
||||||
|
|
||||||
@ -213,9 +216,10 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
|||||||
if(context == null) {
|
if(context == null) {
|
||||||
s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username
|
s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username
|
||||||
+ ", password: " + StringUtils.getMaskedPasswordForDisplay(password));
|
+ ", password: " + StringUtils.getMaskedPasswordForDisplay(password));
|
||||||
|
VmwareSecondaryStorageContextFactory.setVcenterSessionTimeout(vCenterSessionTimeout);
|
||||||
context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
|
context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
|
context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
|
||||||
context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
|
context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
|
||||||
|
|||||||
@ -263,6 +263,7 @@ public enum Config {
|
|||||||
VmwareRecycleHungWorker("Advanced", ManagementServer.class, Boolean.class, "vmware.recycle.hung.wokervm", "false", "Specify whether or not to recycle hung worker VMs", null),
|
VmwareRecycleHungWorker("Advanced", ManagementServer.class, Boolean.class, "vmware.recycle.hung.wokervm", "false", "Specify whether or not to recycle hung worker VMs", null),
|
||||||
VmwareHungWorkerTimeout("Advanced", ManagementServer.class, Long.class, "vmware.hung.wokervm.timeout", "7200", "Worker VM timeout in seconds", null),
|
VmwareHungWorkerTimeout("Advanced", ManagementServer.class, Long.class, "vmware.hung.wokervm.timeout", "7200", "Worker VM timeout in seconds", null),
|
||||||
VmwareEnableNestedVirtualization("Advanced", ManagementServer.class, Boolean.class, "vmware.nested.virtualization", "false", "When set to true this will enable nested virtualization when this is supported by the hypervisor", null),
|
VmwareEnableNestedVirtualization("Advanced", ManagementServer.class, Boolean.class, "vmware.nested.virtualization", "false", "When set to true this will enable nested virtualization when this is supported by the hypervisor", null),
|
||||||
|
VmwareVcenterSessionTimeout("Advanced", ManagementServer.class, Long.class, "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", null),
|
||||||
|
|
||||||
// Midonet
|
// Midonet
|
||||||
MidoNetAPIServerAddress("Network", ManagementServer.class, String.class, "midonet.apiserver.address", "http://localhost:8081", "Specify the address at which the Midonet API server can be contacted (if using Midonet)", null),
|
MidoNetAPIServerAddress("Network", ManagementServer.class, String.class, "midonet.apiserver.address", "http://localhost:8081", "Specify the address at which the Midonet API server can be contacted (if using Midonet)", null),
|
||||||
|
|||||||
@ -751,3 +751,5 @@ CREATE VIEW `cloud`.`domain_router_view` AS
|
|||||||
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
|
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
|
||||||
and async_job.instance_type = 'DomainRouter'
|
and async_job.instance_type = 'DomainRouter'
|
||||||
and async_job.job_status = 0;
|
and async_job.job_status = 0;
|
||||||
|
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", "1200", NULL,NULL,0);
|
||||||
|
|
||||||
|
|||||||
@ -109,6 +109,7 @@ public class VmwareClient {
|
|||||||
private VimPortType vimPort;
|
private VimPortType vimPort;
|
||||||
private String serviceCookie;
|
private String serviceCookie;
|
||||||
private final String SVC_INST_NAME = "ServiceInstance";
|
private final String SVC_INST_NAME = "ServiceInstance";
|
||||||
|
private int vCenterSessionTimeout = 1200000; // Timeout in milliseconds
|
||||||
|
|
||||||
private boolean isConnected = false;
|
private boolean isConnected = false;
|
||||||
|
|
||||||
@ -132,8 +133,8 @@ public class VmwareClient {
|
|||||||
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
||||||
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
|
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
|
||||||
|
|
||||||
ctxt.put("com.sun.xml.internal.ws.request.timeout", 1200000);
|
ctxt.put("com.sun.xml.internal.ws.request.timeout", vCenterSessionTimeout);
|
||||||
ctxt.put("com.sun.xml.internal.ws.connect.timeout", 1200000);
|
ctxt.put("com.sun.xml.internal.ws.connect.timeout", vCenterSessionTimeout);
|
||||||
|
|
||||||
ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
|
ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
|
||||||
|
|
||||||
@ -616,4 +617,13 @@ public class VmwareClient {
|
|||||||
}
|
}
|
||||||
return propmor;
|
return propmor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVcenterSessionTimeout(int vCenterSessionTimeout) {
|
||||||
|
this.vCenterSessionTimeout = vCenterSessionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVcenterSessionTimeout() {
|
||||||
|
return this.vCenterSessionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ public class TestVmwareContextFactory {
|
|||||||
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
|
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
|
||||||
|
|
||||||
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
|
||||||
|
vimClient.setVcenterSessionTimeout(1200000);
|
||||||
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
|
||||||
|
|
||||||
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user