use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection in project photon-model by vmware.
the class VSphereIOThreadPool method execute.
private void execute(URI adapterReference, AuthCredentialsServiceState auth, ConnectionCallback callback) {
BasicConnection connection = new BasicConnection();
// ignores the certificate for testing purposes
if (VSPHERE_IGNORE_CERTIFICATE_WARNINGS) {
connection.setIgnoreSslErrors(true);
} else {
connection.setTrustManager(ServerX509TrustManager.getInstance());
}
if (UriPaths.IAAS_API_ENABLED && !StringUtils.equalsIgnoreCase(auth.type, "Username")) {
connection.setToken(EncryptionUtils.decrypt(auth.privateKey));
} else {
connection.setUsername(auth.privateKeyId);
connection.setPassword(EncryptionUtils.decrypt(auth.privateKey));
}
connection.setURI(adapterReference);
// don't connect now, but as late as possible as the session can expire
executeCallback(connection, callback);
}
use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection in project photon-model by vmware.
the class BaseVSphereAdapterTest method createConnection.
public BasicConnection createConnection() {
if (isMock()) {
throw new IllegalStateException("Cannot create connection in while mock is true");
}
BasicConnection connection = new BasicConnection();
connection.setIgnoreSslErrors(true);
connection.setUsername(this.vcUsername);
connection.setPassword(this.vcPassword);
connection.setURI(URI.create(this.vcUrl));
connection.connect();
return connection;
}
use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection in project photon-model by vmware.
the class VapiConnection method createFromVimConnection.
public static VapiConnection createFromVimConnection(Connection connection) {
VapiConnection vapiConnection = new VapiConnection(getVapiUri(connection.getURI()));
vapiConnection.setUsername(connection.getUsername());
vapiConnection.setPassword(connection.getPassword());
if (connection instanceof BasicConnection) {
BasicConnection basicConn = (BasicConnection) connection;
if (basicConn.isIgnoreSslErrors()) {
vapiConnection.setClient(VapiConnection.newUnsecureHttpClient());
} else if (basicConn.getTrustManager() != null) {
vapiConnection.setClient(VapiConnection.newDefaultHttpClient(basicConn.getTrustManager()));
} else {
vapiConnection.setClient(VapiConnection.newDefaultHttpClient());
}
}
return vapiConnection;
}
use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection in project photon-model by vmware.
the class TestVSphereLibraryProvisionTaskWithStorage method deployFromLibraryWithAdditionalDisks.
@Test
public void deployFromLibraryWithAdditionalDisks() throws Throwable {
ComputeService.ComputeState vm = provisionVMAndGetState(true, true);
try {
if (vm == null) {
return;
}
// Verify that the disk is resized
BasicConnection connection = createConnection();
GetMoRef get = new GetMoRef(connection);
List<VirtualDisk> virtualDisks = fetchAllVirtualDisks(vm, get);
assertEquals(3, virtualDisks.size());
assertEquals(3, vm.diskLinks.size());
List<DeferredResult<DiskService.DiskState>> disks = vm.diskLinks.stream().map(link -> {
Operation getOp = Operation.createGet(this.host, link).setReferer(this.host.getReferer());
return this.host.sendWithDeferredResult(getOp, DiskService.DiskState.class);
}).collect(Collectors.toList());
DeferredResult.allOf(disks).thenAccept(diskStates -> diskStates.stream().forEach(ds -> {
assertNotNull(ds.customProperties);
assertNotNull(ds.sourceImageReference);
assertNotNull(ds.customProperties.get(PROVIDER_DISK_UNIQUE_ID));
}));
} finally {
if (vm != null) {
deleteVmAndWait(vm);
}
}
}
use of com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection in project photon-model by vmware.
the class TestVSphereLibraryProvisionTaskWithDay2 method deployFromLibraryWithShutdown.
@Test
public void deployFromLibraryWithShutdown() throws Throwable {
ComputeService.ComputeState vm = provisionVMAndGetState();
try {
if (vm == null) {
return;
}
// test shutdown Guest OS resource operation
shutdownGuestOS(vm);
// Verify that the disk is resized and is reflected even for a POWERED_OFF vm
BasicConnection connection = createConnection();
GetMoRef get = new GetMoRef(connection);
verifyDiskSize(vm, get, HDD_DISK_SIZE);
} finally {
if (vm != null) {
deleteVmAndWait(vm);
}
}
}
Aggregations