Skip to content

Commit

Permalink
Merge pull request #2147 from sebastian-miclea/FACT-2834
Browse files Browse the repository at this point in the history
(FACT-2834) Dinamically get AIX proc number
  • Loading branch information
oanatmaria authored Oct 21, 2020
2 parents 8fdf1b5 + 02bd913 commit 78ac1be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
16 changes: 15 additions & 1 deletion lib/facter/resolvers/aix/architecture_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def post_resolve(fact_name)

def read_architecture(fact_name)
require_relative 'utils/odm_query'

proc_number = read_proc
odmquery = ODMQuery.new
odmquery
.equals('name', 'proc0')
.equals('name', proc_number)
.equals('attribute', 'type')

result = odmquery.execute
Expand All @@ -32,6 +34,18 @@ def read_architecture(fact_name)

@fact_list[fact_name]
end

def read_proc
odmquery = ODMQuery.new
odmquery
.equals('PdDvLn', 'processor/sys/proc_rspc')
.equals('status', '1')

result = odmquery.execute
result.each_line do |line|
return line.split('=')[1].strip.delete('\"') if line.include?('name')
end
end
end
end
end
Expand Down
15 changes: 10 additions & 5 deletions spec/facter/resolvers/aix/architecture_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
describe Facter::Resolvers::Architecture do
describe '#resolve' do
before do
odm = double('ODMQuery')
odm1 = instance_double(Facter::ODMQuery)
odm2 = instance_double(Facter::ODMQuery)

allow(Facter::ODMQuery).to receive(:new).and_return(odm)
allow(odm).to receive(:equals).with('name', 'proc0').and_return(odm)
allow(odm).to receive(:equals).with('attribute', 'type')
allow(odm).to receive(:execute).and_return(result)
allow(Facter::ODMQuery).to receive(:new).and_return(odm1, odm2)
allow(odm1).to receive(:equals).with('PdDvLn', 'processor/sys/proc_rspc').and_return(odm1)
allow(odm1).to receive(:equals).with('status', '1').and_return(odm1)
allow(odm1).to receive(:execute).and_return('proc8')

allow(odm2).to receive(:equals).with('name', 'proc8').and_return(odm2)
allow(odm2).to receive(:equals).with('attribute', 'type').and_return(odm2)
allow(odm2).to receive(:execute).and_return(result)
end

after do
Expand Down

0 comments on commit 78ac1be

Please sign in to comment.