Skip to content

Commit 7ff8347

Browse files
committed
fix for ingestion volume, nic fail
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent d678a78 commit 7ff8347

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

server/src/main/java/org/apache/cloudstack/ingestion/VmIngestionManagerImpl.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,11 @@ public UserVmResponse importUnmanagedInstance(ImportUnmanageInstanceCmd cmd) {
343343
null, caller, true, null, owner.getAccountId(), userId,
344344
serviceOffering, diskOffering, null, null, hostName,
345345
cluster.getHypervisorType(), new HashMap<>(), powerState);
346-
if (userVm != null) {
346+
} catch (InsufficientCapacityException ice) {
347+
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ice.getMessage());
348+
}
349+
if (userVm != null) {
350+
try {
347351
ingestDisk(rootDisk, userVm, diskOffering, Volume.Type.ROOT, String.format("ROOT-%d", userVm.getId()), rootDiskSize, template, owner, null);
348352
Set<String> disks = dataDiskOfferingMap.keySet();
349353
for (String diskId : disks) {
@@ -354,7 +358,11 @@ public UserVmResponse importUnmanagedInstance(ImportUnmanageInstanceCmd cmd) {
354358
}
355359
}
356360
}
361+
} catch (Exception e) {
362+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import volumes while ingesting vm: %s. %s", instanceName, e.getMessage()));
363+
}
357364

365+
try {
358366
Set<String> nics = nicNetworkMap.keySet();
359367
int i = 0;
360368
for (String nicId : nics) {
@@ -367,9 +375,9 @@ public UserVmResponse importUnmanagedInstance(ImportUnmanageInstanceCmd cmd) {
367375
}
368376
i++;
369377
}
378+
} catch (Exception e) {
379+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to import NICs while ingesting vm: %s. %s", instanceName, e.getMessage()));
370380
}
371-
} catch (InsufficientCapacityException ice) {
372-
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ice.getMessage());
373381
}
374382
break;
375383
}

0 commit comments

Comments
 (0)