@@ -71,68 +71,42 @@ def create
7171 args . push ( '-n' , @resource [ :name ] ) unless @resource [ :thinpool ] == true
7272
7373 size_option = '--size'
74- if @resource [ :thinpool ] . is_a? String
75- size_option = '--virtualsize'
76- end
74+ size_option = '--virtualsize' if @resource [ :thinpool ] . is_a? String
7775
7876 if @resource [ :size ]
7977 args . push ( size_option , @resource [ :size ] )
8078 elsif @resource [ :initial_size ]
8179 args . push ( size_option , @resource [ :initial_size ] )
8280 end
83- if @resource [ :extents ]
84- args . push ( '--extents' , @resource [ :extents ] )
85- end
81+ args . push ( '--extents' , @resource [ :extents ] ) if @resource [ :extents ]
8682
87- if !@resource [ :extents ] && !@resource [ :size ] && !@resource [ :initial_size ]
88- args . push ( '--extents' , '100%FREE' )
89- end
83+ args . push ( '--extents' , '100%FREE' ) if !@resource [ :extents ] && !@resource [ :size ] && !@resource [ :initial_size ]
9084
91- if @resource [ :stripes ]
92- args . push ( '--stripes' , @resource [ :stripes ] )
93- end
85+ args . push ( '--stripes' , @resource [ :stripes ] ) if @resource [ :stripes ]
9486
95- if @resource [ :stripesize ]
96- args . push ( '--stripesize' , @resource [ :stripesize ] )
97- end
87+ args . push ( '--stripesize' , @resource [ :stripesize ] ) if @resource [ :stripesize ]
9888
99- if @resource [ :poolmetadatasize ]
100- args . push ( '--poolmetadatasize' , @resource [ :poolmetadatasize ] )
101- end
89+ args . push ( '--poolmetadatasize' , @resource [ :poolmetadatasize ] ) if @resource [ :poolmetadatasize ]
10290
10391 if @resource [ :mirror ]
10492 args . push ( '--mirrors' , @resource [ :mirror ] )
105- if @resource [ :mirrorlog ]
106- args . push ( '--mirrorlog' , @resource [ :mirrorlog ] )
107- end
108- if @resource [ :region_size ]
109- args . push ( '--regionsize' , @resource [ :region_size ] )
110- end
111- if @resource [ :no_sync ]
112- args . push ( '--nosync' )
113- end
93+ args . push ( '--mirrorlog' , @resource [ :mirrorlog ] ) if @resource [ :mirrorlog ]
94+ args . push ( '--regionsize' , @resource [ :region_size ] ) if @resource [ :region_size ]
95+ args . push ( '--nosync' ) if @resource [ :no_sync ]
11496 end
11597
116- if @resource [ :alloc ]
117- args . push ( '--alloc' , @resource [ :alloc ] )
118- end
98+ args . push ( '--alloc' , @resource [ :alloc ] ) if @resource [ :alloc ]
11999
120- if @resource [ :readahead ]
121- args . push ( '--readahead' , @resource [ :readahead ] )
122- end
100+ args . push ( '--readahead' , @resource [ :readahead ] ) if @resource [ :readahead ]
123101
124102 if @resource [ :persistent ]
125103 # if persistent param is true, set arg to "y", otherwise set to "n"
126104 args . push ( '--persistent' , [ :true , true , 'true' ] . include? ( @resource [ :persistent ] ) ? 'y' : 'n' )
127105 end
128106
129- if @resource [ :minor ]
130- args . push ( '--minor' , @resource [ :minor ] )
131- end
107+ args . push ( '--minor' , @resource [ :minor ] ) if @resource [ :minor ]
132108
133- if @resource [ :type ]
134- args . push ( '--type' , @resource [ :type ] )
135- end
109+ args . push ( '--type' , @resource [ :type ] ) if @resource [ :type ]
136110
137111 if @resource [ :thinpool ]
138112 args . push ( '--thin' )
@@ -149,9 +123,7 @@ def create
149123
150124 def destroy
151125 name_escaped = "#{ @resource [ :volume_group ] . gsub ( '-' , '--' ) } -#{ @resource [ :name ] . gsub ( '-' , '--' ) } "
152- if %r{\b TYPE="(swap)"} . match? ( blkid ( path ) )
153- swapoff ( path )
154- end
126+ swapoff ( path ) if %r{\b TYPE="(swap)"} . match? ( blkid ( path ) )
155127 dmsetup ( 'remove' , name_escaped )
156128 lvremove ( '-f' , path )
157129 end
@@ -199,21 +171,15 @@ def size=(new_size)
199171 end
200172
201173 ## Get the extend size
202- if lvs ( '--noheading' , '-o' , 'vg_extent_size' , '--units' , 'k' , path ) =~ %r{\s +(\d +)\. \d +k}i
203- vg_extent_size = Regexp . last_match ( 1 ) . to_i
204- end
174+ vg_extent_size = Regexp . last_match ( 1 ) . to_i if lvs ( '--noheading' , '-o' , 'vg_extent_size' , '--units' , 'k' , path ) =~ %r{\s +(\d +)\. \d +k}i
205175
206176 ## Verify that it's a extension: Reduce is potentially dangerous and should be done manually
207177 if lvm_size_units [ current_size_unit ] < lvm_size_units [ new_size_unit ]
208178 resizeable = true
209179 elsif lvm_size_units [ current_size_unit ] > lvm_size_units [ new_size_unit ]
210- if ( current_size_bytes * lvm_size_units [ current_size_unit ] ) < ( new_size_bytes * lvm_size_units [ new_size_unit ] )
211- resizeable = true
212- end
180+ resizeable = true if ( current_size_bytes * lvm_size_units [ current_size_unit ] ) < ( new_size_bytes * lvm_size_units [ new_size_unit ] )
213181 elsif lvm_size_units [ current_size_unit ] == lvm_size_units [ new_size_unit ]
214- if new_size_bytes > current_size_bytes
215- resizeable = true
216- end
182+ resizeable = true if new_size_bytes > current_size_bytes
217183 end
218184
219185 if resizeable
@@ -236,9 +202,7 @@ def size=(new_size)
236202 end
237203 rescue Puppet ::ExecutionFailure => e
238204 ## If blkid returned 2, there is no filesystem present or the file doesn't exist. This should not be a failure.
239- if e . message . include? ( ' returned 2:' ) # rubocop:disable Metrics/BlockNesting
240- Puppet . debug ( e . message )
241- end
205+ Puppet . debug ( e . message ) if e . message . include? ( ' returned 2:' ) # rubocop:disable Metrics/BlockNesting
242206 end
243207 end
244208
@@ -271,15 +235,11 @@ def mirror=(new_mirror_count)
271235
272236 puts "Change mirror from #{ current_mirrors } to #{ new_mirror_count } ..."
273237 args = [ '-m' , new_mirror_count ]
274- if @resource [ :mirrorlog ]
275- args . push ( '--mirrorlog' , @resource [ :mirrorlog ] )
276- end
238+ args . push ( '--mirrorlog' , @resource [ :mirrorlog ] ) if @resource [ :mirrorlog ]
277239
278240 # Region size cannot be changed on an existing mirror (not even when changing to zero mirrors).
279241
280- if @resource [ :alloc ]
281- args . push ( '--alloc' , @resource [ :alloc ] )
282- end
242+ args . push ( '--alloc' , @resource [ :alloc ] ) if @resource [ :alloc ]
283243 args . push ( path )
284244 lvconvert ( *args )
285245 end
@@ -310,9 +270,7 @@ def mirrorlog=(new_mirror_log_location)
310270
311271 # puts "Change mirror log location to #{new_mirror_log_location}..."
312272 args = [ '--mirrorlog' , new_mirror_log_location ]
313- if @resource [ :alloc ]
314- args . push ( '--alloc' , @resource [ :alloc ] )
315- end
273+ args . push ( '--alloc' , @resource [ :alloc ] ) if @resource [ :alloc ]
316274 args . push ( path )
317275 lvconvert ( *args )
318276 end
0 commit comments