Sha256: 4a555beebc04cdb210c37b58e4bc83f4bdf81fbe299823ea61222acf7d242715

Contents?: true

Size: 1.44 KB

Versions: 81

Compression:

Stored size: 1.44 KB

Contents

module ForemanRhCloud
  class BranchInfo
    def generate(uuid, host, branch_id, request_hostname)
      {
        :remote_leaf => uuid,
        :remote_branch => branch_id,
        :display_name => host.organization.name,
        :hostname => request_hostname,
        :product => {
          :type => core_app_name,
          :major_version => core_app_version.major,
          :minor_version => core_app_version.minor,
        },
        :organization_id => host.organization.id,
        :satellite_instance_id => Foreman.instance_id,
        :labels => host_labels(host),
      }
    end

    def core_app_name
      'Foreman'
    end

    def core_app_version
      Foreman::Version.new
    end

    def new_label(key, value, namespace)
      {
        :namespace => namespace,
        :key => key,
        :value => value,
      }
    end

    def labels_from_items(items, label_namespace, label_lamb, label_value_method = :to_s)
      items.map { |item| new_label(label_lamb.call(item), item.public_send(label_value_method), label_namespace) }
    end

    def host_labels(host)
      tags_generator = ForemanInventoryUpload::Generators::Tags.new(host)
      tags_generator.generate.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_NAMESPACE) } +
        tags_generator.generate_parameters.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_PARAMS_NAMESPACE) }
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.27 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.26 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.26 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.25.1 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.25 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.25 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.24.1 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.24.1 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.24 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.24 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.23 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.23 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.22 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.22 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-4.0.21.1 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.21.1 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.21 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.20 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.19 app/services/foreman_rh_cloud/branch_info.rb
foreman_rh_cloud-3.0.18.1 app/services/foreman_rh_cloud/branch_info.rb