Skip to content

Commit

Permalink
Removed the modules using deprecated v4 sdks (#536)
Browse files Browse the repository at this point in the history
* Removed the modules using deprecated v4 sdks

* Fixed flake8 and added some comments

* removing deprecated modules from runtime.yml file

* Addressed Comments

---------

Co-authored-by: George Ghawali <[email protected]>
  • Loading branch information
abhinavbansal29 and george-ghawali authored Dec 23, 2024
1 parent 23496fe commit fb5ec92
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 507 deletions.
2 changes: 0 additions & 2 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ action_groups:
- ntnx_volume_groups_info_v2
- ntnx_volume_groups_disks_v2
- ntnx_volume_groups_disks_info_v2
- ntnx_volume_groups_categories_info_v2
- ntnx_volume_groups_vms_info_v2
- ntnx_volume_groups_vms_v2
- ntnx_volume_groups_iscsi_clients_v2
- ntnx_volume_groups_iscsi_clients_info_v2
Expand Down
147 changes: 0 additions & 147 deletions plugins/modules/ntnx_volume_groups_categories_info_v2.py

This file was deleted.

65 changes: 3 additions & 62 deletions plugins/modules/ntnx_volume_groups_iscsi_clients_info_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
description:
- By default, Fetch all iscsi clients currently attached to any VG
- Fetch iscsi client if C(ext_id) is given
- Fetch all iscsi clients attached to a particular VG if C(volume_group_ext_id) is given
- This module uses PC v4 APIs based SDKs
version_added: "2.0.0"
author:
- Pradeepsingh Bhati (@bhati-pradeep)
Expand All @@ -27,27 +25,12 @@
- This will fetch the iscsi client with the given external ID.
type: str
required: false
volume_group_ext_id:
description:
- The external ID of the volume group.
- This will fetch all iscsi clients attached to the given volume group.
type: str
required: false
extends_documentation_fragment:
- nutanix.ncp.ntnx_credentials
- nutanix.ncp.ntnx_info_v2
"""

EXAMPLES = r"""
- name: Fetch iscsi clients attached to VG
nutanix.ncp.ntnx_volume_groups_iscsi_clients_info_v2:
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
state: "present"
volume_group_ext_id: 0005b6b1-0b3b-4b3b-8b3b-0b3b4b3b4b35
register: result
- name: Fetch specific iscsi client info
nutanix.ncp.ntnx_volume_groups_iscsi_clients_info_v2:
nutanix_host: "{{ ip }}"
Expand All @@ -72,7 +55,6 @@
description:
- list of iscsi clients currently attached to any VG
- specific iscsi client if ext_id given
- List of all iscsi clients attached to a particular VG using volume_group_ext_id
type: dict
returned: always
sample: [
Expand All @@ -94,11 +76,6 @@
type: str
returned: always
sample: "0005b6b1-0b3b-4b3b-8b3b-0b3b4b3b4b3b"
volume_group_ext_id:
description: Volume group external ID.
type: str
returned: always
sample: "0005b6b1-0b3b-4b3b-8b3b-0b3b4b3b4b3b"
error:
description: The error message if any.
type: str
Expand All @@ -120,47 +97,16 @@
)
from ..module_utils.v4.volumes.api_client import ( # noqa: E402
get_iscsi_client_api_instance,
get_vg_api_instance,
)


def get_module_spec():
module_args = dict(
ext_id=dict(type="str", required=False),
volume_group_ext_id=dict(type="str", required=False),
)
return module_args


def get_vg_iscsi_clients(module, result):
vgs = get_vg_api_instance(module)
volume_group_ext_id = module.params.get("volume_group_ext_id")

sg = SpecGenerator(module)
kwargs, err = sg.get_info_spec(attr=module.params)

if err:
result["error"] = err
module.fail_json(msg="Failed generating info Spec", **result)

try:
resp = vgs.list_external_iscsi_attachments_by_volume_group_id(
volumeGroupExtId=volume_group_ext_id, **kwargs
)
except Exception as e:
raise_api_exception(
module=module,
exception=e,
msg="Api Exception raised while fetching ISCSI clients attached to VGs",
)

result["volume_group_ext_id"] = volume_group_ext_id
resp = strip_internal_attributes(resp.to_dict()).get("data")
if not resp:
resp = []
result["response"] = resp


def get_iscsi_client(module, result):
clients = get_iscsi_client_api_instance(module)
ext_id = module.params.get("ext_id")
Expand Down Expand Up @@ -208,20 +154,15 @@ def run_module():
argument_spec=get_module_spec(),
supports_check_mode=False,
mutually_exclusive=[
("ext_id", "volume_group_ext_id"),
("ext_id", "filter"),
("volume_group_ext_id", "filter"),
],
)
remove_param_with_none_value(module.params)
result = {"changed": False, "error": None, "response": None}
if module.params.get("volume_group_ext_id"):
get_vg_iscsi_clients(module, result)
if module.params.get("ext_id"):
get_iscsi_client(module, result)
else:
if module.params.get("ext_id"):
get_iscsi_client(module, result)
else:
get_iscsi_clients(module, result)
get_iscsi_clients(module, result)

module.exit_json(**result)

Expand Down
Loading

0 comments on commit fb5ec92

Please sign in to comment.