Skip to content

Commit b65f9c3

Browse files
author
Wang, Peter USD - DVT/SYSTEM TES
committed
[GH-3]Allow pool expansion if raid_groups changes (#5)
if you change the disk_num or add new raid groups, the pool will be expanded as configured.
1 parent ae1dcd7 commit b65f9c3

File tree

5 files changed

+180
-36
lines changed

5 files changed

+180
-36
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ configure and deploy the Unity via Puppet code.
3737
* Ruby `1.9` or greater
3838
* rubypython `0.6.4` or greater (The bridge between Ruby and Python)
3939
* Python `2.7`.
40-
* Storops, 0.4.15 or greater (Python storage management library for Unity and VNX.)
40+
* Storops, 0.5.1 or greater (Python storage management library for Unity and VNX.)
4141

4242

4343
- [rubypython](https://rubygems.org/gems/rubypython) is a bridge between the Ruby and
@@ -206,7 +206,7 @@ Please refer to the example file here: [example_multiple_systems](examples/examp
206206

207207
* `unity_system`: Define a Unity system.
208208
* `unity_license`: Upload a license to a defined Unity system.
209-
* `unity_pool`: Create, destroy a storage pool.
209+
* `unity_pool`: Create, modify, expand or destroy a storage pool.
210210
* `unity_iscsi_portal`: Create, update, or destroy a iSCSI portal. Applicable for both IPv4 and IPv6.
211211
* `unity_host`: Create, update, or destroy a Unity host.
212212
* `unity_io_limit_policy`: Create, update, or destroy a Unity IO limit policy.
@@ -346,6 +346,8 @@ Valid values are:
346346

347347
* `disk_num`: Number of disks.
348348

349+
For pool expansion, user can either increase the `disk_num` or add new raid group in `raid_groups`.
350+
349351
##### `alert_threshold`
350352

351353

@@ -405,6 +407,13 @@ Optional
405407

406408
Create traditional/dynamic pool
407409

410+
Valid values are:
411+
412+
| Value | Description |
413+
|---------|-------------------|
414+
| `1` | traditional pool |
415+
| `2` | dynamic pool |
416+
408417

409418
#### Type: `unity_iscsi_portal`
410419

@@ -649,6 +658,8 @@ peter.wang13 at emc.com
649658

650659
## Release Notes
651660

652-
0.1.0 - Initial release.
653-
0.1.1 - Add license differential uploading.
654-
- Pool expansion if new raid groups are added.
661+
- 0.1.0
662+
* Initial release.
663+
- 0.1.1
664+
* Add license differential uploading.
665+
* Pool expansion if new raid groups are added.

examples/example_pool.pp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
unity_system { 'FNM00150600267':
2-
ip => '10.245.101.35',
2+
ip => '10.245.101.39',
33
user => 'admin',
44
password => 'Password123!',
55
}
@@ -16,10 +16,36 @@
1616
disk_num => 5,
1717
}],
1818
alert_threshold => 80,
19-
is_snap_harvest_enabled => true,
19+
is_snap_harvest_enabled => false,
20+
snap_harvest_high_threshold => 24.0,
2021
is_harvest_enabled => true,
21-
ensure => present,
22+
pool_type => 2,
23+
ensure => absent,
2224
}
2325

26+
# uncomment the following manifest for a pool expansion
27+
28+
# unity_pool { 'puppet_pool':
29+
# unity_system => Unity_system['FNM00150600267'],
30+
# description => 'created by puppet module',
31+
# raid_groups => [{
32+
# disk_group => 'dg_15',
33+
# raid_type => 1,
34+
# stripe_width => 0,
35+
# disk_num => 5,
36+
# }, {
37+
# disk_group => 'dg_8',
38+
# raid_type => 7,
39+
# stripe_width => 0,
40+
# disk_num => 4,
41+
# }],
42+
# alert_threshold => 80,
43+
# is_snap_harvest_enabled => true,
44+
# snap_harvest_high_threshold => 25.0,
45+
# is_harvest_enabled => true,
46+
# pool_type => 2,
47+
# ensure => present,
48+
# }
49+
2450

2551

lib/puppet/provider/unity_pool/pool_provider.rb

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
Puppet::Type.type(:unity_pool).provide(:pool_provider) do
2020
@doc = 'Manage Unity system related information.'
2121

