feature #1613: ondatastore command shows capacity information

This commit is contained in:
Ruben S. Montero committed 2013-07-05 17:41:01 +02:00
1 parent 4d00e2bf32
commit 0e2a876525
2 files changed
+35 -5

No files matched your search

+14 -2
View File
@@ -5,12 +5,22 @@
:NAME:
:desc: Name of the Datastore
:size: 25
:size: 13
:left: true
:SIZE:
:desc: Total Datastore size
:size: 10
:left: true
:AVAIL:
:desc: Free Datastore size (%)
:size: 5
:left: true
:CLUSTER:
:desc: Name of the Cluster
:size: 15
:size: 12
:left: true
:IMAGES:
@@ -35,6 +45,8 @@
:default:
- :ID
- :NAME
- :SIZE
- :AVAIL
- :CLUSTER
- :IMAGES
- :TYPE
+21 -3
View File
@@ -44,11 +44,23 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
d["ID"]
end
column :NAME, "Name of the Datastore", :left, :size=>25 do |d|
column :NAME, "Name of the Datastore", :left, :size=>13 do |d|
d["NAME"]
end
column :CLUSTER, "Name of the Cluster", :left, :size=>15 do |d|
column :SIZE, "Datastore total size", :left, :size =>10 do |d|
OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M')
end
column :AVAIL, "Datastore free size", :left, :size =>5 do |d|
if d['TOTAL_MB'].to_i == 0
"-"
else
"#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round()}%"
end
end
column :CLUSTER, "Name of the Cluster", :left, :size=>12 do |d|
OpenNebulaHelper.cluster_str(d["CLUSTER"])
end
@@ -73,7 +85,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
d["TM_MAD"]
end
default :ID, :NAME, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
default :ID, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
end
table
@@ -113,6 +125,12 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
puts str % ["DISK_TYPE",Image::DISK_TYPES[datastore['DISK_TYPE'].to_i]]
puts
CLIHelper.print_header(str_h1 % "DATASTORE CAPACITY", false)
puts str % ["TOTAL:", OpenNebulaHelper.unit_to_str(datastore['TOTAL_MB'].to_i, {},'M')]
puts str % ["USED: ", OpenNebulaHelper.unit_to_str(datastore['USED_MB'].to_i, {},'M')]
puts str % ["FREE:", OpenNebulaHelper.unit_to_str(datastore['FREE_MB'].to_i, {},'M')]
puts
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
["OWNER", "GROUP", "OTHER"].each { |e|