Updated Branches: refs/heads/kvm-vnc-listen 389086057 -> 895c51d0b
CLOUDSTACK-4619: UI > Infrastructure > zone > Using listApis to check existence of listVmwareDcs API command will show an error in the log when listVmwareDcs API command doesn't exist (in oss build). So, still use listClusters to determine the existence of listVmwareDcs API command. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/771b8377 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/771b8377 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/771b8377 Branch: refs/heads/kvm-vnc-listen Commit: 771b8377fd61bb96f81a0d9bc35cd22de38370f5 Parents: 1acec83 Author: Jessica Wang <[email protected]> Authored: Mon Sep 9 14:00:26 2013 -0700 Committer: Jessica Wang <[email protected]> Committed: Mon Sep 9 14:02:23 2013 -0700 ---------------------------------------------------------------------- ui/scripts/system.js | 55 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/771b8377/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index d677a49..3f5a5d4 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -6096,30 +6096,39 @@ }); $.ajax({ - url: createURL('listApis'), + url: createURL('listClusters'), data: { - name: 'listVmwareDcs' - }, - async: false, - success: function(json) { - $.ajax({ - url: createURL('listVmwareDcs'), //listVmwareDcs API exists in only non-oss bild - data: { - zoneid: args.context.physicalResources[0].id - }, - async: false, - success: function(json) { //e.g. json == { "listvmwaredcsresponse" { "count":1 ,"VMwareDC" [ {"id":"c3c2562d-65e9-4fc7-92e2-773c2efe8f37","zoneid":1,"name":"datacenter","vcenter":"10.10.20.20"} ] } } - var vmwaredcs = json.listvmwaredcsresponse.VMwareDC; - if (vmwaredcs != null) { - selectedZoneObj.vmwaredcName = vmwaredcs[0].name; - selectedZoneObj.vmwaredcVcenter = vmwaredcs[0].vcenter; - selectedZoneObj.vmwaredcId = vmwaredcs[0].id; - } - } - }); - }, - error: function(XMLHttpResponse) {} //suppress error dialog by overriding default error handling: cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse)}); - }); + zoneid: args.context.physicalResources[0].id + }, + async: false, + success: function(json) { + var clusters = json.listclustersresponse.cluster; + if (clusters != null) { + for (var i = 0; i < clusters.length; i++) { + if (clusters[i].hypervisortype == 'VMware') { + $.ajax({ + url: createURL('listVmwareDcs'), //listVmwareDcs API exists in only non-oss bild + data: { + zoneid: args.context.physicalResources[0].id + }, + async: false, + success: function(json) { //e.g. json == { "listvmwaredcsresponse" { "count":1 ,"VMwareDC" [ {"id":"c3c2562d-65e9-4fc7-92e2-773c2efe8f37","zoneid":1,"name":"datacenter","vcenter":"10.10.20.20"} ] } } + var vmwaredcs = json.listvmwaredcsresponse.VMwareDC; + if (vmwaredcs != null) { + selectedZoneObj.vmwaredcName = vmwaredcs[0].name; + selectedZoneObj.vmwaredcVcenter = vmwaredcs[0].vcenter; + selectedZoneObj.vmwaredcId = vmwaredcs[0].id; + } + } + //, error: function(XMLHttpResponse) {} //override default error handling: cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse)}); + }); + + break; + } + } + } + } + }); // for testing only (begin) /* selectedZoneObj.vmwaredcName = "datacenter";
