Sha256: d00a85d82fcb084557cfcc0f2c225882aa67a9e0452891f8defcc54476ea4276

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

Facter.add('signature') do
  setcode do
    if File.size?("/etc/onering/signature")
      parts = File.read("/etc/onering/signature").split("\n").
                reject{|i| i =~ /^\s*#/ }.
                reject{|i| i.strip.chomp.empty? }.
                collect{|i| i.gsub(/\H/,'') }

    elsif Facter.value('macaddress')
      if Facter.value('is_virtual')
        if File.exists?('/sys/hypervisor/uuid')
          parts = [
            File.read('/sys/hypervisor/uuid').strip.chomp.delete('-'),
            Facter.value('macaddress').strip.delete(':')
          ]
        end
      elsif Facter::Util::Resolution.which('dmidecode')
        parts = [
          Facter::Util::Resolution.exec('dmidecode -s system-uuid').strip.chomp.delete('-'),
          Facter.value('macaddress').strip.delete(':')
        ]
      end

    else
      if Facter.value('ipaddress')
        parts = [
          Facter.value('ipaddress').split(',').first.strip.chomp.delete('.')
        ].compact
      end
    end

    (parts && !parts.empty? ? parts.collect{|i| i.upcase }.join('-') : nil)
  end
end

Facter.add('hardwareid') do
  setcode do
    if File.size?('/etc/hardware.id')
      File.read('/etc/hardware.id').strip.chomp rescue nil
    elsif Facter.value('signature')
      require 'digest'
      Digest::SHA256.new.update(Facter.value('signature')).hexdigest[0..5]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
onering-report-plugins-0.0.20 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.19 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.18 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.17 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.16 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.15 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.14 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.13 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.12 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.11 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.10 lib/facter/onering_properties_id.rb
onering-report-plugins-0.0.9 lib/facter/onering_properties_id.rb