22+
mk_resource_methods
23+
24+
def initialize(*args)
25+
super *args
26+
# Define an instance variable that hold values to be synchronized.
27+
@property_flush = {}
28+
end
29+
2230
def create
2331
Puppet.info "Creating pool #{@resource[:name]} with raid #{@resource[:raid_groups]}."
2432
unity = get_unity_system(resource[:unity_system])
@@ -36,6 +44,8 @@ def create
3644
is_fast_cache_enabled: @resource[:is_fast_cache_enabled],
3745
is_fastvp_enabled: @resource[:is_fastvp_enabled],
3846
pool_type: @resource[:pool_type])
47+
@property_hash[:ensure] = :present
48+
3949
end
4050

4151
def destroy
@@ -48,6 +58,7 @@ def destroy
4858
pool = nil
4959
end
5060
pool.delete
61+
@property_hash[:ensure] = :absent
5162
end
5263

5364
def exists?
@@ -65,5 +76,101 @@ def exists?
6576
end
6677
true
6778
end
79+
80+
def flush
81+
Puppet.info 'Flushing pool info.'
82+
return if @property_hash[:ensure] == :absent
83+
84+
diff = {}
85+
86+
pool = pool_get
87+
@property_hash = pool_property pool
88+
89+
@property_hash.each do |key, value|
90+
91+
if @resource[key].nil?
92+
next
93+
end
94+
95+
# Compare whether contains new disks/disk groups
96+
if key == :raid_groups
97+
add_rgs= []
98+
@resource[key].each do |raid_group|
99+
# If disk_num increases, add to diff
100+
dg_name = raid_group['disk_group']
101+
if value.has_key? dg_name
102+
if value[dg_name] < raid_group['disk_num']
103+
Puppet.info "User increases the disk number to #{raid_group['disk_num']} for pool #{pool.id}"
104+
add_rg = {}
105+
add_rg['disk_group'] = dg_name
106+
add_rg['raid_type'] = raid_group['raid_type']
107+
add_rg['disk_num'] = -(value[dg_name] - raid_group['disk_num'])
108+
add_rg['stripe_width'] = raid_group['stripe_width']
109+
Puppet.info "Adding new disks from #{add_rg} to pool #{pool.id}."
110+
111+
add_rgs << add_rg
112+
elsif value[dg_name] > raid_group['disk_num']
113+
Puppet.warning "Cannot shrink the pool, did you decrease disk num for disk_group #{dg_name} occasionally?"
114+
end
115+
else
116+
Puppet.info "Adding new raid group #{raid_group} to pool #{pool.id}."
117+
add_rgs << raid_group
118+
end
119+
end
120+
unless add_rgs.empty?
121+
add_rgs = get_raid_group_parameters(add_rgs)
122+
diff[key] = add_rgs
123+
end
124+
next
125+
end # End of if key == :raid_groups
126+
unless value == @resource[key]
127+
diff[key] = @resource[key]
128+
end
129+
end
130+
unless diff.empty?
131+
Puppet.info "Modifying the pool properties with change #{diff}"
132+
pool.modify!(diff)
133+
end
134+
end
135+
136+
137+
def pool_get
138+
unity = get_unity_system(@resource[:unity_system])
139+
unity.get_pool!(name: @resource[:name])
140+
end
141+
142+
def pool_property pool
143+
if pool.nil?
144+
pool = pool_get
145+
end
146+
curr = {}
147+
148+
curr[:description] = pool.description
149+
dgs = {}
150+
# We only care whether user add add new disk groups
151+
# or new disks in existing disk group.
152+
disk_groups = pool.disk_groups
153+
disk_groups.to_enum.each do |dg_name|
154+
dgs[dg_name.to_s] = disk_groups[dg_name.to_s].__len__
155+
end
156+
curr[:raid_groups] = dgs
157+
158+
curr[:alert_threshold] = pool.alert_threshold
159+
curr[:is_harvest_enabled] = pool.is_harvest_enabled
160+
curr[:is_snap_harvest_enabled] = pool.is_snap_harvest_enabled
161+
curr[:pool_harvest_high_threshold] = pool.pool_space_harvest_high_threshold
162+
curr[:pool_harvest_low_threshold] = pool.pool_space_harvest_low_threshold
163+
curr[:snap_harvest_high_threshold] = pool.snap_space_harvest_high_threshold
164+
curr[:snap_harvest_low_threshold] = pool.snap_space_harvest_low_threshold
165+
curr[:is_fast_cache_enabled] = pool.is_fast_cache_enabled
166+
if pool.pool_fast_vp.nil?
167+
curr[:is_fastvp_enabled] = false
168+
else
169+
curr[:is_fastvp_enabled] = pool.pool_fast_vp.is_schedule_enabled
170+
171+
end
172+
Puppet.info "Pool properties: #{curr}."
173+
curr
174+
end
68175
end
69176

