Skip to content

Commit 4119af2

Browse files
committed
Rubocop autocorrect
1 parent ac7f847 commit 4119af2

File tree

75 files changed

+1279
-1374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1279
-1374
lines changed

lib/facter/logical_volumes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Fact should be confined to only linux servers that have the lvs command
33
confine do
44
Facter.value('kernel') == 'Linux' &&
5-
Facter::Core::Execution.which('lvs')
5+
Facter::Core::Execution.which('lvs')
66
end
77

88
setcode do
@@ -29,4 +29,4 @@
2929
output = Facter::Core::Execution.exec("lvs -o #{columns.join(',')} --noheading --nosuffix")
3030
Puppet_X::LVM::Output.parse('lv_name', columns, output)
3131
end
32-
end
32+
end

lib/facter/lvm_support.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# lvm_support: true/nil
22
# Whether there is LVM support (based on the presence of the "vgs" command)
33
Facter.add('lvm_support') do
4-
confine :kernel => :linux
4+
confine kernel: :linux
55

66
setcode do
77
vgdisplay = Facter::Util::Resolution.which('vgs')
@@ -13,12 +13,12 @@
1313
# Number of VGs
1414
vg_list = []
1515
Facter.add('lvm_vgs') do
16-
confine :lvm_support => true
16+
confine lvm_support: true
1717

