GutoVeronezi commented on a change in pull request #5990:
URL: https://github.com/apache/cloudstack/pull/5990#discussion_r806066088



##########
File path: server/src/main/java/com/cloud/template/TemplateManagerImpl.java
##########
@@ -2211,6 +2214,31 @@ else if (details != null && !details.isEmpty()) {
         return _tmpltDao.findById(id);
     }
 
+    void validateDetails(VMTemplateVO template, Map<String, String> details) {
+        if (details == null || details.isEmpty()) {
+            return;
+        }
+        String bootMode = details.get(ApiConstants.BootType.UEFI.toString());
+        if (bootMode == null) {
+            return;
+        }
+        if (template.isDeployAsIs()) {
+            String msg = "Deploy-as-is templates can not have UEFI parameter 
set. Settings are read directly from the template";

Review comment:
       We can add some context info here, like the template id, name and so on.

##########
File path: server/src/main/java/com/cloud/template/TemplateManagerImpl.java
##########
@@ -2211,6 +2214,31 @@ else if (details != null && !details.isEmpty()) {
         return _tmpltDao.findById(id);
     }
 
+    void validateDetails(VMTemplateVO template, Map<String, String> details) {
+        if (details == null || details.isEmpty()) {

Review comment:
       We can use `CollectionUtils.isEmpty` here.

##########
File path: server/src/main/java/com/cloud/template/TemplateManagerImpl.java
##########
@@ -2211,6 +2214,31 @@ else if (details != null && !details.isEmpty()) {
         return _tmpltDao.findById(id);
     }
 
+    void validateDetails(VMTemplateVO template, Map<String, String> details) {
+        if (details == null || details.isEmpty()) {
+            return;
+        }
+        String bootMode = details.get(ApiConstants.BootType.UEFI.toString());
+        if (bootMode == null) {
+            return;
+        }
+        if (template.isDeployAsIs()) {
+            String msg = "Deploy-as-is templates can not have UEFI parameter 
set. Settings are read directly from the template";
+            throw new InvalidParameterValueException(msg);
+        }
+        try {
+            String mode = bootMode.trim().toUpperCase();
+            ApiConstants.BootMode.valueOf(mode);
+            details.put(ApiConstants.BootType.UEFI.toString(), mode);
+            return;
+        } catch (IllegalArgumentException e) {
+            String msg = String.format("Invalid %s: %s specified. Valid values 
are: %s",
+                    ApiConstants.BOOT_MODE, bootMode, 
Arrays.toString(ApiConstants.BootMode.values()));
+            s_logger.error(msg);

Review comment:
       We could pass the exception as parameter of  `s_logger.error`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to