lib/puppet/type/unity_pool.rb

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,70 @@
2424
end
2525

2626

27-
newparam(:description) do
27+
newproperty(:description) do
2828
desc 'Storage pool description.'
2929
defaultto do
3030
'Created by puppet.'
3131
end
3232
end
3333

34-
newparam(:raid_groups) do
34+
newproperty(:raid_groups, :array_matching => :all) do
3535
desc 'Raid groups to be included in the storage pool.'
3636

37-
validate do |value|
38-
value.each do |raid_group|
39-
Puppet.info(raid_group)
40-
if raid_group['disk_group'] == nil
41-
raise(Puppet::Error, 'disk_group could not be empty, please specify a disk group id.')
42-
end
43-
if raid_group['raid_type'] == nil
44-
Puppet.info('raid_type is not specified, using Automatic')
45-
raid_group['raid_type'] = 'Automatic'
46-
end
47-
if raid_group['disk_num'] == nil
48-
raise(Puppet::Error, 'disk_num cannot not be empty, please specify an integer.')
49-
end
50-
if raid_group['stripe_width'] == nil
51-
Puppet.info('stripe_width is not specified, using BestFit.')
52-
raid_group['stripe_width'] = 0
53-
end
37+
validate do |raid_group|
38+
# value.each do |raid_group|
39+
if raid_group['disk_group'] == nil
40+
raise(Puppet::Error, 'disk_group could not be empty, please specify a disk group id.')
5441
end
42+
if raid_group['raid_type'] == nil
43+
Puppet.info('raid_type is not specified, using Automatic')
44+
raid_group['raid_type'] = 'Automatic'
45+
end
46+
if raid_group['disk_num'] == nil
47+
raise(Puppet::Error, 'disk_num cannot not be empty, please specify an integer.')
48+
end
49+
if raid_group['stripe_width'] == nil
50+
Puppet.info('stripe_width is not specified, using BestFit.')
51+
raid_group['stripe_width'] = 0
52+
end
53+
# end
5554
end
5655
end
5756

58-
newparam(:alert_threshold) do
57+
newproperty(:alert_threshold) do
5958
desc 'Threshold at which the system will generate alerts about the free space in the pool, specified as a percentage'
6059

6160
end
62-
newparam(:is_harvest_enabled) do
61+
newproperty(:is_harvest_enabled) do
6362
desc 'Enable/disable pool harvesting.'
6463

6564
end
66-
newparam(:is_snap_harvest_enabled) do
65+
newproperty(:is_snap_harvest_enabled) do
6766
desc 'Enable/disable pool snapshot harvesting.'
6867

6968
end
70-
newparam(:pool_harvest_high_threshold) do
69+
newproperty(:pool_harvest_high_threshold) do
7170
desc 'Pool used space high threshold at which the system will automatically starts to delete snapshots in the pool'
7271

7372
end
74-
newparam(:pool_harvest_low_threshold) do
73+
newproperty(:pool_harvest_low_threshold) do
7574
desc 'Pool used space low threshold under which the system will automatically stop deletion of snapshots in the pool'
7675

7776
end
78-
newparam(:snap_harvest_high_threshold) do
77+
newproperty(:snap_harvest_high_threshold) do
7978
desc 'Snapshot used space high threshold at which the system automatically starts to delete snapshots in the pool'
8079

8180
end
82-
newparam(:snap_harvest_low_threshold) do
81+
newproperty(:snap_harvest_low_threshold) do
8382
desc 'Snapshot used space low threshold below which the system will stop automatically deleting snapshots in the pool'
8483

8584
end
86-
newparam(:is_fast_cache_enabled) do
85+
newproperty(:is_fast_cache_enabled) do
8786
desc 'Enable/disable FAST Cache for this pool'
8887

8988
end
9089

91-
newparam(:is_fastvp_enabled) do
90+
newproperty(:is_fastvp_enabled) do
9291
desc 'Enable/disable scheduled data relocations for this pool.'
9392

9493
end

lib/puppet/util/dellemc/unity_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
RubyPython.start
77

88
$storops = RubyPython.import('storops')
9+
910
$storops.enable_log
1011

1112
$unity_info = {}

0 commit comments

Comments
 (0)