class ForemanInventoryUpload::Generators::Tags
Public Class Methods
new(host)
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 4 def initialize(host) @host = host end
Public Instance Methods
generate()
click to toggle source
# 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? } end
generate_parameters()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 19 def generate_parameters return [] unless Setting[:include_parameter_tags] (@host.host_inherited_params_objects || []) .map { |item| [item.name, item.value] } .select { |_name, value| value.present? || value.is_a?(FalseClass) } end
Private Instance Methods
content_data()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 47 def content_data [ ['lifecycle_environment', @host.lifecycle_environment&.name], ['content_view', @host.content_view&.name], ] + (@host.activation_keys || []).map { |item| ['activation_key', item.name] } end
host_collections()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 39 def host_collections (@host.host_collections || []).map { |item| ['host collection', item.name] } end
hostgroups()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 34 def hostgroups return [] unless @host.hostgroup @host.hostgroup.title.split('/').map { |item| ['hostgroup', item] }.push(['hostgroup', @host.hostgroup.title]) end
locations()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 29 def locations return [] unless @host.location @host.location.title.split('/').map { |item| ['location', item] }.push(['location', @host.location.title]) end
organizations()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 43 def organizations [['organization', @host.organization.name]] end
satellite_server_data()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 55 def satellite_server_data [ ['satellite_instance_id', Foreman.instance_id], ['organization_id', @host.organization_id.to_s], ] end