module FVMUtil

Miscellaneous utility functions

Public Instance Methods

gigabytes(s) click to toggle source

Given an amount in bytes, return the human-readable version in GiB

# File lib/foreman_vm/util.rb, line 9
def gigabytes(s)
  if s.to_i < 1073741824
    mb = s.to_f / 1024 / 1024
    sprintf '%0.0f MiB', mb
  else
    gb = s.to_f / 1024 / 1024 / 1024
    sprintf '%0.0f GiB', gb
  end
end
shortname(fqdn) click to toggle source

Given an FQDN, return the shortname

# File lib/foreman_vm/util.rb, line 4
 def shortname(fqdn)
  fqdn.sub(/\..*/, '') 
end