From fa7c5f6abc1947f643f992284ca306132b8eed76 Mon Sep 17 00:00:00 2001 From: Gevorg-Khachatryaan Date: Wed, 18 Oct 2023 18:25:06 +0400 Subject: [PATCH] check mode for delete operations --- plugins/modules/ntnx_acps.py | 5 +++++ plugins/modules/ntnx_address_groups.py | 6 ++++++ plugins/modules/ntnx_categories.py | 6 ++++++ plugins/modules/ntnx_floating_ips.py | 5 +++++ plugins/modules/ntnx_foundation_central.py | 5 +++++ plugins/modules/ntnx_foundation_image_upload.py | 7 +++++++ plugins/modules/ntnx_image_placement_policy.py | 6 ++++++ plugins/modules/ntnx_images.py | 6 ++++++ plugins/modules/ntnx_karbon_clusters.py | 5 +++++ plugins/modules/ntnx_karbon_clusters_node_pools.py | 6 ++++++ plugins/modules/ntnx_karbon_registries.py | 5 +++++ plugins/modules/ntnx_ndb_clusters.py | 6 ++++++ plugins/modules/ntnx_ndb_database_clones.py | 4 +++- plugins/modules/ntnx_ndb_database_snapshots.py | 6 ++++++ plugins/modules/ntnx_ndb_databases.py | 9 ++++++++- plugins/modules/ntnx_ndb_db_server_vms.py | 3 ++- plugins/modules/ntnx_ndb_linked_databases.py | 7 +++++++ plugins/modules/ntnx_ndb_maintenance_window.py | 6 ++++++ plugins/modules/ntnx_ndb_profiles.py | 6 ++++++ plugins/modules/ntnx_ndb_slas.py | 6 ++++++ plugins/modules/ntnx_ndb_stretched_vlans.py | 6 ++++++ plugins/modules/ntnx_ndb_tags.py | 6 ++++++ plugins/modules/ntnx_ndb_time_machine_clusters.py | 9 +++++++++ plugins/modules/ntnx_ndb_vlans.py | 6 ++++++ plugins/modules/ntnx_pbrs.py | 6 ++++++ plugins/modules/ntnx_projects.py | 7 +++++++ plugins/modules/ntnx_protection_rules.py | 7 +++++++ plugins/modules/ntnx_recovery_plans.py | 7 +++++++ plugins/modules/ntnx_roles.py | 7 +++++++ plugins/modules/ntnx_security_rules.py | 5 +++++ plugins/modules/ntnx_service_groups.py | 5 +++++ plugins/modules/ntnx_subnets.py | 6 ++++++ plugins/modules/ntnx_user_groups.py | 8 ++++++++ plugins/modules/ntnx_users.py | 7 +++++++ plugins/modules/ntnx_vms.py | 6 ++++++ plugins/modules/ntnx_vpcs.py | 6 ++++++ 36 files changed, 216 insertions(+), 3 deletions(-) diff --git a/plugins/modules/ntnx_acps.py b/plugins/modules/ntnx_acps.py index 04f1f1f56..59e21af5e 100644 --- a/plugins/modules/ntnx_acps.py +++ b/plugins/modules/ntnx_acps.py @@ -466,6 +466,11 @@ def delete_acp(module, result): result["error"] = "Missing parameter acp_uuid in playbook" module.fail_json(msg="Failed deleting acp", **result) + if module.check_mode: + result["acp_uuid"] = acp_uuid + result["response"] = "Acp with uuid:{0} will be deleted.".format(acp_uuid) + return + acp = ACP(module) resp = acp.delete(acp_uuid) result["changed"] = True diff --git a/plugins/modules/ntnx_address_groups.py b/plugins/modules/ntnx_address_groups.py index 55b950c73..d82fe6cdd 100644 --- a/plugins/modules/ntnx_address_groups.py +++ b/plugins/modules/ntnx_address_groups.py @@ -193,6 +193,12 @@ def update_address_group(module, result): def delete_address_group(module, result): address_group = AddressGroup(module) uuid = module.params["address_group_uuid"] + + if module.check_mode: + result["address_group_uuid"] = uuid + result["response"] = "Address group with uuid:{0} will be deleted.".format(uuid) + return + address_group.delete(uuid=uuid, no_response=True) result["response"] = {"msg": "Address group deleted successfully"} result["address_group_uuid"] = uuid diff --git a/plugins/modules/ntnx_categories.py b/plugins/modules/ntnx_categories.py index a2855894e..70dd703e8 100644 --- a/plugins/modules/ntnx_categories.py +++ b/plugins/modules/ntnx_categories.py @@ -278,6 +278,11 @@ def delete_categories(module, result): category_key_values.append(v["value"]) delete_category_values(module, name, category_key_values) + if module.check_mode: + result["category_name"] = name + result["response"] = "Category with name:{0} will be deleted.".format(name) + return + # delete the category resp = _category_key.delete(uuid=name, no_response=True) result["response"] = { @@ -286,6 +291,7 @@ def delete_categories(module, result): ) } + result["category_name"] = name result["changed"] = True diff --git a/plugins/modules/ntnx_floating_ips.py b/plugins/modules/ntnx_floating_ips.py index 826083bbe..0534c023f 100644 --- a/plugins/modules/ntnx_floating_ips.py +++ b/plugins/modules/ntnx_floating_ips.py @@ -230,6 +230,11 @@ def create_floating_ip(module, result): def delete_floating_ip(module, result): fip_uuid = module.params["fip_uuid"] + if module.check_mode: + result["fip_uuid"] = fip_uuid + result["response"] = "Floating IP with uuid:{0} will be deleted.".format(fip_uuid) + return + floating_ip = FloatingIP(module) resp = floating_ip.delete(fip_uuid) result["changed"] = True diff --git a/plugins/modules/ntnx_foundation_central.py b/plugins/modules/ntnx_foundation_central.py index 7c8acdb76..9952349a6 100644 --- a/plugins/modules/ntnx_foundation_central.py +++ b/plugins/modules/ntnx_foundation_central.py @@ -715,6 +715,11 @@ def deleteCluster(module, result): cluster_uuid = module.params.get("imaged_cluster_uuid") cluster = ImagedCluster(module) + if module.check_mode: + result["imaged_cluster_uuid"] = cluster_uuid + result["response"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) + return + resp = cluster.delete(cluster_uuid, no_response=True) result["response"] = resp result["imaged_cluster_uuid"] = cluster_uuid diff --git a/plugins/modules/ntnx_foundation_image_upload.py b/plugins/modules/ntnx_foundation_image_upload.py index 719f66eaa..d911f7476 100644 --- a/plugins/modules/ntnx_foundation_image_upload.py +++ b/plugins/modules/ntnx_foundation_image_upload.py @@ -96,8 +96,15 @@ def delete_image(module, result): image = Image(module, delete_image=True) fname = module.params["filename"] itype = module.params["installer_type"] + + if module.check_mode: + result["file_name"] = fname + result["response"] = "Image with name:{0} will be deleted.".format(fname) + return + resp = image.delete_image(fname, itype) + result["file_name"] = fname result["changed"] = True result["response"] = resp diff --git a/plugins/modules/ntnx_image_placement_policy.py b/plugins/modules/ntnx_image_placement_policy.py index 087e7ea56..53f5a2343 100644 --- a/plugins/modules/ntnx_image_placement_policy.py +++ b/plugins/modules/ntnx_image_placement_policy.py @@ -379,8 +379,14 @@ def delete_policy(module, result): result["error"] = "Missing parameter policy_uuid in task" module.fail_json(msg="Failed deleting Image placement policy", **result) + if module.check_mode: + result["policy_uuid"] = policy_uuid + result["response"] = "Placement policy with uuid:{0} will be deleted.".format(policy_uuid) + return + policy_obj = ImagePlacementPolicy(module) resp = policy_obj.delete(policy_uuid) + result["policy_uuid"] = policy_uuid result["response"] = resp result["changed"] = True task_uuid = resp["status"]["execution_context"]["task_uuid"] diff --git a/plugins/modules/ntnx_images.py b/plugins/modules/ntnx_images.py index 8733b9df7..266b73e9a 100644 --- a/plugins/modules/ntnx_images.py +++ b/plugins/modules/ntnx_images.py @@ -452,8 +452,14 @@ def delete_image(module, result): result["error"] = "Missing parameter image_uuid" module.fail_json(msg="Failed deleting Image", **result) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Image with uuid:{0} will be deleted.".format(uuid) + return + image = Image(module) resp = image.delete(uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True task_uuid = resp["status"]["execution_context"]["task_uuid"] diff --git a/plugins/modules/ntnx_karbon_clusters.py b/plugins/modules/ntnx_karbon_clusters.py index aeb1b64ec..1531a07d1 100644 --- a/plugins/modules/ntnx_karbon_clusters.py +++ b/plugins/modules/ntnx_karbon_clusters.py @@ -465,6 +465,11 @@ def delete_cluster(module, result): result["error"] = "Missing parameter name in playbook" module.fail_json(msg="Failed deleting cluster", **result) + if module.check_mode: + result["cluster_name"] = cluster_name + result["response"] = "Cluster with name:{0} will be deleted.".format(cluster_name) + return + cluster = Cluster(module) resp = cluster.delete(cluster_name) result["changed"] = True diff --git a/plugins/modules/ntnx_karbon_clusters_node_pools.py b/plugins/modules/ntnx_karbon_clusters_node_pools.py index bb51d6ba3..afcbd0230 100644 --- a/plugins/modules/ntnx_karbon_clusters_node_pools.py +++ b/plugins/modules/ntnx_karbon_clusters_node_pools.py @@ -322,6 +322,12 @@ def delete_pool(module, result): delete_nodes_of_pool(module, result) + if module.check_mode: + result["cluster_name"] = cluster_name + result["node_pool_name"] = pool_name + result["response"] = "Pool with name:{0} will be deleted.".format(pool_name) + return + node_pool = NodePool(module, resource_type="/v1-beta.1/k8s/clusters") resp = node_pool.remove_node_pool(cluster_name, pool_name) diff --git a/plugins/modules/ntnx_karbon_registries.py b/plugins/modules/ntnx_karbon_registries.py index 9be9f76cd..176dcf024 100644 --- a/plugins/modules/ntnx_karbon_registries.py +++ b/plugins/modules/ntnx_karbon_registries.py @@ -126,6 +126,11 @@ def delete_registry(module, result): result["error"] = "Missing parameter name in playbook" module.fail_json(msg="Failed deleting registry", **result) + if module.check_mode: + result["name"] = registry_name + result["response"] = "Registry with name:{0} will be deleted.".format(registry_name) + return + registry = Registry(module) resp = registry.delete(registry_name) result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_clusters.py b/plugins/modules/ntnx_ndb_clusters.py index aa8b5565f..7b119d140 100644 --- a/plugins/modules/ntnx_ndb_clusters.py +++ b/plugins/modules/ntnx_ndb_clusters.py @@ -423,6 +423,12 @@ def delete_cluster(module, result): cluster_uuid = module.params["uuid"] cluster = Cluster(module) + + if module.check_mode: + result["cluster_uuid"] = cluster_uuid + result["response"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) + return + resp, err = cluster.delete(cluster_uuid) if err: result["error"] = err diff --git a/plugins/modules/ntnx_ndb_database_clones.py b/plugins/modules/ntnx_ndb_database_clones.py index a6485ee76..3e0681b13 100644 --- a/plugins/modules/ntnx_ndb_database_clones.py +++ b/plugins/modules/ntnx_ndb_database_clones.py @@ -901,7 +901,8 @@ def delete_db_clone(module, result): ) if module.check_mode: - result["response"] = spec + result["uuid"] = uuid + result["response"] = "Db clone with uuid:{0} will be deleted.".format(uuid) return resp = _clones.delete(uuid, data=spec) @@ -912,6 +913,7 @@ def delete_db_clone(module, result): operations = Operation(module) resp = operations.wait_for_completion(ops_uuid, delay=5) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_database_snapshots.py b/plugins/modules/ntnx_ndb_database_snapshots.py index b4720f672..5dca14bf1 100644 --- a/plugins/modules/ntnx_ndb_database_snapshots.py +++ b/plugins/modules/ntnx_ndb_database_snapshots.py @@ -366,12 +366,18 @@ def delete_snapshot(module, result): snapshots = Snapshot(module) resp = snapshots.delete(uuid=snapshot_uuid) + if module.check_mode: + result["snapshot_uuid"] = snapshot_uuid + result["response"] = "Snapshot with uuid:{0} will be deleted.".format(snapshot_uuid) + return + if module.params.get("wait"): ops_uuid = resp["operationId"] operations = Operation(module) time.sleep(3) # to get ops ID functional resp = operations.wait_for_completion(ops_uuid, delay=2) + result["snapshot_uuid"] = snapshot_uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_databases.py b/plugins/modules/ntnx_ndb_databases.py index 6a7d76cdd..d61ed3516 100644 --- a/plugins/modules/ntnx_ndb_databases.py +++ b/plugins/modules/ntnx_ndb_databases.py @@ -1499,6 +1499,12 @@ def delete_db_servers(module, result, database_info): spec = db_servers.get_default_delete_spec( delete=module.params.get("delete_db_server_vms", False) ) + + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Db server with uuid:{0} will be deleted.".format(uuid) + return + resp = db_servers.delete(uuid=uuid, data=spec) ops_uuid = resp["operationId"] @@ -1524,7 +1530,8 @@ def delete_instance(module, result): spec = _databases.get_delete_spec() if module.check_mode: - result["response"] = spec + result["uuid"] = uuid + result["response"] = "Instance with uuid:{0} will be deleted.".format(uuid) return resp = _databases.delete(uuid, data=spec) diff --git a/plugins/modules/ntnx_ndb_db_server_vms.py b/plugins/modules/ntnx_ndb_db_server_vms.py index d8a57c320..6aaa5ade8 100644 --- a/plugins/modules/ntnx_ndb_db_server_vms.py +++ b/plugins/modules/ntnx_ndb_db_server_vms.py @@ -684,7 +684,8 @@ def delete_db_server(module, result): spec["remove"] = not spec["delete"] if module.check_mode: - result["response"] = spec + result["uuid"] = uuid + result["response"] = "Db server with uuid:{0} will be deleted.".format(uuid) return resp = db_servers.delete(data=spec, uuid=uuid) diff --git a/plugins/modules/ntnx_ndb_linked_databases.py b/plugins/modules/ntnx_ndb_linked_databases.py index 5dbabbaa6..b930c59b9 100644 --- a/plugins/modules/ntnx_ndb_linked_databases.py +++ b/plugins/modules/ntnx_ndb_linked_databases.py @@ -283,12 +283,19 @@ def remove_database(module, result): err_msg = "database_uuid and instance_uuid are required fields for deleting database from database instance" module.fail_json(msg=err_msg, **result) + if module.check_mode: + result["db_instance_uuid"] = instance_uuid + result["db_uuid"] = database_uuid + result["response"] = "Database with uuid:{0} will be removed.".format(database_uuid) + return + _databases = DatabaseInstance(module) resp = _databases.remove_linked_database( linked_database_uuid=database_uuid, database_instance_uuid=instance_uuid ) result["response"] = resp result["db_instance_uuid"] = instance_uuid + result["db_uuid"] = database_uuid if module.params.get("wait"): ops_uuid = resp["operationId"] diff --git a/plugins/modules/ntnx_ndb_maintenance_window.py b/plugins/modules/ntnx_ndb_maintenance_window.py index f90e8fb96..9ce45b97d 100644 --- a/plugins/modules/ntnx_ndb_maintenance_window.py +++ b/plugins/modules/ntnx_ndb_maintenance_window.py @@ -237,7 +237,13 @@ def delete_window(module, result): if not uuid: module.fail_json(msg="uuid is required field for delete", **result) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Window with uuid:{0} will be deleted.".format(uuid) + return + resp = _maintenance_window.delete(uuid=uuid, data={}) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_profiles.py b/plugins/modules/ntnx_ndb_profiles.py index 3c342679b..bb953e5a6 100644 --- a/plugins/modules/ntnx_ndb_profiles.py +++ b/plugins/modules/ntnx_ndb_profiles.py @@ -1183,8 +1183,14 @@ def delete_profile(module, result): if not uuid: return module.fail_json(msg="'profile_uuid' is a required for deleting profile") + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Profile with uuid:{0} will be deleted.".format(uuid) + return + resp = profiles.delete(uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_slas.py b/plugins/modules/ntnx_ndb_slas.py index eb04fa925..0990d2938 100644 --- a/plugins/modules/ntnx_ndb_slas.py +++ b/plugins/modules/ntnx_ndb_slas.py @@ -207,6 +207,11 @@ def delete_sla(module, result): if not uuid: module.fail_json(msg="uuid is required field for delete", **result) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Sla with uuid:{0} will be deleted.".format(uuid) + return + sla, err = _sla.get_sla(uuid=uuid) if err: module.fail_json(msg="Failed fetching sla info", **result) @@ -221,6 +226,7 @@ def delete_sla(module, result): msg="sla delete failed", response=resp, ) + result["uuid"] = uuid result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_stretched_vlans.py b/plugins/modules/ntnx_ndb_stretched_vlans.py index bebead6d0..4767945da 100644 --- a/plugins/modules/ntnx_ndb_stretched_vlans.py +++ b/plugins/modules/ntnx_ndb_stretched_vlans.py @@ -186,8 +186,14 @@ def delete_stretched_vlan(module, result): msg="stretched_vlan_uuid is required field for delete", **result ) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Stretched vlan with uuid:{0} will be deleted.".format(uuid) + return + resp = stretched_vlan.delete_stretched_vlan(uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_tags.py b/plugins/modules/ntnx_ndb_tags.py index 4c473805c..8f9392a2b 100644 --- a/plugins/modules/ntnx_ndb_tags.py +++ b/plugins/modules/ntnx_ndb_tags.py @@ -199,7 +199,13 @@ def delete_tags(module, result): if not uuid: module.fail_json(msg="'uuid' is required field for delete", **result) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Tag with uuid:{0} will be deleted.".format(uuid) + return + resp = tags.delete(uuid=uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_time_machine_clusters.py b/plugins/modules/ntnx_ndb_time_machine_clusters.py index 576abf9f5..f662789de 100644 --- a/plugins/modules/ntnx_ndb_time_machine_clusters.py +++ b/plugins/modules/ntnx_ndb_time_machine_clusters.py @@ -305,8 +305,17 @@ def delete_data_access_instance(module, result): result["error"] = err err_msg = "'cluster' is required field for removing cluster from time machine" module.fail_json(msg=err_msg, **result) + + if module.check_mode: + result["cluster_uuid"] = cluster_uuid + result["time_machine_uuid"] = tm_uuid + result["response"] = "Cluster with uuid:{0} will be deleted from Time Machine.".format(cluster_uuid) + return + resp = tm.delete_data_access_instance(tm_uuid, cluster_uuid) + result["cluster_uuid"] = cluster_uuid + result["time_machine_uuid"] = tm_uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_ndb_vlans.py b/plugins/modules/ntnx_ndb_vlans.py index bd978ce57..67c593a45 100644 --- a/plugins/modules/ntnx_ndb_vlans.py +++ b/plugins/modules/ntnx_ndb_vlans.py @@ -374,8 +374,14 @@ def delete_vlan(module, result): if not uuid: module.fail_json(msg="vlan_uuid is required field for delete", **result) + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Vlan with uuid:{0} will be deleted.".format(uuid) + return + resp = vlan.delete(uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True diff --git a/plugins/modules/ntnx_pbrs.py b/plugins/modules/ntnx_pbrs.py index 497d0ac20..f7e9b5402 100644 --- a/plugins/modules/ntnx_pbrs.py +++ b/plugins/modules/ntnx_pbrs.py @@ -502,6 +502,12 @@ def delete_pbr(module, result): pbr_uuid = module.params["pbr_uuid"] pbr = Pbr(module) + + if module.check_mode: + result["pbr_uuid"] = pbr_uuid + result["response"] = "Pbr with uuid:{0} will be deleted.".format(pbr_uuid) + return + resp = pbr.delete(pbr_uuid) result["changed"] = True result["response"] = resp diff --git a/plugins/modules/ntnx_projects.py b/plugins/modules/ntnx_projects.py index 67afb5d8c..270d3b4e3 100644 --- a/plugins/modules/ntnx_projects.py +++ b/plugins/modules/ntnx_projects.py @@ -742,7 +742,14 @@ def delete_project(module, result): module.fail_json(msg="Failed deleting Project", **result) projects = Project(module) + + if module.check_mode: + result["uuid"] = uuid + result["response"] = "Project with uuid:{0} will be deleted.".format(uuid) + return + resp = projects.delete(uuid) + result["uuid"] = uuid result["response"] = resp result["changed"] = True task_uuid = resp["status"]["execution_context"]["task_uuid"] diff --git a/plugins/modules/ntnx_protection_rules.py b/plugins/modules/ntnx_protection_rules.py index a27b7d6c6..5abf18ca4 100644 --- a/plugins/modules/ntnx_protection_rules.py +++ b/plugins/modules/ntnx_protection_rules.py @@ -720,7 +720,14 @@ def update_protection_rule(module, result): def delete_protection_rule(module, result): protection_rule = ProtectionRule(module) rule_uuid = module.params["rule_uuid"] + + if module.check_mode: + result["rule_uuid"] = rule_uuid + result["response"] = "Role with uuid:{0} will be deleted.".format(rule_uuid) + return + resp = protection_rule.delete(uuid=rule_uuid) + result["rule_uuid"] = rule_uuid task_uuid = resp["status"]["execution_context"]["task_uuid"] result["changed"] = True diff --git a/plugins/modules/ntnx_recovery_plans.py b/plugins/modules/ntnx_recovery_plans.py index 777ce9f2b..770ab122e 100644 --- a/plugins/modules/ntnx_recovery_plans.py +++ b/plugins/modules/ntnx_recovery_plans.py @@ -1101,7 +1101,14 @@ def update_recovery_plan(module, result): def delete_recovery_plan(module, result): recovery_plan = RecoveryPlan(module) plan_uuid = module.params["plan_uuid"] + + if module.check_mode: + result["plan_uuid"] = plan_uuid + result["response"] = "Recovery plan with uuid:{0} will be deleted.".format(plan_uuid) + return + resp = recovery_plan.delete(uuid=plan_uuid) + result["plan_uuid"] = plan_uuid task_uuid = resp["status"]["execution_context"]["task_uuid"] result["changed"] = True diff --git a/plugins/modules/ntnx_roles.py b/plugins/modules/ntnx_roles.py index 55d6a2559..445e7dd66 100644 --- a/plugins/modules/ntnx_roles.py +++ b/plugins/modules/ntnx_roles.py @@ -289,7 +289,14 @@ def update_role(module, result): def delete_role(module, result): roles = Role(module) role_uuid = module.params["role_uuid"] + + if module.check_mode: + result["role_uuid"] = role_uuid + result["response"] = "Role with uuid:{0} will be deleted.".format(role_uuid) + return + resp = roles.delete(uuid=role_uuid) + result["role_uuid"] = role_uuid task_uuid = resp["status"]["execution_context"]["task_uuid"] result["changed"] = True diff --git a/plugins/modules/ntnx_security_rules.py b/plugins/modules/ntnx_security_rules.py index a6c92e5de..06242624e 100644 --- a/plugins/modules/ntnx_security_rules.py +++ b/plugins/modules/ntnx_security_rules.py @@ -1280,6 +1280,11 @@ def delete_security_rule(module, result): result["error"] = "Missing parameter security_rule_uuid in playbook" module.fail_json(msg="Failed deleting security_rule", **result) + if module.check_mode: + result["security_rule_uuid"] = security_rule_uuid + result["response"] = "Security rule with uuid:{0} will be deleted.".format(security_rule_uuid) + return + security_rule = SecurityRule(module) resp = security_rule.delete(security_rule_uuid) result["changed"] = True diff --git a/plugins/modules/ntnx_service_groups.py b/plugins/modules/ntnx_service_groups.py index 14d01d454..9bb67bd93 100644 --- a/plugins/modules/ntnx_service_groups.py +++ b/plugins/modules/ntnx_service_groups.py @@ -237,6 +237,11 @@ def delete_service_group(module, result): result["error"] = "Missing parameter service_group_uuid in playbook" module.fail_json(msg="Failed deleting service_groups", **result) + if module.check_mode: + result["service_group_uuid"] = service_group_uuid + result["response"] = "Service group with uuid:{0} will be deleted.".format(service_group_uuid) + return + service_group = ServiceGroup(module) resp = service_group.delete(service_group_uuid, no_response=True) result["changed"] = True diff --git a/plugins/modules/ntnx_subnets.py b/plugins/modules/ntnx_subnets.py index 1be8363c0..e8d92bdcd 100644 --- a/plugins/modules/ntnx_subnets.py +++ b/plugins/modules/ntnx_subnets.py @@ -579,6 +579,12 @@ def delete_subnet(module, result): subnet_uuid = module.params["subnet_uuid"] subnet = Subnet(module) + + if module.check_mode: + result["subnet_uuid"] = subnet_uuid + result["response"] = "Subnet with uuid:{0} will be deleted.".format(subnet_uuid) + return + resp = subnet.delete(subnet_uuid) result["changed"] = True result["response"] = resp diff --git a/plugins/modules/ntnx_user_groups.py b/plugins/modules/ntnx_user_groups.py index a86f8d1da..fb3c7e190 100644 --- a/plugins/modules/ntnx_user_groups.py +++ b/plugins/modules/ntnx_user_groups.py @@ -250,9 +250,17 @@ def delete_user_group(module, result): module.fail_json(msg="Failed deleting user_group", **result) user_group = UserGroup(module) + + if module.check_mode: + result["uuid"] = uuid + result["response"] = "User group with uuid:{0} will be deleted.".format(uuid) + return + resp = user_group.delete(uuid) result["response"] = resp result["changed"] = True + result["uuid"] = uuid + task_uuid = resp["status"]["execution_context"]["task_uuid"] if module.params.get("wait"): diff --git a/plugins/modules/ntnx_users.py b/plugins/modules/ntnx_users.py index 2c06d8efd..96862e953 100644 --- a/plugins/modules/ntnx_users.py +++ b/plugins/modules/ntnx_users.py @@ -265,8 +265,15 @@ def delete_user(module, result): user = User(module) resp = user.delete(uuid) + + if module.check_mode: + result["uuid"] = uuid + result["response"] = "User with uuid:{0} will be deleted.".format(uuid) + return + result["response"] = resp result["changed"] = True + result["uuid"] = uuid task_uuid = resp["status"]["execution_context"]["task_uuid"] if module.params.get("wait"): diff --git a/plugins/modules/ntnx_vms.py b/plugins/modules/ntnx_vms.py index 7d1d329d3..9c7f55feb 100644 --- a/plugins/modules/ntnx_vms.py +++ b/plugins/modules/ntnx_vms.py @@ -947,6 +947,12 @@ def delete_vm(module, result): module.fail_json(msg="Failed deleting VM", **result) vm = VM(module) + + if module.check_mode: + result["vm_uuid"] = vm_uuid + result["response"] = "VM with uuid:{0} will be deleted.".format(vm_uuid) + return + resp = vm.delete(vm_uuid) result["changed"] = True result["response"] = resp diff --git a/plugins/modules/ntnx_vpcs.py b/plugins/modules/ntnx_vpcs.py index 8f7d0c658..06e2bbfdc 100644 --- a/plugins/modules/ntnx_vpcs.py +++ b/plugins/modules/ntnx_vpcs.py @@ -257,6 +257,12 @@ def delete_vpc(module, result): vpc_uuid = module.params["vpc_uuid"] vpc = Vpc(module) + + if module.check_mode: + result["vpc_uuid"] = vpc_uuid + result["response"] = "VPC with uuid:{0} will be deleted.".format(vpc_uuid) + return + resp = vpc.delete(vpc_uuid) result["changed"] = True result["response"] = resp