Sha256: 95b22e3ca60668f14322a7881d555ea794cd249cad0ba1ffd7e865a2b673f448

Contents?: true

Size: 1.88 KB

Versions: 66

Compression:

Stored size: 1.88 KB

Contents

Facter.add('site') do
  setcode do
    if File.size?('/etc/onering/static/site')
      site = File.read('/etc/onering/static/site').strip.chomp

    else
      if File.exists?('/proc/cmdline')
        site = (File.read('/proc/cmdline').chomp.split(' ').select{|i| i =~ /^domain=/ }.first rescue nil)
        site = site.split('=', 2).last if site
        site = site.split('.').first if site
      end
    end

    site = nil if ['test', 'hw', 'vm'].include?(site)

    if site
      site
    else
      Facter.value('fqdn').split('.')[-3].downcase rescue nil
    end
  end
end

Facter.add('environment') do
  setcode do
    env = (Facter.value('fqdn').split('.').first.split('-')[-2].downcase rescue nil)

    case env
    when 'dev'
      'development'
    when /(stg|stage)/
      'staging'
    when 'prod'
      'production'
    else
      nil
    end
  end
end

Facter.add('slot') do
  setcode do
    slot = Integer(Facter::Util::Resolution.exec("bmc node_number 2> /dev/null")) rescue nil
    slot = nil if slot == 0
    slot
  end
end


ipmi_ok = (Facter::Util::Resolution.exec("ipmiutil health 2> /dev/null | tail -n1 | grep failed") === nil)

if ipmi_ok
  ipmi_lan = Facter::Util::Resolution.exec("ipmitool lan print 1 2> /dev/null")

  if ipmi_lan
    ipmi_lan_data = {}

    ipmi_lan.lines.each do |line|
      key, value = line.split(/:/, 2)
      value = value.strip.squeeze(' ').chomp

      case key
      when /^IP Address/i
        ipmi_lan_data[:ip] = value

      when /^Subnet Mask/i
        ipmi_lan_data[:netmask] = value

      when /^MAC Address/i
        ipmi_lan_data[:macaddress] = value.upcase

      when /^Default Gateway IP/i
        ipmi_lan_data[:gateway] = value

      when /^SNMP Community String/i
        ipmi_lan_data[:snmp_community] = value

      end
    end

    ipmi_lan_data.each do |key, value|
      Facter.add("ipmi_#{key}") do
        setcode { value }
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
onering-report-0.6.5 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.65 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.64 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.63 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.62 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.61 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.60 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.59 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.58 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.57 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.56 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.55 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.54 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.53 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.52 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.51 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.50 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.49 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.48 lib/facter/onering_properties_physical.rb
onering-report-plugins-0.0.47 lib/facter/onering_properties_physical.rb