1. Added skipCA check for the task
2. Request timeout and connection timeout
This commit is contained in:
Родитель
a47e3525a4
Коммит
a65b65ff3d
|
@ -1,7 +1,10 @@
|
|||
|
||||
|
||||
public class ConnectionData {
|
||||
|
||||
private String userName;
|
||||
private String password;
|
||||
private String url;
|
||||
private boolean skipCACheck;
|
||||
|
||||
public ConnectionData(String vCenterUrl, String vCenterUserName, String vCenterPassword, boolean skipCACheck) {
|
||||
this.userName = vCenterUserName;
|
||||
this.password = vCenterPassword;
|
||||
|
@ -9,8 +12,19 @@ public class ConnectionData {
|
|||
this.skipCACheck = skipCACheck;
|
||||
}
|
||||
|
||||
public String userName;
|
||||
public String password;
|
||||
public String url;
|
||||
public boolean skipCACheck;
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean isSkipCACheck() {
|
||||
return skipCACheck;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import java.util.*;
|
||||
import com.sun.xml.ws.client.BindingProviderProperties;
|
||||
import com.vmware.vim25.*;
|
||||
|
||||
import javax.xml.ws.BindingProvider;
|
||||
|
||||
import com.vmware.vim25.*;
|
||||
import java.util.*;
|
||||
|
||||
public class VMWareImpl implements IVMWare {
|
||||
|
||||
|
@ -497,19 +497,21 @@ public class VMWareImpl implements IVMWare {
|
|||
vimPort = vimService.getVimPort();
|
||||
|
||||
Map<String, Object> reqContext = ((BindingProvider) vimPort).getRequestContext();
|
||||
reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, connData.url);
|
||||
reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, connData.getUrl());
|
||||
reqContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
|
||||
reqContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 30 * 60 * 1000);
|
||||
reqContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 5 * 60 * 1000);
|
||||
ManagedObjectReference serviceInstance = new ManagedObjectReference();
|
||||
serviceInstance.setType("ServiceInstance");
|
||||
serviceInstance.setValue("ServiceInstance");
|
||||
|
||||
if (connData.skipCACheck) {
|
||||
if (connData.isSkipCACheck()) {
|
||||
SkipCACheck.AllowUntrustedConnections();
|
||||
}
|
||||
|
||||
serviceContent = vimPort.retrieveServiceContent(serviceInstance);
|
||||
rootFolder = serviceContent.getRootFolder();
|
||||
userSession = vimPort.login(serviceContent.getSessionManager(), connData.userName, connData.password,
|
||||
userSession = vimPort.login(serviceContent.getSessionManager(), connData.getUserName(), connData.getPassword(),
|
||||
null);
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-rt</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -80,7 +80,7 @@ public class InMemoryVMWareImpl implements IVMWare {
|
|||
}
|
||||
|
||||
public void connect(ConnectionData connData) throws Exception {
|
||||
if (connData.password.equals("InvalidPassword") || !connData.skipCACheck) {
|
||||
if (connData.getPassword().equals("InvalidPassword") || !connData.isSkipCACheck()) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче