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? }.map { |key, value| [key, truncated_value(value)] } 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_params || {}) .select { |_name, value| value.present? || value.is_a?(FalseClass) } .map { |key, value| [key, truncated_value(value)] } end
Private Instance Methods
content_data()
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 47 def content_data (@host.lifecycle_environments.uniq || []).map { |item| ['lifecycle_environment', item.name] } + (@host.activation_keys || []).map { |item| ['activation_key', item.name] } + (@host.content_views || []).map { |item| ['content_view', 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 53 def satellite_server_data [ ['satellite_instance_id', Foreman.instance_id], ['organization_id', @host.organization_id.to_s], ] end
truncated_value(value)
click to toggle source
# File lib/foreman_inventory_upload/generators/tags.rb, line 60 def truncated_value(value) return 'Original value exceeds 250 characters' if value.to_s.length > 250 value end