Skip to content

Commit

Permalink
aix helper additions
Browse files Browse the repository at this point in the history
no need to POWER cpu version helpers

accept ohai bittiness
  • Loading branch information
Isa Farnik committed Oct 26, 2015
1 parent 035f1ed commit 18a862e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ API
- `sparc?`
- `ppc64?`
- `ppc64le?`
- `powerpc?`

#### Examples
```ruby
Expand Down
15 changes: 14 additions & 1 deletion lib/chef/sugar/architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Architecture
#
def _64_bit?(node)
%w(amd64 x86_64 ppc64 ppc64le s390x ia64 sparc64 aarch64 arch64 arm64 sun4v sun4u)
.include?(node['kernel']['machine'])
.include?(node['kernel']['machine']) || ( node['kernel']['bits'] == '64' )
end

#
Expand Down Expand Up @@ -88,6 +88,16 @@ def ppc64le?(node)
%w(ppc64le)
.include?(node['kernel']['machine'])
end

#
# Determine if the current architecture is PowerPC
#
# @return [Boolean]
#
def powerpc?(node)
%w(powerpc)
.include?(node['kernel']['machine'])
end
end

module DSL
Expand All @@ -111,6 +121,9 @@ def ppc64?; Chef::Sugar::Architecture.ppc64?(node); end

# @see Chef::Sugar::Architecture#ppc64le?
def ppc64le?; Chef::Sugar::Architecture.ppc64le?(node); end

# @see Chef::Sugar::Architecture#powerpc?
def powerpc?; Chef::Sugar::Architecture.powerpc?(node); end
end
end
end
16 changes: 16 additions & 0 deletions spec/unit/chef/sugar/architecture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
end
end

it 'returns true when ohai provides the bittiness' do
node = { 'kernel' => { 'bits' => '64' } }
expect(described_class._64_bit?(node)).to be true
end

it 'returns false when ohai provides the bittiness' do
node = { 'kernel' => { 'bits' => '32' } }
expect(described_class._64_bit?(node)).to be false
end

it 'returns false when the system is not 64 bit' do
node = { 'kernel' => { 'machine' => 'i386' } }
expect(described_class._64_bit?(node)).to be false
Expand Down Expand Up @@ -62,6 +72,12 @@
end
end

describe '#powerpc?' do
it 'returns true when the system is IBM POWER or powerpc' do
node = { 'kernel' => { 'machine' => 'powerpc' } }
end
end

describe '#sparc?' do
it 'returns true when the system is SPARC sun4u' do
node = { 'kernel' => { 'machine' => 'sun4u' } }
Expand Down

0 comments on commit 18a862e

Please sign in to comment.