Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vcsa_settings module #19

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
---
minor_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
Loading