private long getImportSizeBytes(OvfCreateImportSpecResult importResult) { List<OvfFileItem> items = importResult.getFileItem(); if (items == null) { return 0; } long totalBytes = 0; for (OvfFileItem fi : items) { totalBytes += fi.getSize(); } return totalBytes; }
protected String computeDiskSourceUri(String basePath, OvfFileItem ovfFileItem) { String s = ovfFileItem.getPath(); if (s.startsWith("https://") || s.startsWith("http://") || s.startsWith("file://")) { return s; } return basePath + s; }
private void transferVmdkFiles(final String ovfPath, final OvfCreateImportSpecResult importSpecResult, final List<HttpNfcLeaseDeviceUrl> deviceUrls, final ProgressUpdater progressUpdater) throws Exception { for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) { final String deviceKey = deviceUrl.getImportKey(); for (OvfFileItem fileItem : importSpecResult.getFileItem()) { if (deviceKey.equals(fileItem.getDeviceId())) { final TransferVmdkTask transferVmdkTask = getTransferVmdkTask(ovfPath, progressUpdater, deviceUrl, fileItem); executor.execute(transferVmdkTask); break; } } } }
@NotNull private TransferVmdkTask getTransferVmdkTask(final String ovfPath, final ProgressUpdater progressUpdater, final HttpNfcLeaseDeviceUrl deviceUrl, final OvfFileItem fileItem) throws Exception { final URL vmDiskUrl = new URL(deviceUrl.getUrl()); final ITransferVmdkFrom transferVmdkFrom = getTransferVmdK(ovfPath, fileItem.getPath()); final TransferVmdkToUrl toUrl = new TransferVmdkToUrl(vmDiskUrl, fileItem.isCreate()); return new TransferVmdkTask(transferVmdkFrom, toUrl, progressUpdater); }
private long getDisksTotalNoBytes(final OvfCreateImportSpecResult importSpecResult) { long disksTotalNoBytes = 0; for (final OvfFileItem item : importSpecResult.getFileItem()) { if (item.getCimType() == DISK_DRIVE_CIM_TYPE) { disksTotalNoBytes += item.getSize(); } } return disksTotalNoBytes; }
public static long calcTotalBytes(OvfCreateImportSpecResult ovfImportResult) { List<OvfFileItem> fileItemArr = ovfImportResult.getFileItem(); long totalBytes = 0; if (fileItemArr != null) { for (OvfFileItem fi : fileItemArr) { totalBytes += fi.getSize(); } } return totalBytes; }