Skip to content

Instantly share code, notes, and snippets.

@rhtyd rhtyd/test-diff
Created Mar 5, 2016

Embed
What would you like to do?
Nux - vms on dashboard
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 22f7409..e91b349 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -4479,6 +4479,7 @@ textarea {
height: 316px;
overflow: auto;
overflow-x: hidden;
+ overflow-y: auto;
/*+placement:shift 0px 0px;*/
position: relative;
left: 0px;
diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js
index f2b5682..3013b96 100644
--- a/ui/scripts/dashboard.js
+++ b/ui/scripts/dashboard.js
@@ -253,7 +253,7 @@
var capacities = json.listcapacityresponse.capacity ?
json.listcapacityresponse.capacity : [];
- complete($.extend(data, {
+ data = $.extend(data, {
zoneCapacities: $.map(capacities, function(capacity) {
if (capacity.podname) {
capacity.zonename = capacity.zonename.concat(', ' + _l('label.pod') + ': ' + capacity.podname);
@@ -274,7 +274,52 @@
total: cloudStack.converters.convertByType(capacity.type, capacity.capacitytotal)
};
})
- }));
+ });
+
+ // Calculate VMs
+ var totalInstanceCount = 0;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
+ data: {
+ listAll: true,
+ page: 1,
+ pageSize: 1
+ },
+ async: false,
+ success: function(json) {
+ if (json.listvirtualmachinesresponse.count != undefined) {
+ totalInstanceCount = json.listvirtualmachinesresponse.count;
+ }
+ }
+ });
+
+ var runningInstanceCount = 0;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
+ data: {
+ listAll: true,
+ page: 1,
+ pageSize: 1,
+ state: "Running"
+ },
+ async: false,
+ success: function(json) {
+ if (json.listvirtualmachinesresponse.count != undefined) {
+ runningInstanceCount = json.listvirtualmachinesresponse.count;
+ }
+ }
+ });
+
+ var vms = {
+ total: totalInstanceCount,
+ used: runningInstanceCount,
+ percent: runningInstanceCount * 100 / totalInstanceCount,
+ type: "Running VMs",
+ zoneID: "1234",
+ zoneName: "All zones"
+ };
+ data.zoneCapacities.push(vms);
+ complete(data);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.