cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/master to c61d2ee
Date Tue, 05 Nov 2013 19:55:28 GMT
Updated Branches:
  refs/heads/master fdf7639eb -> c61d2eedf


CLOUDSTACK-4908: UI > Infrastructure > Sockets > (1) calculate total number of CPU
Sockets for all hypervisors.
(2) > view all > calculate CPU Sockets for each hypervisor.


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

Branch: refs/heads/master
Commit: c61d2eedf4a87107ae9a77c8c39b7f584995e617
Parents: fdf7639
Author: Jessica Wang <jessicawang@apache.org>
Authored: Tue Nov 5 11:55:06 2013 -0800
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Tue Nov 5 11:55:06 2013 -0800

----------------------------------------------------------------------
 ui/scripts/sharedFunctions.js |   1 +
 ui/scripts/system.js          | 113 ++++++++++++++++++++++++++++++++-----
 2 files changed, 99 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c61d2eed/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 05d2d9d..fddbd70 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -46,6 +46,7 @@ var md5HashedLogin = false;
 
 //page size for API call (e.g."listXXXXXXX&pagesize=N" )
 var pageSize = 20;
+//var pageSize = 1; //for testing only
 
 var rootAccountId = 1;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c61d2eed/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 381d884..7d4ce2a 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -380,9 +380,64 @@
                         }
                     },
 
-                    socketInfo: function(data) {
+                    socketInfo: function(data) {                    	
+                    	var socketCount = 0;                    	
+                    	$.ajax({
+                            url: createURL('listHypervisors'),
+                            async: false,
+                            success: function(json) {
+                                args.response.success({
+                                    data: $(json.listhypervisorsresponse.hypervisor).map(function(index,
hypervisor) {                                                	
+                                    	var totalHostCount = 0;                            
                   	
+                                    	var currentPage = 1;
+                                    	var returnedHostCount = 0;
+                                    	var returnedHostCpusocketsSum = 0;
+                                    	var returnedHostHavingCpusockets = true;
+                                    	                                                	
+                                    	var callListHostsWithPage = function(setTotalHostCount)
{                                                		
+                                    		$.ajax({
+                            					url: createURL('listHosts'),
+                                        		async: false,
+                                        		data: {
+                                        			hypervisortype: hypervisor.name,
+                                        			page: currentPage,
+                                        	        pagesize: pageSize //global variable
+                                        		},
+                                        		success: function(json) {                     
                                			
+                                        			if (setTotalHostCount) {
+                                        				totalHostCount = json.listhostsresponse.count;
+                                        			}                                            
       			
+                                        			returnedHostCount += json.listhostsresponse.host.length;
+                                        			                                             
      			
+                                        			var items = json.listhostsresponse.host;
+                                        			for (var i = 0; i < items.length; i++) {
+                                        				if (items[i].cpusockets != undefined &&
isNaN(items[i].cpusockets) == false) {
+                                        					returnedHostCpusocketsSum += items[i].cpusockets;
+                                        				} else {
+                                        					returnedHostHavingCpusockets = false;
+                                        				}
+                                        			}  
+                                        			
+                                        			if (returnedHostCount < totalHostCount) {
+                                        				currentPage++;
+                                        				callListHostsWithPage(false);
+                                        			}                                            
       			
+                                        		}
+                            				});                                                		
+                                    	}
+                                    	
+                                    	callListHostsWithPage(true);
+                                    	
+                                    	if (returnedHostHavingCpusockets) {
+                                    		socketCount += returnedHostCpusocketsSum;
+                                    	}                                    	
+                                    })
+                                });
+                            }
+                        });
+                    	
                         complete($.extend(data, {
-                            socketCount: 0
+                            socketCount: socketCount
                         }));
                     }
                 };
@@ -7135,22 +7190,50 @@
                                         success: function(json) {
                                             args.response.success({
                                                 data: $(json.listhypervisorsresponse.hypervisor).map(function(index,
hypervisor) {                                                	
-                                                	var hostCount;
-                                                	$.ajax({
-                                                		url: createURL('listHosts'),
-                                                		async: false,
-                                                		data: {
-                                                			hypervisortype: hypervisor.name
-                                                		},
-                                                		success: function(json) {             
                                  			
-                                                			hostCount = json.listhostsresponse.count;
-                                                		}
-                                                	});                                    
           	                                               	
+                                                	var totalHostCount = 0;                
                               	
+                                                	var currentPage = 1;
+                                                	var returnedHostCount = 0;
+                                                	var returnedHostCpusocketsSum = 0;
+                                                	var returnedHostHavingCpusockets = true;
+                                                	                                       
        	
+                                                	var callListHostsWithPage = function(setTotalHostCount)
{                                                		
+                                                		$.ajax({
+                                        					url: createURL('listHosts'),
+                                                    		async: false,
+                                                    		data: {
+                                                    			hypervisortype: hypervisor.name,
+                                                    			page: currentPage,
+                                                    	        pagesize: pageSize //global
variable
+                                                    		},
+                                                    		success: function(json) {         
                                            			
+                                                    			if (setTotalHostCount) {
+                                                    				totalHostCount = json.listhostsresponse.count;
+                                                    			}                                
                   			
+                                                    			returnedHostCount += json.listhostsresponse.host.length;
+                                                    			                                 
                  			
+                                                    			var items = json.listhostsresponse.host;
+                                                    			for (var i = 0; i < items.length;
i++) {
+                                                    				if (items[i].cpusockets != undefined
&& isNaN(items[i].cpusockets) == false) {
+                                                    					returnedHostCpusocketsSum += items[i].cpusockets;
+                                                    				} else {
+                                                    					returnedHostHavingCpusockets = false;
+                                                    				}
+                                                    			}  
+                                                    			
+                                                    			if (returnedHostCount < totalHostCount)
{
+                                                    				currentPage++;
+                                                    				callListHostsWithPage(false);
+                                                    			}                                
                   			
+                                                    		}
+                                        				});                                         
      		
+                                                	}
                                                 	
+                                                	callListHostsWithPage(true);
+                                                	                                       
 	
                                                     return {
                                                         hypervisor: hypervisor.name,
-                                                        hosts: hostCount,
-                                                        sockets: 0                      
                                 
+                                                        hosts: totalHostCount,
+                                                        sockets: (returnedHostHavingCpusockets?
returnedHostCpusocketsSum : 'unknown')                                                   

                                                     };
                                                 })
                                             });


Mime
View raw message