1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

rename self.properties -> self.extra_zfs_properties

This commit is contained in:
Vita Batrla 2024-04-05 16:21:09 +02:00
parent 56d346dbc1
commit 6542ad5c5f

View file

@ -102,10 +102,10 @@ from ansible.module_utils.basic import AnsibleModule
class Zfs(object): class Zfs(object):
def __init__(self, module, name, properties): def __init__(self, module, name, extra_zfs_properties):
self.module = module self.module = module
self.name = name self.name = name
self.properties = properties self.extra_zfs_properties = extra_zfs_properties
self.changed = False self.changed = False
self.zfs_cmd = module.get_bin_path('zfs', True) self.zfs_cmd = module.get_bin_path('zfs', True)
self.zpool_cmd = module.get_bin_path('zpool', True) self.zpool_cmd = module.get_bin_path('zpool', True)
@ -146,7 +146,7 @@ class Zfs(object):
if self.module.check_mode: if self.module.check_mode:
self.changed = True self.changed = True
return return
properties = self.properties extra_zfs_properties = self.extra_zfs_properties
origin = self.module.params.get('origin') origin = self.module.params.get('origin')
cmd = [self.zfs_cmd] cmd = [self.zfs_cmd]
@ -162,8 +162,8 @@ class Zfs(object):
if action in ['create', 'clone']: if action in ['create', 'clone']:
cmd += ['-p'] cmd += ['-p']
if properties: if extra_zfs_properties:
for prop, value in properties.items(): for prop, value in extra_zfs_properties.items():
if prop == 'volsize': if prop == 'volsize':
cmd += ['-V', value] cmd += ['-V', value]
elif prop == 'volblocksize': elif prop == 'volblocksize':
@ -194,7 +194,7 @@ class Zfs(object):
def set_properties_if_changed(self): def set_properties_if_changed(self):
diff = {'before': {'extra_zfs_properties': {}}, 'after': {'extra_zfs_properties': {}}} diff = {'before': {'extra_zfs_properties': {}}, 'after': {'extra_zfs_properties': {}}}
current_properties = self.list_properties() current_properties = self.list_properties()
for prop, value in self.properties.items(): for prop, value in self.extra_zfs_properties.items():
current_value = self.get_property(prop, current_properties) current_value = self.get_property(prop, current_properties)
if current_value != value: if current_value != value:
self.set_property(prop, value) self.set_property(prop, value)
@ -203,7 +203,7 @@ class Zfs(object):
if self.module.check_mode: if self.module.check_mode:
return diff return diff
updated_properties = self.list_properties() updated_properties = self.list_properties()
for prop in self.properties: for prop in self.extra_zfs_properties:
value = self.get_property(prop, updated_properties) value = self.get_property(prop, updated_properties)
if value is None: if value is None:
self.module.fail_json(msg="zfsprop was not present after being successfully set: %s" % prop) self.module.fail_json(msg="zfsprop was not present after being successfully set: %s" % prop)
@ -303,7 +303,7 @@ def main():
result['diff']['before_header'] = name result['diff']['before_header'] = name
result['diff']['after_header'] = name result['diff']['after_header'] = name
result.update(zfs.properties) result.update(zfs.extra_zfs_properties)
result['changed'] = zfs.changed result['changed'] = zfs.changed
module.exit_json(**result) module.exit_json(**result)