if (swift == null) {
msg = "There is no Swift in this setup";
s_logger.warn(msg);
throw new CloudRuntimeException(msg);
}
VMTemplateSwiftVO tmpltSwiftRef = _vmTmpltSwiftlDao.findBySwiftTemplate(swift.getId(), cmd.getId());
if (tmpltSwiftRef == null) {
msg = "Delete Template failed due to cannot find Template" + cmd.getId() + " in Swift ";
s_logger.warn(msg);
throw new CloudRuntimeException(msg);
}
Answer answer = _agentMgr.sendToSSVM(null, new DeleteObjectFromSwiftCommand(swift, "T-" + cmd.getId(), null));
if (answer == null || !answer.getResult()) {
msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ? "answer is null" : answer.getDetails());
s_logger.warn(msg);
throw new CloudRuntimeException(msg);
} else {
_vmTmpltSwiftlDao.remove(tmpltSwiftRef.getId());
s_logger.debug("Deleted template " + cmd.getId() + " in Swift");
}
}