Skip to content

Commit 22ba15e

Browse files
Merge pull request #279 from bmlit/yes_arg
Add yes argument when creating/extending a LV
2 parents c437d99 + 72da9f1 commit 22ba15e

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

.rubocop_todo.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ Lint/Void:
4141
# Offense count: 10
4242
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
4343
Metrics/AbcSize:
44-
Max: 83
44+
Max: 85
4545

4646
# Offense count: 11
4747
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
4848
# AllowedMethods: refine
4949
Metrics/BlockLength:
50-
Max: 199
50+
Max: 256
5151

5252
# Offense count: 4
5353
# Configuration parameters: AllowedMethods, AllowedPatterns.
5454
Metrics/CyclomaticComplexity:
55-
Max: 30
55+
Max: 32
5656

5757
# Offense count: 13
5858
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
5959
Metrics/MethodLength:
60-
Max: 44
60+
Max: 50
6161

6262
# Offense count: 1
6363
# Configuration parameters: Max, CountKeywordArgs.
@@ -67,7 +67,7 @@ Metrics/ParameterLists:
6767
# Offense count: 4
6868
# Configuration parameters: AllowedMethods, AllowedPatterns.
6969
Metrics/PerceivedComplexity:
70-
Max: 33
70+
Max: 35
7171

7272
# Offense count: 3
7373
Naming/AccessorMethodName:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ resources out yourself.
201201
* stripesize (Parameter) - The stripesize to use for the new logical volume.
202202
* thinpool (Parameter) - Default value: `false` - Set to true to create a thin pool or to pool name to create thin volume
203203
* volume_group (Parameter) - The volume group name associated with this logical volume. This will automatically set this volume group as a dependency, but it must be defined elsewhere using the volume_group resource type.
204+
* yes_flag (Parameter) - Default value: `false` - If set to true, do not prompt for confirmation interactively but always assume the answer yes.
204205

205206
### physical_volume
206207

lib/puppet/provider/logical_volume/lvm.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def create
118118
else
119119
args << @resource[:volume_group]
120120
end
121+
122+
args.push('--yes') if @resource[:yes_flag]
121123
lvcreate(*args)
122124
end
123125

@@ -183,7 +185,10 @@ def size=(new_size)
183185
end
184186

185187
if resizeable
186-
lvextend('-L', new_size, path) || raise("Cannot extend to size #{new_size} because lvextend failed.")
188+
args = []
189+
args.push('--yes') if @resource[:yes_flag]
190+
191+
lvextend('-L', new_size, path, *args) || raise("Cannot extend to size #{new_size} because lvextend failed.")
187192

188193
unless @resource[:resize_fs] == :false || @resource[:resize_fs] == false || @resource[:resize_fs] == 'false'
189194
begin

lib/puppet/type/logical_volume.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ def insync?(is)
180180
end
181181
end
182182

183+
newparam(:yes_flag) do
184+
desc 'If set to true, do not prompt for confirmation interactively but always assume the answer yes.'
185+
defaultto false
186+
end
187+
183188
autorequire(:volume_group) do
184189
@parameters[:volume_group].value
185190
end

manifests/logical_volume.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
# :inherit
5050
# :normal
5151

52+
# @param yes_flag If set to true, do not prompt for confirmation interactively but always assume the answer yes.
53+
5254
#
5355
define lvm::logical_volume (
5456
String[1] $volume_group,
@@ -78,6 +80,7 @@
7880
Optional[Boolean] $no_sync = undef,
7981
Optional[Variant[String[1], Integer]] $region_size = undef,
8082
Optional[Enum['anywhere', 'contiguous', 'cling', 'inherit', 'normal']] $alloc = undef,
83+
Boolean $yes_flag = false,
8184
) {
8285
$lvm_device_path = "/dev/${volume_group}/${name}"
8386

@@ -139,6 +142,7 @@
139142
no_sync => $no_sync,
140143
region_size => $region_size,
141144
alloc => $alloc,
145+
yes_flag => $yes_flag,
142146
}
143147

144148
if $createfs {

tasks/ensure_lv.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
"region_size": {
8181
"description": "A mirror is divided into regions of this size (in MB), the mirror log uses this granularity to track which regions are in sync. CAN NOT BE CHANGED on already mirrored volume. Take your mirror size in terabytes and round up that number to the next power of 2, using that number as the -R argument.",
8282
"type": "Optional[Integer]"
83-
}
83+
},
84+
"yes_flag": {
85+
"description": "If set to true, do not prompt for confirmation interactively but always assume the answer yes.",
86+
"type": "Boolean"
87+
}
8488
}
85-
}
89+
}

tasks/ensure_lv.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
logical_volume[:alloc] = params['alloc'] if params['alloc']
5151
logical_volume[:no_sync] = params['no_sync'] if params['no_sync']
5252
logical_volume[:region_size] = params['region_size'] if params['region_size']
53+
logical_volume[:yes_flag] = params['yes_flag'] if params['yes_flag']
5354

5455
# Save the result
5556
_resource, report = Puppet::Resource.indirection.save(logical_volume)

0 commit comments

Comments
 (0)