Skip to content

Commit

Permalink
Adding docs to some V4 module utils files (#544)
Browse files Browse the repository at this point in the history
* Adding docs to some V4 module utils files

* minor ansible lint fix

* Adding minor ansible lint fix
  • Loading branch information
george-ghawali authored Dec 22, 2024
1 parent 7676e48 commit 0a68873
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
9 changes: 9 additions & 0 deletions plugins/module_utils/v4/iam/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@


def get_authorization_policy(module, api_instance, ext_id):
"""
This method will return authorization policy info using ext_id.
Args:
module (object): Ansible module object
api_instance (object): Authorization policy api instance
ext_id (str): External id of authorization policy
Returns:
authorization_policy_info (dict): Authorization policy info
"""
try:
return api_instance.get_authorization_policy_by_id(extId=ext_id).data
except Exception as e:
Expand Down
77 changes: 77 additions & 0 deletions plugins/module_utils/v4/vmm/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@


def get_vm(module, api_instance, ext_id):
"""
Get VM by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of VM
Returns:
vm (obj): VM info object
"""
try:
return api_instance.get_vm_by_id(extId=ext_id).data
except Exception as e:
Expand All @@ -17,6 +26,16 @@ def get_vm(module, api_instance, ext_id):


def get_nic(module, api_instance, ext_id, vm_ext_id):
"""
Get NIC by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of NIC
vm_ext_id: ext_id of VM
Returns:
nic (obj): NIC info object
"""
try:
return api_instance.get_nic_by_id(vmExtId=vm_ext_id, extId=ext_id).data
except Exception as e:
Expand All @@ -28,6 +47,15 @@ def get_nic(module, api_instance, ext_id, vm_ext_id):


def get_ngt_status(module, api_instance, vm_ext_id):
"""
Get NGT info by vm ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
vm_ext_id: ext_id of VM
Returns:
ngt (obj): NGT info object
"""
try:
return api_instance.get_guest_tools_by_id(extId=vm_ext_id).data
except Exception as e:
Expand All @@ -39,6 +67,16 @@ def get_ngt_status(module, api_instance, vm_ext_id):


def get_disk(module, api_instance, ext_id, vm_ext_id):
"""
Get Disk by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of Disk
vm_ext_id: ext_id of VM
Returns:
disk (obj): Disk info object
"""
try:
return api_instance.get_disk_by_id(vmExtId=vm_ext_id, extId=ext_id).data
except Exception as e:
Expand All @@ -50,6 +88,16 @@ def get_disk(module, api_instance, ext_id, vm_ext_id):


def get_serial_port(module, api_instance, ext_id, vm_ext_id):
"""
Get Serial Port by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of Serial Port
vm_ext_id: ext_id of VM
Returns:
serial_port (obj): Serial Port info object
"""
try:
return api_instance.get_serial_port_by_id(vmExtId=vm_ext_id, extId=ext_id).data
except Exception as e:
Expand All @@ -61,6 +109,15 @@ def get_serial_port(module, api_instance, ext_id, vm_ext_id):


def get_template(module, api_instance, ext_id):
"""
Get Template by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of Template
Returns:
template (obj): Template info object
"""
try:
return api_instance.get_template_by_id(extId=ext_id).data
except Exception as e:
Expand All @@ -72,6 +129,16 @@ def get_template(module, api_instance, ext_id):


def get_cd_rom(module, api_instance, ext_id, vm_ext_id):
"""
Get CD ROM by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of CD ROM
vm_ext_id: ext_id of VM
Returns:
cd_rom (obj): CD ROM info object
"""
try:
return api_instance.get_cd_rom_by_id(vmExtId=vm_ext_id, extId=ext_id).data
except Exception as e:
Expand All @@ -83,6 +150,16 @@ def get_cd_rom(module, api_instance, ext_id, vm_ext_id):


def get_gpu(module, api_instance, ext_id, vm_ext_id):
"""
Get GPU by ext_id
Args:
module: Ansible module
api_instance: VmApi instance from ntnx_vmm_py_client sdk
ext_id: ext_id of GPU
vm_ext_id: ext_id of VM
Returns:
gpu (obj): GPU info object
"""
try:
return api_instance.get_gpu_by_id(vmExtId=vm_ext_id, extId=ext_id).data
except Exception as e:
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/ntnx_vms_ngt_info_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
validate_certs: false
ext_id: "98b9dc89-be08-3c56-b554-692b8b676fd1"
register: result
"""

RETURN = r"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,3 @@
mode: "0644"
url: "{{ unattendxml.url }}"
dest: "{{ unattendxml.dest }}"

0 comments on commit 0a68873

Please sign in to comment.