Skip to content

Commit

Permalink
Merge pull request #34791 from sjorge/zpool-state-tweaks
Browse files Browse the repository at this point in the history
salt.state.zpool tweaks
  • Loading branch information
Mike Place committed Jul 19, 2016
2 parents 1617a70 + d48c6d2 commit 49ab3fd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions salt/states/zpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
/dev/disk2
/dev/disk3
simplepool:
zpool.present:
- config:
import: false
force: true
- properties:
comment: another salty storage pool
- layout:
- /dev/disk0
- /dev/disk1
.. warning::
The layout will never be updated, it will only be used at time of creation.
Expand Down Expand Up @@ -171,7 +182,9 @@ def present(name, properties=None, filesystem_properties=None, layout=None, conf
layout_result = {}
for root_dev in layout:
if '-' in root_dev:
if root_dev.split('-')[0] not in ['mirror', 'log', 'cache', 'raidz1', 'raidz2', 'raidz3', 'spare']:
# NOTE: people seem to be confused a lot and want to use the 'disk' vdev which does not exist
# we try to accomidate them in the state module by faking it.
if root_dev.split('-')[0] not in ['mirror', 'log', 'cache', 'raidz1', 'raidz2', 'raidz3', 'spare', 'disk']:
layout_valid = False
layout_result[root_dev] = 'not a valid vdev type'
layout[root_dev] = layout[root_dev].keys() if isinstance(layout[root_dev], OrderedDict) else layout[root_dev].split(' ')
Expand Down Expand Up @@ -267,8 +280,10 @@ def present(name, properties=None, filesystem_properties=None, layout=None, conf
params.append(name)
for root_dev in layout:
if '-' in root_dev: # special device
params.append(root_dev.split('-')[0]) # add the type by stripping the ID
if root_dev.split('-')[0] in ['mirror', 'log', 'cache', 'raidz1', 'raidz2', 'raidz3', 'spare']:
# NOTE: accomidate non existing 'disk' vdev
if root_dev.split('-')[0] in ['mirror', 'log', 'cache', 'raidz1', 'raidz2', 'raidz3', 'spare', 'disk']:
if root_dev.split('-')[0] != 'disk':
params.append(root_dev.split('-')[0]) # add the type by stripping the ID
for sub_dev in layout[root_dev]: # add all sub devices
if '/' not in sub_dev and config['device_dir'] and os.path.exists(config['device_dir']):
sub_dev = os.path.join(config['device_dir'], sub_dev)
Expand Down

0 comments on commit 49ab3fd

Please sign in to comment.