Sha256: a8d7f2c357aeea770b69abe87bf85556240f614682c0650ee15faca620e3b7d0

Contents?: true

Size: 1.45 KB

Versions: 43

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Facts
  module Solaris
    class Zones
      FACT_NAME = 'solaris_zones.zones'
      ALIASES = %w[
        zone_.*_brand
        zone_.*_iptype
        zone_.*_name
        zone_.*_uuid
        zone_.*_id
        zone_.*_path
        zone_.*_status
        zones
      ].freeze

      def call_the_resolver
        resolved_facts = []
        zones = {}

        results = Facter::Resolvers::Solaris::Zone.resolve(:zone)
        return Facter::ResolvedFact.new(FACT_NAME, nil) unless results

        results&.each do |result|
          zones.merge!(parse_result(result))
          resolved_facts << create_legacy_zone_facts(result)
        end

        resolved_facts << Facter::ResolvedFact.new('solaris_zones.zones', zones)
        resolved_facts << Facter::ResolvedFact.new('zones', results.count, :legacy)

        resolved_facts.flatten
      end

      private

      def parse_result(result)
        {
          result[:name].to_sym => {
            brand: result[:brand],
            id: result[:id],
            ip_type: result[:iptype],
            path: result[:path],
            status: result[:status]
          }
        }
      end

      def create_legacy_zone_facts(zone)
        legacy_facts = []
        %w[brand iptype name uuid id path status].each do |key|
          legacy_facts << Facter::ResolvedFact.new("zone_#{zone[:name]}_#{key}", zone[key.to_sym], :legacy)
        end

        legacy_facts
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
facter-4.2.10 lib/facter/facts/solaris/zones.rb
facter-4.2.9 lib/facter/facts/solaris/zones.rb
facter-4.2.8 lib/facter/facts/solaris/zones.rb
facter-4.2.7 lib/facter/facts/solaris/zones.rb
facter-4.2.6 lib/facter/facts/solaris/zones.rb
facter-4.2.5 lib/facter/facts/solaris/zones.rb
facter-4.2.4 lib/facter/facts/solaris/zones.rb
facter-4.2.3 lib/facter/facts/solaris/zones.rb
facter-4.2.2 lib/facter/facts/solaris/zones.rb
facter-4.2.1 lib/facter/facts/solaris/zones.rb
facter-4.2.0 lib/facter/facts/solaris/zones.rb
facter-4.1.1 lib/facter/facts/solaris/zones.rb
facter-4.1.0 lib/facter/facts/solaris/zones.rb
facter-4.0.52 lib/facter/facts/solaris/zones.rb
facter-4.0.51 lib/facter/facts/solaris/zones.rb
facter-4.0.50 lib/facter/facts/solaris/zones.rb
facter-4.0.49 lib/facter/facts/solaris/zones.rb
facter-4.0.48 lib/facter/facts/solaris/zones.rb
facter-4.0.47 lib/facter/facts/solaris/zones.rb
facter-4.0.46 lib/facter/facts/solaris/zones.rb