diff --git a/src/cli/etc/onedatastore.yaml b/src/cli/etc/onedatastore.yaml index ee1fe3be79..9081f21403 100644 --- a/src/cli/etc/onedatastore.yaml +++ b/src/cli/etc/onedatastore.yaml @@ -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 diff --git a/src/cli/one_helper/onedatastore_helper.rb b/src/cli/one_helper/onedatastore_helper.rb index b5ae134e07..3137ab700e 100644 --- a/src/cli/one_helper/onedatastore_helper.rb +++ b/src/cli/one_helper/onedatastore_helper.rb @@ -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|