Skip to content

Commit

Permalink
(FACT-3094) Aix mountpoint resolver couldn't resolve nfs
Browse files Browse the repository at this point in the history
This commit fixes NFS mounts being resolved incorrectly by facter. This
happened because the node from where the remote directory is mounted
would be under the `node` header of the mount output. To fix this, we
shift the array by removing the first element, so that every other
column falls into place
  • Loading branch information
BobosilaVictor committed Nov 15, 2021
1 parent f1c3411 commit 6c6ef2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/facter/resolvers/aix/mountpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ def read_mount(fact_name)

def add_mount_points_fact(line)
elem = line.split("\s")

elem.shift unless line[0] == ' '

@fact_list[:mountpoints][elem[1]] = { device: elem[0], filesystem: elem[2],
options: elem.last.split(',') }
options: elem.last.include?(':') ? [] : elem.last.split(',') }
end

def retrieve_sizes_for_mounts
Expand Down
5 changes: 4 additions & 1 deletion spec/facter/resolvers/aix/mountpoints_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
used: '2.16 GiB', used_bytes: 2_319_687_680 },
'/var' => { available: '205.06 MiB', available_bytes: 215_023_616, capacity: '0.76%', device: '/dev/hd3',
filesystem: 'x', options: ['rw', 'nodev', 'log=/dev/hd3'], size: '206.64 MiB',
size_bytes: 216_678_912, used: '1.58 MiB', used_bytes: 1_655_296 } }
size_bytes: 216_678_912, used: '1.58 MiB', used_bytes: 1_655_296 },
'/tmp/salam' => { available: '63.57 GiB', available_bytes: 68_253_413_376, capacity: '7.20%',
device: '/var/share', filesystem: 'nfs3', options: [], size: '68.50 GiB',
size_bytes: 73_549_217_792, used: '4.93 GiB', used_bytes: 5_295_804_416 } }
end
let(:log_spy) { instance_spy(Facter::Log) }

Expand Down
3 changes: 2 additions & 1 deletion spec/fixtures/df
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Filesystem 512-blocks Used Available Capacity Mounted on
/dev/hd4 4194304 780504 3413800 19% /
/dev/hd2 10485760 4530640 5955120 44% /usr
/dev/hd3 423201 3233 419968 1% /var
/proc - - - - /proc
/proc - - - - /proc
joe:/var/share 143650816 10343368 133307448 8% /tmp/salam
1 change: 1 addition & 0 deletions spec/fixtures/mount
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/proc /proc procfs Mar 22 08:05 rw
/dev/hd10opt /opt jfs2 Mar 22 08:05 rw,log=/dev/hd8
/dev/hd3 /var x Mar 22 08:05 rw,nodev,log=/dev/hd3
joe /var/share /tmp/salam nfs3 Nov 12 04:40

0 comments on commit 6c6ef2d

Please sign in to comment.