From 5fde51755feb8c01a6a0cd34de3c6d63b0dcc928 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 9 Jul 2015 18:21:25 +0200 Subject: [PATCH] Add DISK accounting --- .../public/app/tabs/dashboard-tab/users.hbs | 13 +- .../public/app/tabs/dashboard-tab/vms.hbs | 17 +- src/sunstone/public/app/tabs/provision-tab.js | 201 +++++++++--------- .../tabs/provision-tab/dashboard/users.hbs | 12 +- .../tabs/provision-tab/dashboard/vdc-vms.hbs | 12 +- .../app/tabs/provision-tab/dashboard/vms.hbs | 12 +- .../app/tabs/provision-tab/users/info.hbs | 20 +- .../app/tabs/provision-tab/users/list.js | 118 +++++----- .../public/app/tabs/provision-tab/vms/list.js | 2 +- .../public/app/tabs/vms-tab/panels/storage.js | 13 +- src/sunstone/public/app/utils/accounting.js | 108 +++++++++- .../public/app/utils/accounting/html.hbs | 27 ++- src/sunstone/public/app/utils/graphs.js | 2 +- 13 files changed, 371 insertions(+), 186 deletions(-) diff --git a/src/sunstone/public/app/tabs/dashboard-tab/users.hbs b/src/sunstone/public/app/tabs/dashboard-tab/users.hbs index d59e0dbe2d..ca15bae614 100644 --- a/src/sunstone/public/app/tabs/dashboard-tab/users.hbs +++ b/src/sunstone/public/app/tabs/dashboard-tab/users.hbs @@ -1,5 +1,6 @@
+

{{tr "USERS"}} @@ -17,19 +18,25 @@
-

+

{{tr "CPU hours"}}

{{> ./empty-graph}}
-

+

{{tr "Memory GB hours"}}

{{> ./empty-graph}}
+
+

+ {{tr "Disk MB hours"}} +

+
{{> ./empty-graph}}
+

\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs b/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs index 1e4fefe0df..4c4cb5dbe3 100644 --- a/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs +++ b/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs @@ -1,5 +1,6 @@
+

{{tr "VMs"}} @@ -40,19 +41,25 @@
-

+

{{tr "CPU hours"}}

-
{{> ./empty-graph}}
+
{{> ./empty-graph}}
-

+

{{tr "Memory GB hours"}}

-
{{> ./empty-graph}}
+
{{> ./empty-graph}}
+
+
+

+ {{tr "Disk MB hours"}} +

+
{{> ./empty-graph}}

