Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ public TemplateProfile prepareDelete(DeleteTemplateCmd cmd) {
throw new InvalidParameterValueException("Please specify a valid template.");
}

if (template.getState() == VirtualMachineTemplate.State.NotUploaded || template.getState() == VirtualMachineTemplate.State.UploadInProgress) {
throw new InvalidParameterValueException("The template is either getting uploaded or it may be initiated shortly, please wait for it to be completed");
}

return new TemplateProfile(userId, template, zoneId);
}

Expand Down Expand Up @@ -495,6 +499,10 @@ public TemplateProfile prepareDelete(DeleteIsoCmd cmd) {
throw new InvalidParameterValueException("Please specify a valid iso.");
}

if (template.getState() == VirtualMachineTemplate.State.NotUploaded || template.getState() == VirtualMachineTemplate.State.UploadInProgress) {
throw new InvalidParameterValueException("The iso is either getting uploaded or it may be initiated shortly, please wait for it to be completed");
}

return new TemplateProfile(userId, template, zoneId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,9 @@ protected Answer deleteTemplate(DeleteCommand cmd) {
File tmpltParent = null;
if (tmpltPath.exists() && tmpltPath.isDirectory()) {
tmpltParent = tmpltPath;
} else if (absoluteTemplatePath.endsWith(File.separator + obj.getId())) {
// the path ends with <account id>/<template id>, if upload fails
tmpltParent = tmpltPath;
} else {
tmpltParent = tmpltPath.getParentFile();
}
Expand Down Expand Up @@ -2357,6 +2360,9 @@ protected Answer deleteVolume(final DeleteCommand cmd) {
if (volPath.exists() && volPath.isDirectory()) {
// for vmware, absoluteVolumePath represents a directory where volume files are located.
tmpltParent = volPath;
} else if (absoluteVolumePath.endsWith(File.separator + obj.getId())) {
// the path ends with <account id>/<volume id>, if upload fails
tmpltParent = volPath;
} else {
// for other hypervisors, the volume .vhd or .qcow2 file path is passed
tmpltParent = new File(absoluteVolumePath).getParentFile();
Expand Down