Sha256: 91112780920a575f41636f8f9eadd21fcbb4baad1e6540a6d273ef6e2e97c50a
Contents?: true
Size: 1.67 KB
Versions: 7
Compression:
Stored size: 1.67 KB
Contents
module ForemanInventoryUpload module Generators class Tags def initialize(host) @host = host end def generate ( locations + hostgroups + host_collections + organizations + content_data + satellite_server_data ).reject { |key, value| value.empty? } end 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 def locations return [] unless @host.location @host.location.title.split('/').map { |item| ['location', item] }.push(['location', @host.location.title]) end def hostgroups return [] unless @host.hostgroup @host.hostgroup.title.split('/').map { |item| ['hostgroup', item] }.push(['hostgroup', @host.hostgroup.title]) end def host_collections (@host.host_collections || []).map { |item| ['host collection', item.name] } end def organizations [['organization', @host.organization.name]] end 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 def satellite_server_data [ ['satellite_instance_id', Foreman.instance_id], ['organization_id', @host.organization_id.to_s], ] end end end end
Version data entries
7 entries across 7 versions & 1 rubygems