\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/provision-tab.js b/src/sunstone/public/app/tabs/provision-tab.js index 0b9dfb858c..08f661d57d 100644 --- a/src/sunstone/public/app/tabs/provision-tab.js +++ b/src/sunstone/public/app/tabs/provision-tab.js @@ -702,106 +702,6 @@ define(function(require) { $("#provision_dashboard").html(""); - if (Config.provision.dashboard.isEnabled("quotas")) { - $("#provision_dashboard").append(TemplateDashboardQuotas()); - - - OpenNebula.User.show({ - data : { - id: "-1" - }, - success: function(request,user_json){ - var user = user_json.USER; - - QuotaWidgets.initEmptyQuotas(user); - - if (!$.isEmptyObject(user.VM_QUOTA)){ - var default_user_quotas = QuotasDefault.default_quotas(user.DEFAULT_USER_QUOTAS); - - var vms = QuotaWidgets.quotaInfo( - user.VM_QUOTA.VM.VMS_USED, - user.VM_QUOTA.VM.VMS, - default_user_quotas.VM_QUOTA.VM.VMS, - true); - - $("#provision_dashboard_rvms_percentage").html(vms["percentage"]); - $("#provision_dashboard_rvms_str").html(vms["str"]); - $("#provision_dashboard_rvms_meter").css("width", vms["percentage"]+"%"); - - var memory = QuotaWidgets.quotaMBInfo( - user.VM_QUOTA.VM.MEMORY_USED, - user.VM_QUOTA.VM.MEMORY, - default_user_quotas.VM_QUOTA.VM.MEMORY, - true); - - $("#provision_dashboard_memory_percentage").html(memory["percentage"]); - $("#provision_dashboard_memory_str").html(memory["str"]); - $("#provision_dashboard_memory_meter").css("width", memory["percentage"]+"%"); - - var cpu = QuotaWidgets.quotaFloatInfo( - user.VM_QUOTA.VM.CPU_USED, - user.VM_QUOTA.VM.CPU, - default_user_quotas.VM_QUOTA.VM.CPU, - true); - - $("#provision_dashboard_cpu_percentage").html(cpu["percentage"]); - $("#provision_dashboard_cpu_str").html(cpu["str"]); - $("#provision_dashboard_cpu_meter").css("width", cpu["percentage"]+"%"); - } - } - }) - } - - if (Config.provision.dashboard.isEnabled("vdcquotas")) { - $("#provision_dashboard").append(TemplateDashboardVdcQuotas()); - - - OpenNebula.Group.show({ - data : { - id: "-1" - }, - success: function(request,group_json){ - var group = group_json.GROUP; - - QuotaWidgets.initEmptyQuotas(group); - - if (!$.isEmptyObject(group.VM_QUOTA)){ - var default_group_quotas = QuotaDefaults.default_quotas(group.DEFAULT_GROUP_QUOTAS); - - var vms = QuotaWidgets.quotaInfo( - group.VM_QUOTA.VM.VMS_USED, - group.VM_QUOTA.VM.VMS, - default_group_quotas.VM_QUOTA.VM.VMS, - true); - - $("#provision_dashboard_vdc_rvms_percentage").html(vms["percentage"]); - $("#provision_dashboard_vdc_rvms_str").html(vms["str"]); - $("#provision_dashboard_vdc_rvms_meter").css("width", vms["percentage"]+"%"); - - var memory = QuotaWidgets.quotaMBInfo( - group.VM_QUOTA.VM.MEMORY_USED, - group.VM_QUOTA.VM.MEMORY, - default_group_quotas.VM_QUOTA.VM.MEMORY, - true); - - $("#provision_dashboard_vdc_memory_percentage").html(memory["percentage"]); - $("#provision_dashboard_vdc_memory_str").html(memory["str"]); - $("#provision_dashboard_vdc_memory_meter").css("width", memory["percentage"]+"%"); - - var cpu = QuotaWidgets.quotaFloatInfo( - group.VM_QUOTA.VM.CPU_USED, - group.VM_QUOTA.VM.CPU, - default_group_quotas.VM_QUOTA.VM.CPU, - true); - - $("#provision_dashboard_vdc_cpu_percentage").html(cpu["percentage"]); - $("#provision_dashboard_vdc_cpu_str").html(cpu["str"]); - $("#provision_dashboard_vdc_cpu_meter").css("width", cpu["percentage"]+"%"); - } - } - }) - } - if (Config.provision.dashboard.isEnabled("vms")) { $("#provision_dashboard").append(TemplateDashboardVms()); @@ -990,6 +890,105 @@ define(function(require) { }); } + if (Config.provision.dashboard.isEnabled("quotas")) { + $("#provision_dashboard").append(TemplateDashboardQuotas()); + + + OpenNebula.User.show({ + data : { + id: "-1" + }, + success: function(request,user_json){ + var user = user_json.USER; + + QuotaWidgets.initEmptyQuotas(user); + + if (!$.isEmptyObject(user.VM_QUOTA)){ + var default_user_quotas = QuotasDefault.default_quotas(user.DEFAULT_USER_QUOTAS); + + var vms = QuotaWidgets.quotaInfo( + user.VM_QUOTA.VM.VMS_USED, + user.VM_QUOTA.VM.VMS, + default_user_quotas.VM_QUOTA.VM.VMS, + true); + + $("#provision_dashboard_rvms_percentage").html(vms["percentage"]); + $("#provision_dashboard_rvms_str").html(vms["str"]); + $("#provision_dashboard_rvms_meter").css("width", vms["percentage"]+"%"); + + var memory = QuotaWidgets.quotaMBInfo( + user.VM_QUOTA.VM.MEMORY_USED, + user.VM_QUOTA.VM.MEMORY, + default_user_quotas.VM_QUOTA.VM.MEMORY, + true); + + $("#provision_dashboard_memory_percentage").html(memory["percentage"]); + $("#provision_dashboard_memory_str").html(memory["str"]); + $("#provision_dashboard_memory_meter").css("width", memory["percentage"]+"%"); + + var cpu = QuotaWidgets.quotaFloatInfo( + user.VM_QUOTA.VM.CPU_USED, + user.VM_QUOTA.VM.CPU, + default_user_quotas.VM_QUOTA.VM.CPU, + true); + + $("#provision_dashboard_cpu_percentage").html(cpu["percentage"]); + $("#provision_dashboard_cpu_str").html(cpu["str"]); + $("#provision_dashboard_cpu_meter").css("width", cpu["percentage"]+"%"); + } + } + }) + } + + if (Config.provision.dashboard.isEnabled("vdcquotas")) { + $("#provision_dashboard").append(TemplateDashboardVdcQuotas()); + + + OpenNebula.Group.show({ + data : { + id: "-1" + }, + success: function(request,group_json){ + var group = group_json.GROUP; + + QuotaWidgets.initEmptyQuotas(group); + + if (!$.isEmptyObject(group.VM_QUOTA)){ + var default_group_quotas = QuotaDefaults.default_quotas(group.DEFAULT_GROUP_QUOTAS); + + var vms = QuotaWidgets.quotaInfo( + group.VM_QUOTA.VM.VMS_USED, + group.VM_QUOTA.VM.VMS, + default_group_quotas.VM_QUOTA.VM.VMS, + true); + + $("#provision_dashboard_vdc_rvms_percentage").html(vms["percentage"]); + $("#provision_dashboard_vdc_rvms_str").html(vms["str"]); + $("#provision_dashboard_vdc_rvms_meter").css("width", vms["percentage"]+"%"); + + var memory = QuotaWidgets.quotaMBInfo( + group.VM_QUOTA.VM.MEMORY_USED, + group.VM_QUOTA.VM.MEMORY, + default_group_quotas.VM_QUOTA.VM.MEMORY, + true); + + $("#provision_dashboard_vdc_memory_percentage").html(memory["percentage"]); + $("#provision_dashboard_vdc_memory_str").html(memory["str"]); + $("#provision_dashboard_vdc_memory_meter").css("width", memory["percentage"]+"%"); + + var cpu = QuotaWidgets.quotaFloatInfo( + group.VM_QUOTA.VM.CPU_USED, + group.VM_QUOTA.VM.CPU, + default_group_quotas.VM_QUOTA.VM.CPU, + true); + + $("#provision_dashboard_vdc_cpu_percentage").html(cpu["percentage"]); + $("#provision_dashboard_vdc_cpu_str").html(cpu["str"]); + $("#provision_dashboard_vdc_cpu_meter").css("width", cpu["percentage"]+"%"); + } + } + }) + } } @@ -1983,4 +1982,4 @@ define(function(require) { }); } -}); \ No newline at end of file +}); diff --git a/src/sunstone/public/app/tabs/provision-tab/dashboard/users.hbs b/src/sunstone/public/app/tabs/provision-tab/dashboard/users.hbs index 0bd58488ce..5f80e3fdb9 100644 --- a/src/sunstone/public/app/tabs/provision-tab/dashboard/users.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/dashboard/users.hbs @@ -56,9 +56,19 @@
+
+
+

