Sha256: 7622c7abe7443b47759a6f4a1c8f888d9cdcf4339d481b9bdc55c0d1ac0be778

Contents?: true

Size: 1.46 KB

Versions: 79

Compression:

Stored size: 1.46 KB

Contents

# Fact: ldom
#
# Purpose:
#   Returns a list of dynamic facts that describe the attributes of
#   a Solaris logical domain. The facts returned will include: domainrole,
#   domainname, domainuuid, domaincontrol, and domainchassis.
#
# Resolution:
#   Uses the output of `virtinfo -ap`.
#

if Facter.value(:kernel) == 'SunOS' &&
   Facter.value(:hardwareisa) == 'sparc' &&
   Facter::Core::Execution.which('virtinfo')

  virtinfo = Facter::Core::Execution.exec('virtinfo -ap')

  # Convert virtinfo parseable output format to array of arrays.
  # DOMAINROLE|impl=LDoms|control=true|io=true|service=true|root=true
  # DOMAINNAME|name=primary
  # DOMAINUUID|uuid=8e0d6ec5-cd55-e57f-ae9f-b4cc050999a4
  # DOMAINCONTROL|name=san-t2k-6
  # DOMAINCHASSIS|serialno=0704RB0280
  #
  # For keys containing multiple value such as domain role:
  # ldom_{key}_{subkey} = value
  # Otherwise the fact will simply be:
  # ldom_{key} = value
  unless virtinfo.nil?
    virt_array = virtinfo.split("\n").select{|l| l =~ /^DOMAIN/ }.
      collect{|l| l.split('|')}
    virt_array.each do |x|
      key = x[0]
      value = x[1..x.size]

      if value.size == 1
        Facter.add("ldom_#{key.downcase}") do
          setcode { value.first.split('=')[1] }
        end
      else
        value.each do |y|
          k = y.split('=')[0]
          v = y.split('=')[1]
          Facter.add("ldom_#{key.downcase}_#{k.downcase}") do
            setcode { v }
          end
        end
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
facter-2.5.7 lib/facter/ldom.rb
facter-2.5.7-x86-mingw32 lib/facter/ldom.rb
facter-2.5.7-x64-mingw32 lib/facter/ldom.rb
facter-2.5.7-universal-darwin lib/facter/ldom.rb
facter-2.5.6-x86-mingw32 lib/facter/ldom.rb
facter-2.5.6-x64-mingw32 lib/facter/ldom.rb
facter-2.5.6-universal-darwin lib/facter/ldom.rb
facter-2.5.6 lib/facter/ldom.rb
facter-2.5.5-x86-mingw32 lib/facter/ldom.rb
facter-2.5.5-x64-mingw32 lib/facter/ldom.rb
facter-2.5.5-universal-darwin lib/facter/ldom.rb
facter-2.5.5 lib/facter/ldom.rb
facter-2.5.4-x86-mingw32 lib/facter/ldom.rb
facter-2.5.4-x64-mingw32 lib/facter/ldom.rb
facter-2.5.4-universal-darwin lib/facter/ldom.rb
facter-2.5.4 lib/facter/ldom.rb
bolt-0.24.0 vendored/facter/lib/facter/ldom.rb
bolt-0.23.0 vendored/facter/lib/facter/ldom.rb
bolt-0.22.0 vendored/facter/lib/facter/ldom.rb
bolt-0.21.8 vendored/facter/lib/facter/ldom.rb