Method: Utils.generate_os_hash

Defined in:
lib/vmfloaty/utils.rb

.generate_os_hash(os_args) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/vmfloaty/utils.rb', line 84

def self.generate_os_hash(os_args)
  # expects args to look like:
  # ["centos", "debian=5", "windows=1"]

  # Build vm hash where
  #
  #  [operating_system_type1 -> total,
  #   operating_system_type2 -> total,
  #   ...]
  os_types = {}
  os_args.each do |arg|
    os_arr = arg.split('=')
    os_types[os_arr[0]] = os_arr.size == 1 ? 1 : os_arr[1].to_i
  end
  os_types
end