CS-14989: cloudstack 3.0 UI - VM wizard - select template step - populate only templates whose hypervisor(s) are supported in the selected zone.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/63d512b8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/63d512b8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/63d512b8 Branch: refs/heads/3.0.x Commit: 63d512b80863eda7dd22958e3f532b5ec7d60842 Parents: 4cf1cb7 Author: Jessica Wang <[email protected]> Authored: Wed May 23 14:11:55 2012 -0700 Committer: Jessica Wang <[email protected]> Committed: Wed May 23 14:12:36 2012 -0700 ---------------------------------------------------------------------- ui/scripts/instances.js | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/63d512b8/ui/scripts/instances.js ---------------------------------------------------------------------- diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index dee0cf0..731774e 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -105,12 +105,22 @@ } }); + + //***** get templates/ISOs (begin) ***** + var hypervisorArray = []; + $(hypervisorObjs).each(function(index, item) { + hypervisorArray.push(item.name); + }); + $.ajax({ url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid), dataType: "json", async: false, - success: function(json) { - featuredTemplateObjs = json.listtemplatesresponse.template; + success: function(json) { + featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); $.ajax({ @@ -118,7 +128,10 @@ dataType: "json", async: false, success: function(json) { - communityTemplateObjs = json.listtemplatesresponse.template; + communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); $.ajax({ @@ -126,10 +139,12 @@ dataType: "json", async: false, success: function(json) { - myTemplateObjs = json.listtemplatesresponse.template; + myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); - $.ajax({ url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"), @@ -155,7 +170,9 @@ myIsoObjs = json.listisosresponse.iso; } }); - + //***** get templates/ISOs (end) ***** + + args.response.success({ hypervisor: { idField: 'name',
