|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.storage.resource; |
18 | 18 |
|
| 19 | +import javax.annotation.PostConstruct; |
| 20 | +import javax.inject.Inject; |
| 21 | + |
19 | 22 | import org.apache.log4j.Logger; |
20 | 23 |
|
| 24 | +import com.cloud.configuration.Config; |
| 25 | +import com.cloud.configuration.dao.ConfigurationDao; |
21 | 26 | import com.cloud.hypervisor.vmware.util.VmwareClient; |
22 | 27 | import com.cloud.hypervisor.vmware.util.VmwareContext; |
23 | 28 | import com.cloud.hypervisor.vmware.util.VmwareContextPool; |
| 29 | +import com.cloud.utils.NumbersUtil; |
24 | 30 |
|
25 | 31 | public class VmwareSecondaryStorageContextFactory { |
26 | 32 | private static final Logger s_logger = Logger.getLogger(VmwareSecondaryStorageContextFactory.class); |
27 | 33 |
|
28 | 34 | private static volatile int s_seq = 1; |
29 | 35 |
|
30 | 36 | private static VmwareContextPool s_pool; |
| 37 | + private static ConfigurationDao s_configDao; |
| 38 | + |
| 39 | + @Inject ConfigurationDao _configDao; |
31 | 40 |
|
32 | 41 | public static void initFactoryEnvironment() { |
33 | 42 | System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory"); |
34 | 43 | s_pool = new VmwareContextPool(); |
35 | 44 | } |
36 | 45 |
|
| 46 | + @PostConstruct |
| 47 | + void init() { |
| 48 | + s_configDao = _configDao; |
| 49 | + } |
| 50 | + |
37 | 51 | public static VmwareContext create(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception { |
38 | 52 | assert(vCenterAddress != null); |
39 | 53 | assert(vCenterUserName != null); |
40 | 54 | assert(vCenterPassword != null); |
41 | 55 |
|
42 | 56 | String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService"; |
| 57 | + int vCenterSessionTimeout = NumbersUtil.parseInt(s_configDao.getValue(Config.VmwareVcenterSessionTimeout.key()), 600) * 1000; |
43 | 58 | VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++); |
44 | | - vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword); |
| 59 | + vimClient.setVcenterSessionTimeout(vCenterSessionTimeout); |
| 60 | + vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword); |
45 | 61 | VmwareContext context = new VmwareContext(vimClient, vCenterAddress); |
46 | 62 | assert(context != null); |
47 | 63 |
|
|
0 commit comments