Skip to content

Commit ef7f9d1

Browse files
committed
(MODULES-11011) extend vg facts
Adds facts for the extends in the volume groups (size, count, free extends) Also sets the units to megabytes (of 1024k) Otherwise the --nosuffix option was not used, and we could get results like '<54,24g' Ref: MODULES-11011
1 parent cada6d4 commit ef7f9d1

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

lib/facter/volume_groups.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
'vg_allocation_policy',
2121
'vg_size',
2222
'vg_free',
23+
'vg_extent_size',
24+
'vg_extent_count',
25+
'vg_free_count',
2326
]
2427

25-
output = Facter::Core::Execution.exec("vgs -o #{columns.join(',')} --noheading --nosuffix")
28+
output = Facter::Core::Execution.exec("vgs -o #{columns.join(',')} --noheading --nosuffix --units m")
2629
Puppet_X::LVM::Output.parse('vg_name', columns, output)
2730
end
2831
end

spec/unit/facter/volume_groups_spec.rb

+27-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
context 'when not on Linux' do
99
it 'is set to nil' do
1010
Facter.fact(:kernel).expects(:value).at_least(1).returns('SunOs')
11-
Facter.value(:volume_groups).should be_nil
11+
expect(Facter.value(:volume_groups)).to be_nil
1212
end
1313
end
1414

@@ -24,7 +24,7 @@
2424
end
2525

2626
it 'is set to nil' do
27-
Facter.value(:volume_groups).should be_nil
27+
expect(Facter.value(:volume_groups)).to be_nil
2828
end
2929
end
3030

@@ -36,26 +36,34 @@
3636

3737
it 'is able to resolve vgs' do
3838
vgs_output = <<-OUTPUT
39-
ZcFkEG-217a-nnc6-PvWx-oXou-7THt-XR6eci centos wz--n- writeable normal 19.51g 44.00m
40-
tMqdQC-ukEx-bEft-bLk8-WoM1-jX0a-0p1rri tasks wz--n- writeable normal 3.99g 2.82g
39+
ZcFkEG-217a-nnc6-PvWx-oXou-7THt-XR6eci centos wz--n- writeable normal 953864,00 126472,00 4,00 238466 31618
40+
tMqdQC-ukEx-bEft-bLk8-WoM1-jX0a-0p1rri tasks wz--n- writeable normal 55540,00 6388,00 4,00 13885 1597
4141
OUTPUT
4242
vgs_output.lstrip!
4343
Facter::Core::Execution.expects(:exec).at_least(1).returns(vgs_output)
44-
Facter.value(:volume_groups).should include('centos' => {
45-
'uuid' => 'ZcFkEG-217a-nnc6-PvWx-oXou-7THt-XR6eci',
46-
'attr' => 'wz--n-', 'permissions' => 'writeable',
47-
'allocation_policy' => 'normal',
48-
'size' => '19.51g',
49-
'free' => '44.00m'
50-
},
51-
'tasks' => {
52-
'uuid' => 'tMqdQC-ukEx-bEft-bLk8-WoM1-jX0a-0p1rri',
53-
'attr' => 'wz--n-',
54-
'permissions' => 'writeable',
55-
'allocation_policy' => 'normal',
56-
'size' => '3.99g',
57-
'free' => '2.82g',
58-
})
44+
expect(Facter.value(:volume_groups)).to include(
45+
'centos' => {
46+
'uuid' => 'ZcFkEG-217a-nnc6-PvWx-oXou-7THt-XR6eci',
47+
'attr' => 'wz--n-', 'permissions' => 'writeable',
48+
'allocation_policy' => 'normal',
49+
'size' => '953864,00',
50+
'free' => '126472,00',
51+
'extent_size' => '4,00',
52+
'extent_count' => '238466',
53+
'free_count' => '31618'
54+
},
55+
'tasks' => {
56+
'uuid' => 'tMqdQC-ukEx-bEft-bLk8-WoM1-jX0a-0p1rri',
57+
'attr' => 'wz--n-',
58+
'permissions' => 'writeable',
59+
'allocation_policy' => 'normal',
60+
'size' => '55540,00',
61+
'free' => '6388,00',
62+
'extent_size' => '4,00',
63+
'extent_count' => '13885',
64+
'free_count' => '1597',
65+
},
66+
)
5967
end
6068
end
6169
end

0 commit comments

Comments
 (0)