Class: ForemanInventoryUpload::Generators::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_inventory_upload/generators/tags.rb

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Tags

Returns a new instance of Tags.



4
5
6
# File 'lib/foreman_inventory_upload/generators/tags.rb', line 4

def initialize(host)
  @host = host
end

Instance Method Details

#generateObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/foreman_inventory_upload/generators/tags.rb', line 8

def generate
  (
    locations +
    hostgroups +
    host_collections +
    organizations +
    content_data +
    satellite_server_data
  ).reject { |key, value| value.empty? }.map { |key, value| [key, truncated_value(value)] }
end

#generate_parametersObject



19
20
21
22
23
24
25
# File 'lib/foreman_inventory_upload/generators/tags.rb', line 19

def generate_parameters
  return [] unless Setting[:include_parameter_tags]

  (@host.host_params || {})
    .select { |_name, value| value.present? || value.is_a?(FalseClass) }
    .map { |key, value| [key, truncated_value(value)] }
end