Skip to content

Commit

Permalink
Merge pull request #1999 from sebastian-miclea/FACT-2040
Browse files Browse the repository at this point in the history
(FACT-2040) Added solaris memory resolver
  • Loading branch information
Bogdan Irimie authored Aug 4, 2020
2 parents e818c93 + 46faa70 commit f412202
Show file tree
Hide file tree
Showing 32 changed files with 937 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/swap/available.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class Available
FACT_NAME = 'memory.swap.available'
ALIASES = 'swapfree'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
end
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/swap/available_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class AvailableBytes
FACT_NAME = 'memory.swap.available_bytes'
ALIASES = 'swapfree_mb'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
fact_value = fact_value[:available_bytes] if fact_value

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/solaris/memory/swap/capacity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class Capacity
FACT_NAME = 'memory.swap.capacity'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
fact_value = fact_value[:capacity] if fact_value

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/swap/total.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class Total
FACT_NAME = 'memory.swap.total'
ALIASES = 'swapsize'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
end
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/swap/total_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class TotalBytes
FACT_NAME = 'memory.swap.total_bytes'
ALIASES = 'swapsize_mb'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
fact_value = fact_value[:total_bytes] if fact_value

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
end
end
end
21 changes: 21 additions & 0 deletions lib/facter/facts/solaris/memory/swap/used.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class Used
FACT_NAME = 'memory.swap.used'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
end
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/facter/facts/solaris/memory/swap/used_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module Swap
class UsedBytes
FACT_NAME = 'memory.swap.used_bytes'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:swap)
fact_value = fact_value[:used_bytes] if fact_value
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/system/available.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class Available
FACT_NAME = 'memory.system.available'
ALIASES = 'memoryfree'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:available_bytes])
end
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/system/available_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class AvailableBytes
FACT_NAME = 'memory.system.available_bytes'
ALIASES = 'memoryfree_mb'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
fact_value = fact_value[:available_bytes] if fact_value

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/solaris/memory/system/capacity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class Capacity
FACT_NAME = 'memory.system.capacity'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
fact_value = fact_value[:capacity] if fact_value

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/system/total.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class Total
FACT_NAME = 'memory.system.total'
ALIASES = 'memorysize'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:total_bytes])
end
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/facter/facts/solaris/memory/system/total_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class TotalBytes
FACT_NAME = 'memory.system.total_bytes'
ALIASES = 'memorysize_mb'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
fact_value = fact_value[:total_bytes] if fact_value

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, Facter::FactsUtils::UnitConverter.bytes_to_mb(fact_value), :legacy)]
end
end
end
end
end
end
21 changes: 21 additions & 0 deletions lib/facter/facts/solaris/memory/system/used.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class Used
FACT_NAME = 'memory.system.used'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
if fact_value
fact_value = Facter::FactsUtils::UnitConverter.bytes_to_human_readable(fact_value[:used_bytes])
end
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/facter/facts/solaris/memory/system/used_bytes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Facts
module Solaris
module Memory
module System
class UsedBytes
FACT_NAME = 'memory.system.used_bytes'

def call_the_resolver
fact_value = Facter::Resolvers::Solaris::Memory.resolve(:system)
fact_value = fact_value[:used_bytes] if fact_value
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
end
Loading

0 comments on commit f412202

Please sign in to comment.