Add zfs cloning

pull/18777/head
John W Higgins 9 years ago committed by Matt Clay
parent c10f898b53
commit c6a38ef185

@ -66,6 +66,10 @@ 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.
@ -253,8 +257,11 @@ 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)
if "@" in self.name: if "@" in self.name:
action = 'snapshot' action = 'snapshot'
elif clone:
action = 'clone'
else: else:
action = 'create' action = 'create'
@ -272,6 +279,8 @@ class Zfs(object):
if volsize: if volsize:
cmd.append('-V') cmd.append('-V')
cmd.append(volsize) cmd.append(volsize)
if clone:
cmd.append(clone)
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:
@ -347,6 +356,7 @@ 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']},

Loading…
Cancel
Save