Sha256: e39c647b2cea08befb4a0f2c88cbbf11e48da4c2ba2d376c87041acafe15aa0f

Contents?: true

Size: 1.28 KB

Versions: 33

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Solaris
      class Zone < BaseResolver
        init_resolver

        class << self
          private

          def post_resolve(fact_name, _options)
            @fact_list.fetch(fact_name) { build_zone_fact(fact_name) }
          end

          def build_zone_fact(fact_name)
            command = '/usr/sbin/zoneadm list -cp'
            zone_adm_output = Facter::Core::Execution.execute(command, logger: log)

            if zone_adm_output.empty?
              log.debug("Command #{command} returned an empty result")
              return
            end
            @fact_list[:zone] = create_zone_facts(zone_adm_output)

            @fact_list[fact_name]
          end

          def create_zone_facts(zones_result)
            zones_fact = []
            zones_result.each_line do |zone_line|
              id, name, status, path, uuid, brand, ip_type = zone_line.split(':')
              zones_fact << {
                brand: brand,
                id: id,
                iptype: ip_type.chomp,
                name: name,
                uuid: uuid,
                status: status,
                path: path
              }
            end
            zones_fact
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
facter-4.2.10 lib/facter/resolvers/solaris/zone.rb
facter-4.2.9 lib/facter/resolvers/solaris/zone.rb
facter-4.2.8 lib/facter/resolvers/solaris/zone.rb
facter-4.2.7 lib/facter/resolvers/solaris/zone.rb
facter-4.2.6 lib/facter/resolvers/solaris/zone.rb
facter-4.2.5 lib/facter/resolvers/solaris/zone.rb
facter-4.2.4 lib/facter/resolvers/solaris/zone.rb
facter-4.2.3 lib/facter/resolvers/solaris/zone.rb
facter-4.2.2 lib/facter/resolvers/solaris/zone.rb
facter-4.2.1 lib/facter/resolvers/solaris/zone.rb
facter-4.2.0 lib/facter/resolvers/solaris/zone.rb
facter-4.1.1 lib/facter/resolvers/solaris/zone.rb
facter-4.1.0 lib/facter/resolvers/solaris/zone.rb