Module: Staypuft::Concerns::HostDetailsHelper

Extended by:
ActiveSupport::Concern
Defined in:
app/models/staypuft/concerns/host_details_helper.rb

Instance Method Summary collapse

Instance Method Details

#architecturesObject

Returns architecture



47
48
49
50
51
52
53
# File 'app/models/staypuft/concerns/host_details_helper.rb', line 47

def architectures
  if self.facts_hash["architecture"]
    self.facts_hash["architecture"].name
  else
    nil
  end
end

#cpusObject

Returns total number of processes



28
29
30
# File 'app/models/staypuft/concerns/host_details_helper.rb', line 28

def cpus
  self.facts_hash["processorcount"]
end

#memObject

Returns memory in GB



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/staypuft/concerns/host_details_helper.rb', line 7

def mem
  mem_arr = self.facts_hash["memorytotal"]
  if mem_arr
    mem_str, mem_unit = mem_arr.split(" ")
    mem_number = mem_str.to_f
    case mem_unit
    when "MB"
      mem_number / 1024
    when "GB"
      mem_number
    when "TB"
      mem_number * 1024
    else
      nil
    end
  else
    nil
  end
end

#model_typeObject

Returns model



33
34
35
# File 'app/models/staypuft/concerns/host_details_helper.rb', line 33

def model_type
  self.facts_hash["hardwaremodel"]
end

#network_interfacesObject

Returns array of NIC names



38
39
40
41
42
43
44
# File 'app/models/staypuft/concerns/host_details_helper.rb', line 38

def network_interfaces
  if self.facts_hash["interfaces"]
    self.facts_hash["interfaces"].split(",")
  else
    nil
  end
end