Search in sources :

Example 1 with AsyncProgressUpdater

use of io.cloudslang.content.vmware.entities.AsyncProgressUpdater in project cs-actions by CloudSlang.

the class DeployOvfTemplateService method deployOvfTemplate.

public void deployOvfTemplate(final HttpInputs httpInputs, final VmInputs vmInputs, final String templatePath, final Map<String, String> ovfNetworkMap, final Map<String, String> ovfPropertyMap) throws Exception {
    final ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
    try {
        final ImmutablePair<ManagedObjectReference, OvfCreateImportSpecResult> pair = createLeaseSetup(connectionResources, vmInputs, templatePath, ovfNetworkMap, ovfPropertyMap);
        final ManagedObjectReference httpNfcLease = pair.getLeft();
        final OvfCreateImportSpecResult importSpecResult = pair.getRight();
        final HttpNfcLeaseInfo httpNfcLeaseInfo = getHttpNfcLeaseInfoWhenReady(connectionResources, httpNfcLease);
        final List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
        final ProgressUpdater progressUpdater = executor.isParallel() ? new AsyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease, connectionResources) : new SyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease, connectionResources);
        executor.execute(progressUpdater);
        transferVmdkFiles(templatePath, importSpecResult, deviceUrls, progressUpdater);
        executor.shutdown();
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }
}
Also used : SyncProgressUpdater(io.cloudslang.content.vmware.entities.SyncProgressUpdater) AsyncProgressUpdater(io.cloudslang.content.vmware.entities.AsyncProgressUpdater) ProgressUpdater(io.cloudslang.content.vmware.entities.ProgressUpdater) SyncProgressUpdater(io.cloudslang.content.vmware.entities.SyncProgressUpdater) ConnectionResources(io.cloudslang.content.vmware.connection.ConnectionResources) OvfCreateImportSpecResult(com.vmware.vim25.OvfCreateImportSpecResult) HttpNfcLeaseInfo(com.vmware.vim25.HttpNfcLeaseInfo) OvfUtils.getHttpNfcLeaseInfo(io.cloudslang.content.vmware.utils.OvfUtils.getHttpNfcLeaseInfo) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) HttpNfcLeaseDeviceUrl(com.vmware.vim25.HttpNfcLeaseDeviceUrl) AsyncProgressUpdater(io.cloudslang.content.vmware.entities.AsyncProgressUpdater)

Aggregations

HttpNfcLeaseDeviceUrl (com.vmware.vim25.HttpNfcLeaseDeviceUrl)1 HttpNfcLeaseInfo (com.vmware.vim25.HttpNfcLeaseInfo)1 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)1 OvfCreateImportSpecResult (com.vmware.vim25.OvfCreateImportSpecResult)1 ConnectionResources (io.cloudslang.content.vmware.connection.ConnectionResources)1 AsyncProgressUpdater (io.cloudslang.content.vmware.entities.AsyncProgressUpdater)1 ProgressUpdater (io.cloudslang.content.vmware.entities.ProgressUpdater)1 SyncProgressUpdater (io.cloudslang.content.vmware.entities.SyncProgressUpdater)1 OvfUtils.getHttpNfcLeaseInfo (io.cloudslang.content.vmware.utils.OvfUtils.getHttpNfcLeaseInfo)1