Skip to content

Commit

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

Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed May 17, 2024
1 parent f916e52 commit 8d868a4
Show file tree
Hide file tree
Showing 7 changed files with 860 additions and 0 deletions.
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 8d868a4

Please sign in to comment.