1818
if Facter.value(:lvm_support)
1919
vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30)
2020
end
21-
21+
2222
if vgs.nil?
2323
setcode { 0 }
2424
else
@@ -36,7 +36,7 @@
3636
pvs = Facter::Core::Execution.execute("vgs -o pv_name #{vg} 2>/dev/null", timeout: 30)
3737
res = nil
3838
unless pvs.nil?
39-
res = pvs.split("\n").select{|l| l =~ /^\s+\// }.collect(&:strip).sort.join(',')
39+
res = pvs.split("\n").select { |l| l =~ /^\s+\// }.map(&:strip).sort.join(',')
4040
end
4141
res
4242
end
@@ -47,7 +47,7 @@
4747
# Number of PVs
4848
pv_list = []
4949
Facter.add('lvm_pvs') do
50-
confine :lvm_support => true
50+
confine lvm_support: true
5151
if Facter.value(:lvm_support)
5252
pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30)
5353
end

lib/facter/physical_volumes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Fact should be confined to only linux servers that have the lvs command
33
confine do
44
Facter.value('kernel') == 'Linux' &&
5-
Facter::Core::Execution.which('pvs')
5+
Facter::Core::Execution.which('pvs')
66
end
77

88
setcode do

lib/facter/volume_groups.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Fact should be confined to only linux servers that have the lvs command
33
confine do
44
Facter.value('kernel') == 'Linux' &&
5-
Facter::Core::Execution.which('vgs')
5+
Facter::Core::Execution.which('vgs')
66
end
77

88
setcode do
@@ -25,4 +25,4 @@
2525
output = Facter::Core::Execution.exec("vgs -o #{columns.join(',')} --noheading --nosuffix")
2626
Puppet_X::LVM::Output.parse('vg_name', columns, output)
2727
end
28-
end
28+
end
Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
require 'open3'
22
Puppet::Type.type(:filesystem).provide :aix do
3+
desc 'Manages logical volume filesystems on AIX'
34

4-
desc "Manages logical volume filesystems on AIX"
5+
confine operatingsystem: :AIX
6+
defaultfor operatingsystem: :AIX
57

6-
confine :operatingsystem => :AIX
7-
defaultfor :operatingsystem => :AIX
8-
9-
commands :crfs => 'crfs',
10-
:chfs => 'chfs'
8+
commands crfs: 'crfs',
9+
chfs: 'chfs'
1110

1211
def exists?
1312
Open3.popen3("lsfs #{@resource[:name]}")[3].value.success?
@@ -16,7 +15,7 @@ def exists?
1615
def create
1716
args = []
1817

19-
attributes=[
18+
attributes = [
2019
:ag_size,
2120
:large_files,
2221
:compress,
@@ -33,7 +32,7 @@ def create
3332
:agblksize,
3433
:extended_attributes,
3534
:mount_options,
36-
:vix
35+
:vix,
3736
]
3837

3938
args.push(*add_attributes(*attributes))
@@ -52,37 +51,37 @@ def create
5251
# size property after creation
5352
if @resource[:size]
5453
if size != @resource[:size]
55-
self.size= (@resource[:size])
54+
self.size = (@resource[:size])
5655
end
5756
end
5857
end
5958

6059
def attribute_flag(pvalue)
6160
{
62-
:ag_size => 'ag',
63-
:large_file => 'bf',
64-
:initial_size => 'size',
65-
:size => 'size',
66-
:extended_attributes => 'ea',
67-
:mount_options => 'options',
68-
:encrypted => 'efs'
61+
ag_size: 'ag',
62+
large_file: 'bf',
63+
initial_size: 'size',
64+
size: 'size',
65+
extended_attributes: 'ea',
66+
mount_options: 'options',
67+
encrypted: 'efs',
6968
}[pvalue] || pvalue.to_s
7069
end
7170

7271
def add_attributes(*args)
73-
attr_args=[]
72+
attr_args = []
7473
args.each do |arg|
7574
if @resource[arg]
76-
ans=parse_boolean(@resource[arg])
75+
ans = parse_boolean(@resource[arg])
7776
attr_args.push('-a', "#{attribute_flag(arg)}=#{@resource[arg]}")
7877
end
7978
end
8079
attr_args
8180
end
8281

83-
def add_flag(flag,param)
82+
def add_flag(flag, param)
8483
if @resource[param]
85-
[ "-#{flag.to_s}", "#{parse_boolean(@resource[param])}" ]
84+
["-#{flag}", parse_boolean(@resource[param]).to_s]
8685
end
8786
end
8887

@@ -98,71 +97,71 @@ def parse_boolean(param)
9897
end
9998

10099
def size
101-
cursize=0
102-
reqsize=blk_roundup(val_to_blk(@resource[:size]))
100+
cursize = 0
101+
reqsize = blk_roundup(val_to_blk(@resource[:size]))
103102

104-
Open3.popen3("lsfs -q #{@resource[:name]}") do |stdin, stdout, stderr|
103+
Open3.popen3("lsfs -q #{@resource[:name]}") do |_stdin, stdout, _stderr|
105104
stdout.each do |line|
106-
elements=line.split(/\s+/)
105+
elements = line.split(%r{\s+})
107106
if elements[2] == @resource[:name]
108-
cursize=elements[4].to_i
107+
cursize = elements[4].to_i
109108
end
110109
end
111110
end
112111

113112
if cursize == reqsize
114113
@resource[:size]
115114
else
116-
blk_to_val(cursize,@resource[:size][-1,1])
115+
blk_to_val(cursize, @resource[:size][-1, 1])
117116
end
118117
end
119118

120-
def size=(newsize)
121-
chfs('-a',"size=#{@resource[:size]}", @resource[:name])
119+
def size=(_newsize)
120+
chfs('-a', "size=#{@resource[:size]}", @resource[:name])
122121
end
123122

124123
def val_to_blk(val)
125-
input = val.match(/(\d+)([^0-9]|)/).to_a
124+
input = val.match(%r{(\d+)([^0-9]|)}).to_a
126125
case input[2]
127126
when 'M'
128-
input[1].to_i*1024*2
127+
input[1].to_i * 1024 * 2
129128
when 'G'
130-
input[1].to_i*1024*1024*2
129+
input[1].to_i * 1024 * 1024 * 2
131130
else
132131
input[1].to_i
133132
end
134133
end
135134

136-
def blk_to_val(blocks,units=nil)
135+
def blk_to_val(blocks, units = nil)
137136
case units
138137
when 'M'
139-
sprintf('%gM', Float(blocks.to_i/2/1024))
138+
'%gM' % Float(blocks.to_i / 2 / 1024)
140139
when 'G'
141-
sprintf('%gG', Float(blocks.to_i/2/1024/1024))
140+
'%gG' % Float(blocks.to_i / 2 / 1024 / 1024)
142141
else
143142
blocks
144143
end
145144
end
146145

147146
def blk_roundup(blocks)
148-
ppsize=Integer(pp_size*1024*2)
149-
ppsize*Float(Float(blocks)/ppsize).ceil.to_i
147+
ppsize = Integer(pp_size * 1024 * 2)
148+
ppsize * Float(Float(blocks) / ppsize).ceil.to_i
150149
end
151150

152151
def pp_size
153152
vg = @resource[:volume_group] || 'rootvg'
154-
Open3.capture2("lsvg #{vg} | /bin/grep 'PP SIZE'")[0].split(/\s+/)[5].to_i
153+
Open3.capture2("lsvg #{vg} | /bin/grep 'PP SIZE'")[0].split(%r{\s+})[5].to_i
155154
end
156155

157156
def attribute_flag(pvalue)
158157
{
159-
:ag_size => 'ag',
160-
:large_file => 'bf',
161-
:initial_size => 'size',
162-
:size => 'size',
163-
:extended_attributes => 'ea',
164-
:mount_options => 'options',
165-
:encrypted => 'efs'
158+
ag_size: 'ag',
159+
large_file: 'bf',
160+
initial_size: 'size',
161+
size: 'size',
162+
extended_attributes: 'ea',
163+
mount_options: 'options',
164+
encrypted: 'efs',
166165
}[pvalue] || pvalue.to_s
167166
end
168167
end
Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
11
Puppet::Type.type(:filesystem).provide :lvm do
2-
desc "Manages filesystem of a logical volume on Linux"
2+
desc 'Manages filesystem of a logical volume on Linux'
33

4-
confine :kernel => :linux
4+
confine kernel: :linux
55

6-
commands :blkid => 'blkid'
6+
commands blkid: 'blkid'
77

8-
def create
9-
mkfs(@resource[:fs_type], @resource[:name])
10-
end
8+
def create
9+
mkfs(@resource[:fs_type], @resource[:name])
10+
end
1111

12-
def exists?
13-
fstype == @resource[:fs_type]
14-
end
12+
def exists?
13+
fstype == @resource[:fs_type]
14+
end
1515

16-
def destroy
17-
# no-op
18-
end
16+
def destroy
17+
# no-op
18+
end
19+
20+
def fstype
21+
%r{\bTYPE=\"(\S+)\"}.match(blkid(@resource[:name]))[1]
22+
rescue Puppet::ExecutionFailure
23+
nil
24+
end
1925

20-
def fstype
21-
/\bTYPE=\"(\S+)\"/.match(blkid(@resource[:name]))[1]
22-
rescue Puppet::ExecutionFailure
23-
nil
26+
def mkfs(fs_type, name)
27+
mkfs_params = { 'reiserfs' => '-q', 'xfs' => '-f' }
28+
29+
mkfs_cmd = !@resource[:mkfs_cmd].nil? ?
30+
[@resource[:mkfs_cmd]] :
31+
case fs_type
32+
when 'swap'
33+
['mkswap']
34+
else
35+
["mkfs.#{fs_type}"]
36+
end
37+
38+
mkfs_cmd << name
39+
40+
if mkfs_params[fs_type]
41+
mkfs_cmd << mkfs_params[fs_type]
2442
end
2543

26-
def mkfs(fs_type, name)
27-
mkfs_params = { "reiserfs" => "-q" , "xfs" => "-f" }
28-
29-
mkfs_cmd = @resource[:mkfs_cmd] != nil ?
30-
[@resource[:mkfs_cmd]] :
31-
case fs_type
32-
when 'swap'
33-
["mkswap"]
34-
else
35-
["mkfs.#{fs_type}"]
36-
end
37-
38-
mkfs_cmd << name
39-
40-
if mkfs_params[fs_type]
41-
mkfs_cmd << mkfs_params[fs_type]
42-
end
43-
44-
if resource[:options]
45-
mkfs_options = Array.new(resource[:options].split)
46-
mkfs_cmd << mkfs_options
47-
end
48-
49-
execute mkfs_cmd
50-
if fs_type == 'swap'
51-
swap_cmd = ["swapon"]
52-
swap_cmd << name
53-
execute swap_cmd
54-
end
44+
if resource[:options]
45+
mkfs_options = Array.new(resource[:options].split)
46+
mkfs_cmd << mkfs_options
5547
end
5648

49+
execute mkfs_cmd
50+
if fs_type == 'swap'
51+
swap_cmd = ['swapon']
52+
swap_cmd << name
53+
execute swap_cmd
54+
end
55+
end
5756
end

0 commit comments

Comments
 (0)