You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/04/29 07:44:24 UTC

[40/50] git commit: updated refs/heads/master to 0b83559

volume upload: disabled all zones during template upload


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

Branch: refs/heads/master
Commit: 5c152e5f3a8abf7385cbc8c65ddcb000bc11a560
Parents: ce823a3
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Mon Apr 13 14:40:28 2015 +0530
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Mon Apr 13 14:43:12 2015 +0530

----------------------------------------------------------------------
 .../template/GetUploadParamsForTemplateCmd.java | 10 ++++-
 ui/scripts/templates.js                         | 47 +++++---------------
 2 files changed, 21 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5c152e5f/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
index d1dc468..248e892 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
@@ -22,7 +22,6 @@ import java.net.MalformedURLException;
 import java.util.Collection;
 import java.util.Map;
 
-import com.cloud.exception.ResourceAllocationException;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.AbstractGetUploadParamsCmd;
 import org.apache.cloudstack.api.ApiConstants;
@@ -34,6 +33,8 @@ import org.apache.cloudstack.api.response.GuestOSResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.log4j.Logger;
 
+import com.cloud.exception.ResourceAllocationException;
+
 @APICommand(name = "getUploadParamsForTemplate", description = "upload an existing template into the CloudStack cloud. ", responseObject = GetUploadParamsResponse.class, since =
     "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
@@ -149,6 +150,7 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
 
     @Override
     public void execute() throws ServerApiException {
+        validateRequest();
         try {
             GetUploadParamsResponse response = _templateService.registerTemplateForPostUpload(this);
             response.setResponseName(getCommandName());
@@ -159,6 +161,12 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
         }
     }
 
+    private void validateRequest() {
+        if (getZoneId() <= 0) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "invalid zoneid");
+        }
+    }
+
     @Override
     public String getCommandName() {
         return s_name;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5c152e5f/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index c060a0c..5d6c013 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -691,41 +691,18 @@
                                         label: 'label.zone',
                                         docID: 'helpRegisterTemplateZone',
                                         select: function(args) {
-                                            if (g_regionsecondaryenabled == true) {
-                                                args.response.success({
-                                                    data: [{
-                                                        id: -1,
-                                                        description: "All Zones"
-                                                    }]
-                                                });
-                                            } else {
-                                                $.ajax({
-                                                    url: createURL("listZones&available=true"),
-                                                    dataType: "json",
-                                                    async: true,
-                                                    success: function(json) {
-                                                        var zoneObjs = [];
-                                                        var items = json.listzonesresponse.zone;
-                                                        if (items != null) {
-                                                            for (var i = 0; i < items.length; i++) {
-                                                                zoneObjs.push({
-                                                                    id: items[i].id,
-                                                                    description: items[i].name
-                                                                });
-                                                            }
-                                                        }
-                                                        if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
-                                                            zoneObjs.unshift({
-                                                                id: -1,
-                                                                description: "All Zones"
-                                                            });
-                                                        }
-                                                        args.response.success({
-                                                            data: zoneObjs
-                                                        });
-                                                    }
-                                                });
-                                            }
+                                            $.ajax({
+                                                url: createURL("listZones&available=true"),
+                                                dataType: "json",
+                                                async: true,
+                                                success: function(json) {
+                                                    var zoneObjs = json.listzonesresponse.zone;
+                                                    args.response.success({
+                                                        descriptionField: 'name',
+                                                        data: zoneObjs
+                                                    });
+                                                }
+                                            });
                                         }
                                     },