mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-27 03:21:29 +03:00
feature #788: Optional base unit for unit_to_str method
This commit is contained in:
parent
c8f44ede9a
commit
d488cffddc
@ -363,11 +363,11 @@ EOT
|
||||
|
||||
BinarySufix = ["K", "M", "G", "T" ]
|
||||
|
||||
def OpenNebulaHelper.unit_to_str(value, options)
|
||||
def OpenNebulaHelper.unit_to_str(value, options, unit="K")
|
||||
if options[:kilobytes]
|
||||
value
|
||||
else
|
||||
i=0
|
||||
i=BinarySufix.index(unit).to_i
|
||||
|
||||
while value > 1024 && i < 3 do
|
||||
value /= 1024.0
|
||||
|
@ -130,7 +130,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
column :SIZE, "Size of the image",
|
||||
:size=>7 do |d|
|
||||
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,options)
|
||||
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,options,"M")
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :SIZE, :TYPE, :REGTIME, :PUBLIC,
|
||||
|
Loading…
Reference in New Issue
Block a user