Class: Facts::Solaris::Ldom

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/facts/solaris/ldom.rb

Constant Summary collapse

FACT_NAME =
'ldom'
ALIASES =
%w[
  ldom_domainchassis
  ldom_domaincontrol
  ldom_domainname
  ldom_domainrole_control
  ldom_domainrole_impl
  ldom_domainrole_io
  ldom_domainrole_root
  ldom_domainrole_service
  ldom_domainuuid
].freeze

Instance Method Summary collapse

Constructor Details

#initializeLdom

Returns a new instance of Ldom.



19
20
21
# File 'lib/facter/facts/solaris/ldom.rb', line 19

def initialize
  @log = Facter::Log.new(self)
end

Instance Method Details

#call_the_resolverObject



23
24
25
26
27
28
29
# File 'lib/facter/facts/solaris/ldom.rb', line 23

def call_the_resolver
  @log.debug('Solving the ldom fact.')
  fact_value = resolve_fact
  return Facter::ResolvedFact.new(FACT_NAME, nil) if fact_value.nil?

  create_resolved_facts_list(fact_value)
end

#create_resolved_facts_list(fact_value) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/facter/facts/solaris/ldom.rb', line 54

def create_resolved_facts_list(fact_value)
  resolved_facts = [Facter::ResolvedFact.new(FACT_NAME, fact_value)]
  ALIASES.each do |fact_alias|
    key = fact_alias.split('_')[1..-1].map!(&:to_sym)
    resolved_facts << Facter::ResolvedFact.new(fact_alias, fact_value.dig(*key), :legacy)
  end

  resolved_facts
end

#resolve(key) ⇒ Object



50
51
52
# File 'lib/facter/facts/solaris/ldom.rb', line 50

def resolve(key)
  Facter::Resolvers::Solaris::Ldom.resolve(key)
end

#resolve_factObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/facter/facts/solaris/ldom.rb', line 31

def resolve_fact
  chassis_serial = resolve(:chassis_serial)
  return nil if !chassis_serial || chassis_serial.empty?

  {
    domainchassis: chassis_serial,
    domaincontrol: resolve(:control_domain),
    domainname: resolve(:domain_name),
    domainrole: {
      control: resolve(:role_control),
      impl: resolve(:role_impl),
      io: resolve(:role_io),
      root: resolve(:role_root),
      service: resolve(:role_service)
    },
    domainuuid: resolve(:domain_uuid)
  }
end