Skip to content

Commit

Permalink
Add vcsa_settings module
Browse files Browse the repository at this point in the history
vcsa_settings module is used to Configure settings of VMware
appliance.

Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed May 21, 2024
1 parent 7e88370 commit 9b9ed73
Show file tree
Hide file tree
Showing 8 changed files with 863 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/10_vcsa_settings_new_module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
major_changes:
- vcsa_settings - Add new module to configure VCSA settings
37 changes: 37 additions & 0 deletions plugins/module_utils/vmware_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,40 @@ def get_tag_by_category_name(self, tag_name=None, category_name=None):
category_id = category_obj.id

return self.get_tag_by_category_id(tag_name=tag_name, category_id=category_id)

def obj_to_dict(self, vmware_obj, r):
"""
Tranform VMware SDK object to dictionary.
Args:
vmware_obj: Object to transform.
r: Dictionary to fill with object data.
"""
for k, v in vars(vmware_obj).items():
if not k.startswith('_'):
if hasattr(v, '__dict__') and not isinstance(v, str):
self.obj_to_dict(v, r[k])
elif isinstance(v, int):
r[k] = int(v)
else:
r[k] = str(v)

def set_param(self, param, cmp_fn, set_fn):
"""
Since most of the check is similar to do. This method implement
generic call for most of the parameters. It checks if parameter
specified is different to one which is currently set and if yes,
it will update it.
param: AnsibleModule parameter name
cmp_fn: function that compares the parameter value to any API call
set_fn: function that is called if the cmd_fn is true
"""
generic_param = self.params.get(param)
if generic_param is None:
return

if cmp_fn(generic_param):
self.changed = True
if not self.module.check_mode:
set_fn(generic_param)
self.info[param] = generic_param
Loading

0 comments on commit 9b9ed73

Please sign in to comment.