Skip to content

Commit 3a82392

Browse files
committed
Merge remote-tracking branch 'origin/4.14' into 4.15
2 parents 41c2e94 + 58a3f90 commit 3a82392

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

server/src/main/java/com/cloud/template/TemplateAdapterBase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ public TemplateProfile prepareDelete(DeleteTemplateCmd cmd) {
487487
throw new InvalidParameterValueException("Please specify a valid template.");
488488
}
489489

490+
if (template.getState() == VirtualMachineTemplate.State.NotUploaded || template.getState() == VirtualMachineTemplate.State.UploadInProgress) {
491+
throw new InvalidParameterValueException("The template is either getting uploaded or it may be initiated shortly, please wait for it to be completed");
492+
}
493+
490494
return new TemplateProfile(userId, template, zoneId);
491495
}
492496

@@ -526,6 +530,10 @@ public TemplateProfile prepareDelete(DeleteIsoCmd cmd) {
526530
throw new InvalidParameterValueException("Please specify a valid iso.");
527531
}
528532

533+
if (template.getState() == VirtualMachineTemplate.State.NotUploaded || template.getState() == VirtualMachineTemplate.State.UploadInProgress) {
534+
throw new InvalidParameterValueException("The iso is either getting uploaded or it may be initiated shortly, please wait for it to be completed");
535+
}
536+
529537
return new TemplateProfile(userId, template, zoneId);
530538
}
531539

services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,9 @@ protected Answer deleteTemplate(DeleteCommand cmd) {
23482348
File tmpltParent = null;
23492349
if (tmpltPath.exists() && tmpltPath.isDirectory()) {
23502350
tmpltParent = tmpltPath;
2351+
} else if (absoluteTemplatePath.endsWith(File.separator + obj.getId())) {
2352+
// the path ends with <account id>/<template id>, if upload fails
2353+
tmpltParent = tmpltPath;
23512354
} else {
23522355
tmpltParent = tmpltPath.getParentFile();
23532356
}
@@ -2452,6 +2455,9 @@ protected Answer deleteVolume(final DeleteCommand cmd) {
24522455
if (volPath.exists() && volPath.isDirectory()) {
24532456
// for vmware, absoluteVolumePath represents a directory where volume files are located.
24542457
tmpltParent = volPath;
2458+
} else if (absoluteVolumePath.endsWith(File.separator + obj.getId())) {
2459+
// the path ends with <account id>/<volume id>, if upload fails
2460+
tmpltParent = volPath;
24552461
} else {
24562462
// for other hypervisors, the volume .vhd or .qcow2 file path is passed
24572463
tmpltParent = new File(absoluteVolumePath).getParentFile();

0 commit comments

Comments
 (0)