{{tr "Disk MB hours"}}

+
+
+
+ {{> ./empty-graphs}} +
+
+

-
\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/provision-tab/dashboard/vdc-vms.hbs b/src/sunstone/public/app/tabs/provision-tab/dashboard/vdc-vms.hbs index 1bfa3c3fac..5adf08605b 100644 --- a/src/sunstone/public/app/tabs/provision-tab/dashboard/vdc-vms.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/dashboard/vdc-vms.hbs @@ -93,9 +93,19 @@
{{> ./empty-graphs}}
+
+
+

+ {{tr "Disk MB hours"}} +

+
+
+
{{> ./empty-graphs}}
+
+

-
\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/provision-tab/dashboard/vms.hbs b/src/sunstone/public/app/tabs/provision-tab/dashboard/vms.hbs index 7e867a14b9..3838f02146 100644 --- a/src/sunstone/public/app/tabs/provision-tab/dashboard/vms.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/dashboard/vms.hbs @@ -93,9 +93,19 @@
{{> ./empty-graphs}}
+
+
+

+ {{tr "Disk MB hours"}} +

+
+
+
{{> ./empty-graphs}}
+
+

-
\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/provision-tab/users/info.hbs b/src/sunstone/public/app/tabs/provision-tab/users/info.hbs index ba5941c519..f2ed1a3ca8 100644 --- a/src/sunstone/public/app/tabs/provision-tab/users/info.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/users/info.hbs @@ -28,13 +28,23 @@
-
+
-
+
-
+
+
+
+ {{tr "Disk MB hours"}} +
+
+
+
+
+
+
@@ -46,7 +56,7 @@
-
+
{{tr "Memory GB hours"}} @@ -73,4 +83,4 @@
-
\ No newline at end of file +
diff --git a/src/sunstone/public/app/tabs/provision-tab/users/list.js b/src/sunstone/public/app/tabs/provision-tab/users/list.js index 33414dbc4e..c2b17d9831 100644 --- a/src/sunstone/public/app/tabs/provision-tab/users/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/users/list.js @@ -246,88 +246,90 @@ define(function(require) { if (!$.isEmptyObject(data.VM_QUOTA)) { var default_user_quotas = QuotaDefaults.default_quotas(data.DEFAULT_USER_QUOTAS); - quotas = QuotaWidgets.quotaFloatInfo( + vms_quotas = QuotaWidgets.quotaFloatInfo( data.VM_QUOTA.VM.VMS_USED, data.VM_QUOTA.VM.VMS, default_user_quotas.VM_QUOTA.VM.VMS, true); - $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("VMs") + - '' + quotas.str + "" + - '
  • ' + - '
  • ' + - '
    ' + - ' ' + - '
    ' + - '
  • '); - - quotas = QuotaWidgets.quotaFloatInfo( + cpu_quotas = QuotaWidgets.quotaFloatInfo( data.VM_QUOTA.VM.CPU_USED, data.VM_QUOTA.VM.CPU, default_user_quotas.VM_QUOTA.VM.CPU, true); - $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("CPU") + - '' + quotas.str + "" + - '
  • ' + - '
  • ' + - '
    ' + - ' ' + - '
    ' + - '
  • '); - - quotas = QuotaWidgets.quotaMBInfo( + mem_quotas = QuotaWidgets.quotaMBInfo( data.VM_QUOTA.VM.MEMORY_USED, data.VM_QUOTA.VM.MEMORY, default_user_quotas.VM_QUOTA.VM.MEMORY, true); $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("Memory") + - '' + quotas.str + "" + + '
    '+ + ' '+ Locale.tr("VMs") + + '' + vms_quotas.str + "" + + '
    '+ + '
    '+ + ' '+ Locale.tr("CPU") + + '' + cpu_quotas.str + "" + + '
    '+ + '
    '+ + ' '+ Locale.tr("Memory") + + '' + mem_quotas.str + "" + + '
    '+ '
  • ' + '
  • ' + - '
    ' + - ' ' + - '
    ' + + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ '
  • '); } else { - quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true); + vms_quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true); + cpu_quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true); + mem_quotas = QuotaWidgets.quotaMBInfo(0, 0, null, true); $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("VMs") + - '' + quotas.str + "" + + '
    '+ + ' '+ Locale.tr("VMs") + + '' + vms_quotas.str + "" + + '
    '+ + '
    '+ + ' '+ Locale.tr("CPU") + + '' + cpu_quotas.str + "" + + '
    '+ + '
    '+ + ' '+ Locale.tr("Memory") + + '' + mem_quotas.str + "" + + '
    '+ '
  • ' + '
  • ' + - '
    ' + - ' ' + - '
    ' + - '
  • '); - - quotas = QuotaWidgets.quotaFloatInfo(0, 0, null, true); - - $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("CPU") + - '' + quotas.str + "" + - '
  • ' + - '
  • ' + - '
    ' + - ' ' + - '
    ' + - '
  • '); - - quotas = QuotaWidgets.quotaMBInfo(0, 0, null, true); - - $(".provision-pricing-table_user_info", context).append('
  • ' + - ' '+ Locale.tr("Memory") + - '' + quotas.str + "" + - '
  • ' + - '
  • ' + - '
    ' + - ' ' + - '
    ' + + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ + '
    '+ + '
    ' + + ' ' + + '
    ' + + '
    '+ '
  • '); } diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/list.js b/src/sunstone/public/app/tabs/provision-tab/vms/list.js index b0753294fa..c2b69f768a 100644 --- a/src/sunstone/public/app/tabs/provision-tab/vms/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/vms/list.js @@ -952,7 +952,7 @@ define(function(require) { } function get_provision_ips(data) { - return ' ' + OpenNebula.VM.ipsStr(data); + return ' ' + OpenNebula.VM.ipsStr(data, ', '); } // @params diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/storage.js b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js index c7b7b0f3cd..b96841fe8d 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/storage.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js @@ -200,7 +200,7 @@ define(function(require) { if (disk.IMAGE_ID && StateActions.enabledStateAction("VM.disk_saveas", that.element.STATE, that.element.LCM_STATE)) { actions += '\ - ' + Locale.tr("Save as") + '  '; + ' + Locale.tr("Save as") + '  '; } } @@ -208,7 +208,7 @@ define(function(require) { if (Config.isTabActionEnabled("vms-tab", "VM.detachdisk")) { if (StateActions.enabledStateAction("VM.detachdisk", that.element.STATE, that.element.LCM_STATE) && !disk.CONTEXT) { actions += ('\ - ' + Locale.tr("Detach") + + ' + Locale.tr("Detach") + '  '); } } @@ -216,7 +216,7 @@ define(function(require) { if (Config.isTabActionEnabled("vms-tab", "VM.disk_snapshot_create")) { if (StateActions.enabledStateAction("VM.disk_snapshot_create", that.element.STATE, that.element.LCM_STATE) && !disk.CONTEXT) { actions += ('\ - ' + Locale.tr("Snapshot") + + ' + Locale.tr("Snapshot") + ''); } } @@ -441,26 +441,27 @@ define(function(require) { } html += Humanize.prettyTime(snapshot.DATE) + SPACE + + Humanize.sizeFromMB(snapshot.SIZE) + SPACE + (snapshot.NAME ? snapshot.NAME + SPACE : ''); if (Config.isTabActionEnabled("vms-tab", "VM.disk_saveas") && StateActions.enabledStateAction("VM.disk_saveas", that.element.STATE, that.element.LCM_STATE)) { html += '\ - ' + Locale.tr("Save as") + '  '; + ' + Locale.tr("Save as") + '  '; } if (Config.isTabActionEnabled("vms-tab", "VM.disk_snapshot_revert") && StateActions.enabledStateAction("VM.disk_snapshot_revert", that.element.STATE, that.element.LCM_STATE)) { - html += '' + Locale.tr("Revert") + '  '; + html += '' + Locale.tr("Revert") + '  '; } if(!active){ if (Config.isTabActionEnabled("vms-tab", "VM.disk_snapshot_delete") && StateActions.enabledStateAction("VM.disk_snapshot_delete", that.element.STATE, that.element.LCM_STATE)) { - html += '' + Locale.tr("Delete") + ''; + html += '' + Locale.tr("Delete") + ''; } } diff --git a/src/sunstone/public/app/utils/accounting.js b/src/sunstone/public/app/utils/accounting.js index 46f35d1bcb..0083433ac4 100644 --- a/src/sunstone/public/app/utils/accounting.js +++ b/src/sunstone/public/app/utils/accounting.js @@ -212,6 +212,7 @@ define(function(require) { function _fillAccounting(context, req, response, no_table) { $("#acct_cpu_graph", context).html(TemplateEmptyGraph()); $("#acct_mem_graph", context).html(TemplateEmptyGraph()); + $("#acct_disk_graph", context).html(TemplateEmptyGraph()); var options = req.request.data[0]; @@ -402,6 +403,9 @@ define(function(require) { series[group_by].data_points[times[0]].MEM_HOURS = 0; series[group_by].data_points[times[times.length-2]].MEM_HOURS = 0; + series[group_by].data_points[times[0]].DISK_HOURS = 0; + series[group_by].data_points[times[times.length-2]].DISK_HOURS = 0; + var name = group_by_name(history); series[group_by].name = name; series[group_by].label = group_by_prefix+" "+group_by+" "+name; @@ -420,6 +424,7 @@ define(function(require) { serie[t] = {}; serie[t].CPU_HOURS = 0; serie[t].MEM_HOURS = 0; + serie[t].DISK_HOURS = 0; } if( (history.ETIME*1000 > t || history.ETIME == 0) && @@ -437,9 +442,11 @@ define(function(require) { var n_hours = (etime - stime) / 1000 / 60 / 60; + var template = history.VM.TEMPLATE; + // --- cpu --- - var val = parseFloat(history.VM.TEMPLATE.CPU) * n_hours; + var val = parseFloat(template.CPU) * n_hours; if (!isNaN(val)){ serie[t].CPU_HOURS += val; @@ -447,11 +454,48 @@ define(function(require) { // --- mem --- - var val = parseInt(history.VM.TEMPLATE.MEMORY)/1024 * n_hours; + var val = parseInt(template.MEMORY)/1024 * n_hours; if (!isNaN(val)){ serie[t].MEM_HOURS += val; } + + // --- DISK --- + + var disks = []; + if ($.isArray(template.DISK)) + disks = template.DISK; + else if (!$.isEmptyObject(template.DISK)) + disks = [template.DISK]; + + var snapshots = []; + if ($.isArray(template.SNAPSHOTS)){ + snapshots = template.SNAPSHOTS; + } else if (!$.isEmptyObject(template.SNAPSHOTS)) { + snapshots = [template.SNAPSHOTS]; + } + + var val = 0; + $.each(disks, function(index, disk){ + val += parseInt(disk.SIZE) * n_hours; + }) + + // snapshots is an array that contains the snapshots for each DISK + $.each(snapshots, function(index, snapshotForDisk){ + var diskSnapshots = [] + if (!$.isArray(snapshotForDisk.SNAPSHOT)){ + diskSnapshots = [snapshotForDisk.SNAPSHOT]; + } + + // diskSnapshots contains the snapshots for a specific DISK + $.each(diskSnapshots, function(index, snapshot){ + val += parseInt(snapshot.SIZE) * n_hours; + }) + }) + + if (!isNaN(val)){ + serie[t].DISK_HOURS += val; + } } } }); @@ -462,14 +506,17 @@ define(function(require) { var cpu_plot_series = []; var mem_plot_series = []; + var disk_plot_series = []; $.each(series, function(key, val){ var cpu_data = []; var mem_data = []; + var disk_data = []; $.each(val.data_points, function(time,num){ cpu_data.push([parseInt(time),num.CPU_HOURS]); mem_data.push([parseInt(time),num.MEM_HOURS]); + disk_data.push([parseInt(time),num.DISK_HOURS]); }); cpu_plot_series.push( @@ -487,10 +534,19 @@ define(function(require) { id: key, data: mem_data }); + + disk_plot_series.push( + { + label: val.label, + name: val.name, + id: key, + data: disk_data + }); }); var cpu_plot = $.plot($("#acct_cpu_graph", context), cpu_plot_series, options); var mem_plot = $.plot($("#acct_mem_graph", context), mem_plot_series, options); + var disk_plot = $.plot($("#acct_disk_graph", context), disk_plot_series, options); //-------------------------------------------------------------------------- // Init dataTables @@ -513,8 +569,16 @@ define(function(require) { $("#acct_mem_datatable",context).width("100%"); + $("#acct_disk_datatable",context).dataTable().fnClearTable(); + $("#acct_disk_datatable",context).dataTable().fnDestroy(); + + $("#acct_disk_datatable thead",context).remove(); + $("#acct_disk_datatable",context).width("100%"); + + cpu_plot_data = cpu_plot.getData(); mem_plot_data = mem_plot.getData(); + disk_plot_data = disk_plot.getData(); var thead = '\ @@ -550,26 +614,48 @@ define(function(require) { $("#acct_mem_datatable",context).append(thead); + thead = + '\ + \ + '+Locale.tr("Date UTC")+'\ + '+Locale.tr("Total")+''; + + $.each(disk_plot_data, function(i, serie){ + thead += ''+ + group_by_prefix+' '+serie.id+'
    '+serie.name+''; + }); + + thead += ''; + + $("#acct_disk_datatable",context).append(thead); + var cpu_dataTable_data = []; var mem_dataTable_data = []; + var disk_dataTable_data = []; for (var i = 0; i 0) { acct_cpu_dataTable.fnAddData(cpu_dataTable_data); } @@ -619,6 +719,10 @@ define(function(require) { if (mem_dataTable_data.length > 0) { acct_mem_dataTable.fnAddData(mem_dataTable_data); } + + if (disk_dataTable_data.length > 0) { + acct_disk_dataTable.fnAddData(disk_dataTable_data); + } } $("#acct_placeholder", context).hide(); diff --git a/src/sunstone/public/app/utils/accounting/html.hbs b/src/sunstone/public/app/utils/accounting/html.hbs index 299bddc437..b9dc83053e 100644 --- a/src/sunstone/public/app/utils/accounting/html.hbs +++ b/src/sunstone/public/app/utils/accounting/html.hbs @@ -74,6 +74,15 @@
    +
    +
    +

    {{tr "Disk MB hours"}}

    +
    +
    +
    +
    +
    +

    {{#advancedSection (tr "Accounting Tables") }}
    @@ -108,5 +117,21 @@
    +
    +
    +

    {{tr "Disk MB hours"}}

    +
    +
    + + + + + + + + +
    {{tr "Date"}}
    +
    +
    {{/advancedSection}} -
    \ No newline at end of file +
    diff --git a/src/sunstone/public/app/utils/graphs.js b/src/sunstone/public/app/utils/graphs.js index eab14fd688..f283198c32 100644 --- a/src/sunstone/public/app/utils/graphs.js +++ b/src/sunstone/public/app/utils/graphs.js @@ -51,7 +51,7 @@ define(function(require) { } var humanize = info.humanize_figures ? - Humanize.size : function(val) { return val }; + Humanize.size : function(val) { return (val * 100).toFixed() / 100 }; var options = { // colors: [ "#cdebf5", "#2ba6cb", "#6f6f6f" ]