Switch to origin and cleanup

This commit is contained in:
John W Higgins 2015-07-03 16:16:18 -07:00 committed by Matt Clay
parent c6a38ef185
commit b8bf7bd084

View file

@ -66,10 +66,6 @@ options:
- The checksum property. - The checksum property.
required: False required: False
choices: ['on','off',fletcher2,fletcher4,sha256] choices: ['on','off',fletcher2,fletcher4,sha256]
clone:
description:
- Name of the snapshot to clone
required: False
compression: compression:
description: description:
- The compression property. - The compression property.
@ -119,6 +115,10 @@ options:
- The normalization property. - The normalization property.
required: False required: False
choices: [none,formC,formD,formKC,formKD] choices: [none,formC,formD,formKC,formKD]
origin:
description:
- Name of the snapshot to clone
required: False
primarycache: primarycache:
description: description:
- The primarycache property. - The primarycache property.
@ -225,6 +225,12 @@ EXAMPLES = '''
# Create a new file system called myfs2 with snapdir enabled # Create a new file system called myfs2 with snapdir enabled
- zfs: name=rpool/myfs2 state=present snapdir=enabled - zfs: name=rpool/myfs2 state=present snapdir=enabled
# Create a new file system by cloning a snapshot
- zfs: name=rpool/cloned_fs state=present origin=rpool/myfs@mysnapshot
# Destroy a filesystem
- zfs: name=rpool/myfs state=absent
''' '''
@ -257,10 +263,10 @@ class Zfs(object):
properties = self.properties properties = self.properties
volsize = properties.pop('volsize', None) volsize = properties.pop('volsize', None)
volblocksize = properties.pop('volblocksize', None) volblocksize = properties.pop('volblocksize', None)
clone = properties.pop('clone', None) origin = properties.pop('origin', None)
if "@" in self.name: if "@" in self.name:
action = 'snapshot' action = 'snapshot'
elif clone: elif origin:
action = 'clone' action = 'clone'
else: else:
action = 'create' action = 'create'
@ -279,8 +285,8 @@ class Zfs(object):
if volsize: if volsize:
cmd.append('-V') cmd.append('-V')
cmd.append(volsize) cmd.append(volsize)
if clone: if origin:
cmd.append(clone) cmd.append(origin)
cmd.append(self.name) cmd.append(self.name)
(rc, err, out) = self.module.run_command(' '.join(cmd)) (rc, err, out) = self.module.run_command(' '.join(cmd))
if rc == 0: if rc == 0:
@ -356,7 +362,6 @@ def main():
'canmount': {'required': False, 'choices':['on', 'off', 'noauto']}, 'canmount': {'required': False, 'choices':['on', 'off', 'noauto']},
'casesensitivity': {'required': False, 'choices':['sensitive', 'insensitive', 'mixed']}, 'casesensitivity': {'required': False, 'choices':['sensitive', 'insensitive', 'mixed']},
'checksum': {'required': False, 'choices':['on', 'off', 'fletcher2', 'fletcher4', 'sha256']}, 'checksum': {'required': False, 'choices':['on', 'off', 'fletcher2', 'fletcher4', 'sha256']},
'clone': {'required': False},
'compression': {'required': False, 'choices':['on', 'off', 'lzjb', 'gzip', 'gzip-1', 'gzip-2', 'gzip-3', 'gzip-4', 'gzip-5', 'gzip-6', 'gzip-7', 'gzip-8', 'gzip-9', 'lz4', 'zle']}, 'compression': {'required': False, 'choices':['on', 'off', 'lzjb', 'gzip', 'gzip-1', 'gzip-2', 'gzip-3', 'gzip-4', 'gzip-5', 'gzip-6', 'gzip-7', 'gzip-8', 'gzip-9', 'lz4', 'zle']},
'copies': {'required': False, 'choices':['1', '2', '3']}, 'copies': {'required': False, 'choices':['1', '2', '3']},
'createparent': {'required': False, 'choices':['on', 'off']}, 'createparent': {'required': False, 'choices':['on', 'off']},
@ -370,6 +375,7 @@ def main():
'mountpoint': {'required': False}, 'mountpoint': {'required': False},
'nbmand': {'required': False, 'choices':['on', 'off']}, 'nbmand': {'required': False, 'choices':['on', 'off']},
'normalization': {'required': False, 'choices':['none', 'formC', 'formD', 'formKC', 'formKD']}, 'normalization': {'required': False, 'choices':['none', 'formC', 'formD', 'formKC', 'formKD']},
'origin': {'required': False},
'primarycache': {'required': False, 'choices':['all', 'none', 'metadata']}, 'primarycache': {'required': False, 'choices':['all', 'none', 'metadata']},
'quota': {'required': False}, 'quota': {'required': False},
'readonly': {'required': False, 'choices':['on', 'off']}, 'readonly': {'required': False, 'choices':['on', 'off']},