cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 3c28ce7
Date Mon, 13 Feb 2017 11:59:59 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 8efdcfc1c -> 3c28ce7f4


CLOUDSTACK-8950 Hypervisor Parameter check is not performed for
registerTemplate and getUploadParamsForTemplate API's

Any string is allowed as hypervisor type from the api.
HypervisorType.getType() tries to validate with the enums and if nothing
matches, sets the type as None.

Added a check to not allow None hypervisor type when registering.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cc06c518
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cc06c518
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cc06c518

Branch: refs/heads/master
Commit: cc06c5189a377fc6bc4b7e8bbed56e9058588863
Parents: e02003d
Author: Rajani Karuturi <rajani.karuturi@accelerite.com>
Authored: Thu Nov 3 10:58:22 2016 +0530
Committer: Rajani Karuturi <rajani.karuturi@accelerite.com>
Committed: Mon Feb 13 15:07:06 2017 +0530

----------------------------------------------------------------------
 .../com/cloud/template/TemplateAdapterBase.java | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc06c518/server/src/com/cloud/template/TemplateAdapterBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java
index c5d0c5b..530c562 100644
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -270,10 +270,15 @@ public abstract class TemplateAdapterBase extends AdapterBase implements
Templat
             zoneId = -1L;
         }
 
-        return prepare(false, CallContext.current().getCallingUserId(), cmd.getTemplateName(),
cmd.getDisplayText(), cmd.getBits(), cmd.isPasswordEnabled(),
-            cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(),
cmd.getFormat(), cmd.getOsTypeId(), zoneId,
-            HypervisorType.getType(cmd.getHypervisor()), cmd.getChecksum(), true, cmd.getTemplateTag(),
owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null,
-            cmd.isDynamicallyScalable(), isRouting ? TemplateType.ROUTING : TemplateType.USER);
+        HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
+        if(hypervisorType == HypervisorType.None) {
+            throw new InvalidParameterValueException("Hypervisor Type: " + cmd.getHypervisor()
+ " is invalid. Supported Hypervisor types are "
+                    + EnumUtils.listValues(HypervisorType.values()).replace("None, ", ""));
+        }
+
+        return prepare(false, CallContext.current().getCallingUserId(), cmd.getTemplateName(),
cmd.getDisplayText(), cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(),
+                cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), cmd.getFormat(),
cmd.getOsTypeId(), zoneId, hypervisorType, cmd.getChecksum(), true,
+                cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null,
cmd.isDynamicallyScalable(), isRouting ? TemplateType.ROUTING : TemplateType.USER);
 
     }
 
@@ -293,9 +298,15 @@ public abstract class TemplateAdapterBase extends AdapterBase implements
Templat
             zoneId = -1L;
         }
 
+        HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
+        if(hypervisorType == HypervisorType.None) {
+            throw new InvalidParameterValueException("Hypervisor Type: " + cmd.getHypervisor()
+ " is invalid. Supported Hypervisor types are "
+                                                         + EnumUtils.listValues(HypervisorType.values()).replace("None,
", ""));
+        }
+
         return prepare(false, CallContext.current().getCallingUserId(), cmd.getName(), cmd.getDisplayText(),
cmd.getBits(), cmd.isPasswordEnabled(),
                        cmd.getRequiresHvm(), null, cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(),
cmd.getFormat(), cmd.getOsTypeId(), zoneId,
-                       HypervisorType.getType(cmd.getHypervisor()), cmd.getChecksum(), true,
cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null,
+                       hypervisorType, cmd.getChecksum(), true, cmd.getTemplateTag(), owner,
cmd.getDetails(), cmd.isSshKeyEnabled(), null,
                        cmd.isDynamicallyScalable(), isRouting ? TemplateType.ROUTING : TemplateType.USER);
 
     }


Mime
View raw message