From fa7c5f6abc1947f643f992284ca306132b8eed76 Mon Sep 17 00:00:00 2001 From: Gevorg-Khachatryaan Date: Wed, 18 Oct 2023 18:25:06 +0400 Subject: [PATCH 1/7] 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 From 82a6c7c7c0e93a5ac4c5bc38687836e52da305a8 Mon Sep 17 00:00:00 2001 From: Gevorg-Khachatryaan Date: Tue, 31 Oct 2023 17:38:53 +0400 Subject: [PATCH 2/7] response to msg fix --- plugins/modules/ntnx_acps.py | 2 +- plugins/modules/ntnx_address_groups.py | 2 +- plugins/modules/ntnx_categories.py | 2 +- plugins/modules/ntnx_floating_ips.py | 2 +- plugins/modules/ntnx_foundation_central.py | 2 +- plugins/modules/ntnx_foundation_image_upload.py | 8 ++++---- plugins/modules/ntnx_image_placement_policy.py | 2 +- plugins/modules/ntnx_images.py | 2 +- plugins/modules/ntnx_karbon_clusters.py | 2 +- plugins/modules/ntnx_karbon_clusters_node_pools.py | 2 +- plugins/modules/ntnx_karbon_registries.py | 2 +- plugins/modules/ntnx_ndb_clusters.py | 2 +- plugins/modules/ntnx_ndb_database_clones.py | 2 +- plugins/modules/ntnx_ndb_database_snapshots.py | 2 +- plugins/modules/ntnx_ndb_databases.py | 5 +++-- plugins/modules/ntnx_ndb_db_server_vms.py | 3 ++- plugins/modules/ntnx_ndb_linked_databases.py | 2 +- plugins/modules/ntnx_ndb_maintenance_window.py | 2 +- plugins/modules/ntnx_ndb_profiles.py | 2 +- plugins/modules/ntnx_ndb_slas.py | 2 +- plugins/modules/ntnx_ndb_stretched_vlans.py | 2 +- plugins/modules/ntnx_ndb_tags.py | 2 +- plugins/modules/ntnx_ndb_time_machine_clusters.py | 2 +- plugins/modules/ntnx_ndb_vlans.py | 2 +- plugins/modules/ntnx_pbrs.py | 2 +- plugins/modules/ntnx_projects.py | 2 +- plugins/modules/ntnx_protection_rules.py | 2 +- plugins/modules/ntnx_recovery_plans.py | 2 +- plugins/modules/ntnx_roles.py | 2 +- plugins/modules/ntnx_security_rules.py | 2 +- plugins/modules/ntnx_service_groups.py | 2 +- plugins/modules/ntnx_subnets.py | 2 +- plugins/modules/ntnx_user_groups.py | 2 +- plugins/modules/ntnx_users.py | 2 +- plugins/modules/ntnx_vms.py | 2 +- plugins/modules/ntnx_vpcs.py | 2 +- 36 files changed, 42 insertions(+), 40 deletions(-) diff --git a/plugins/modules/ntnx_acps.py b/plugins/modules/ntnx_acps.py index 59e21af5e..d26b69e4b 100644 --- a/plugins/modules/ntnx_acps.py +++ b/plugins/modules/ntnx_acps.py @@ -468,7 +468,7 @@ def delete_acp(module, result): if module.check_mode: result["acp_uuid"] = acp_uuid - result["response"] = "Acp with uuid:{0} will be deleted.".format(acp_uuid) + result["msg"] = "Acp with uuid:{0} will be deleted.".format(acp_uuid) return acp = ACP(module) diff --git a/plugins/modules/ntnx_address_groups.py b/plugins/modules/ntnx_address_groups.py index d82fe6cdd..4ba0d0950 100644 --- a/plugins/modules/ntnx_address_groups.py +++ b/plugins/modules/ntnx_address_groups.py @@ -196,7 +196,7 @@ def delete_address_group(module, result): if module.check_mode: result["address_group_uuid"] = uuid - result["response"] = "Address group with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Address group with uuid:{0} will be deleted.".format(uuid) return address_group.delete(uuid=uuid, no_response=True) diff --git a/plugins/modules/ntnx_categories.py b/plugins/modules/ntnx_categories.py index 70dd703e8..a92324bef 100644 --- a/plugins/modules/ntnx_categories.py +++ b/plugins/modules/ntnx_categories.py @@ -280,7 +280,7 @@ def delete_categories(module, result): if module.check_mode: result["category_name"] = name - result["response"] = "Category with name:{0} will be deleted.".format(name) + result["msg"] = "Category with name:{0} will be deleted.".format(name) return # delete the category diff --git a/plugins/modules/ntnx_floating_ips.py b/plugins/modules/ntnx_floating_ips.py index 0534c023f..367643561 100644 --- a/plugins/modules/ntnx_floating_ips.py +++ b/plugins/modules/ntnx_floating_ips.py @@ -232,7 +232,7 @@ def delete_floating_ip(module, result): if module.check_mode: result["fip_uuid"] = fip_uuid - result["response"] = "Floating IP with uuid:{0} will be deleted.".format(fip_uuid) + result["msg"] = "Floating IP with uuid:{0} will be deleted.".format(fip_uuid) return floating_ip = FloatingIP(module) diff --git a/plugins/modules/ntnx_foundation_central.py b/plugins/modules/ntnx_foundation_central.py index 9952349a6..c5535d6cd 100644 --- a/plugins/modules/ntnx_foundation_central.py +++ b/plugins/modules/ntnx_foundation_central.py @@ -717,7 +717,7 @@ def deleteCluster(module, result): if module.check_mode: result["imaged_cluster_uuid"] = cluster_uuid - result["response"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) + result["msg"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) return resp = cluster.delete(cluster_uuid, no_response=True) diff --git a/plugins/modules/ntnx_foundation_image_upload.py b/plugins/modules/ntnx_foundation_image_upload.py index d911f7476..0758f56f9 100644 --- a/plugins/modules/ntnx_foundation_image_upload.py +++ b/plugins/modules/ntnx_foundation_image_upload.py @@ -80,10 +80,11 @@ def get_module_spec(): def upload_image(module, result): image = Image(module) + fname = module.params["filename"] + result["image_name"] = fname if module.check_mode: result["response"] = module.params return - fname = module.params["filename"] itype = module.params["installer_type"] source = module.params["source"] timeout = module.params["timeout"] @@ -96,15 +97,14 @@ def delete_image(module, result): image = Image(module, delete_image=True) fname = module.params["filename"] itype = module.params["installer_type"] + result["image_name"] = fname if module.check_mode: - result["file_name"] = fname - result["response"] = "Image with name:{0} will be deleted.".format(fname) + result["msg"] = "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 53f5a2343..b9ae1b2c2 100644 --- a/plugins/modules/ntnx_image_placement_policy.py +++ b/plugins/modules/ntnx_image_placement_policy.py @@ -381,7 +381,7 @@ def delete_policy(module, result): if module.check_mode: result["policy_uuid"] = policy_uuid - result["response"] = "Placement policy with uuid:{0} will be deleted.".format(policy_uuid) + result["msg"] = "Placement policy with uuid:{0} will be deleted.".format(policy_uuid) return policy_obj = ImagePlacementPolicy(module) diff --git a/plugins/modules/ntnx_images.py b/plugins/modules/ntnx_images.py index 266b73e9a..27d6f39ff 100644 --- a/plugins/modules/ntnx_images.py +++ b/plugins/modules/ntnx_images.py @@ -454,7 +454,7 @@ def delete_image(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Image with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Image with uuid:{0} will be deleted.".format(uuid) return image = Image(module) diff --git a/plugins/modules/ntnx_karbon_clusters.py b/plugins/modules/ntnx_karbon_clusters.py index 1531a07d1..af2e58ec4 100644 --- a/plugins/modules/ntnx_karbon_clusters.py +++ b/plugins/modules/ntnx_karbon_clusters.py @@ -467,7 +467,7 @@ def delete_cluster(module, result): if module.check_mode: result["cluster_name"] = cluster_name - result["response"] = "Cluster with name:{0} will be deleted.".format(cluster_name) + result["msg"] = "Cluster with name:{0} will be deleted.".format(cluster_name) return cluster = Cluster(module) diff --git a/plugins/modules/ntnx_karbon_clusters_node_pools.py b/plugins/modules/ntnx_karbon_clusters_node_pools.py index afcbd0230..bddd93bf4 100644 --- a/plugins/modules/ntnx_karbon_clusters_node_pools.py +++ b/plugins/modules/ntnx_karbon_clusters_node_pools.py @@ -325,7 +325,7 @@ def delete_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) + result["msg"] = "Pool with name:{0} will be deleted.".format(pool_name) return node_pool = NodePool(module, resource_type="/v1-beta.1/k8s/clusters") diff --git a/plugins/modules/ntnx_karbon_registries.py b/plugins/modules/ntnx_karbon_registries.py index 176dcf024..3c9cd7f88 100644 --- a/plugins/modules/ntnx_karbon_registries.py +++ b/plugins/modules/ntnx_karbon_registries.py @@ -128,7 +128,7 @@ def delete_registry(module, result): if module.check_mode: result["name"] = registry_name - result["response"] = "Registry with name:{0} will be deleted.".format(registry_name) + result["msg"] = "Registry with name:{0} will be deleted.".format(registry_name) return registry = Registry(module) diff --git a/plugins/modules/ntnx_ndb_clusters.py b/plugins/modules/ntnx_ndb_clusters.py index 7b119d140..aa55960fc 100644 --- a/plugins/modules/ntnx_ndb_clusters.py +++ b/plugins/modules/ntnx_ndb_clusters.py @@ -426,7 +426,7 @@ def delete_cluster(module, result): if module.check_mode: result["cluster_uuid"] = cluster_uuid - result["response"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) + result["msg"] = "Cluster with uuid:{0} will be deleted.".format(cluster_uuid) return resp, err = cluster.delete(cluster_uuid) diff --git a/plugins/modules/ntnx_ndb_database_clones.py b/plugins/modules/ntnx_ndb_database_clones.py index 3e0681b13..71f4c63d3 100644 --- a/plugins/modules/ntnx_ndb_database_clones.py +++ b/plugins/modules/ntnx_ndb_database_clones.py @@ -902,7 +902,7 @@ def delete_db_clone(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Db clone with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Db clone with uuid:{0} will be deleted.".format(uuid) return resp = _clones.delete(uuid, data=spec) diff --git a/plugins/modules/ntnx_ndb_database_snapshots.py b/plugins/modules/ntnx_ndb_database_snapshots.py index 5dca14bf1..9e795cae2 100644 --- a/plugins/modules/ntnx_ndb_database_snapshots.py +++ b/plugins/modules/ntnx_ndb_database_snapshots.py @@ -368,7 +368,7 @@ def delete_snapshot(module, result): if module.check_mode: result["snapshot_uuid"] = snapshot_uuid - result["response"] = "Snapshot with uuid:{0} will be deleted.".format(snapshot_uuid) + result["msg"] = "Snapshot with uuid:{0} will be deleted.".format(snapshot_uuid) return if module.params.get("wait"): diff --git a/plugins/modules/ntnx_ndb_databases.py b/plugins/modules/ntnx_ndb_databases.py index d61ed3516..b41a16c70 100644 --- a/plugins/modules/ntnx_ndb_databases.py +++ b/plugins/modules/ntnx_ndb_databases.py @@ -1502,7 +1502,7 @@ def delete_db_servers(module, result, database_info): if module.check_mode: result["uuid"] = uuid - result["response"] = "Db server with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Db server with uuid:{0} will be deleted.".format(uuid) return resp = db_servers.delete(uuid=uuid, data=spec) @@ -1530,8 +1530,9 @@ 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) + result["msg"] = "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 6aaa5ade8..ab2b889a4 100644 --- a/plugins/modules/ntnx_ndb_db_server_vms.py +++ b/plugins/modules/ntnx_ndb_db_server_vms.py @@ -684,8 +684,9 @@ 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) + result["msg"] = "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 b930c59b9..b12c472fb 100644 --- a/plugins/modules/ntnx_ndb_linked_databases.py +++ b/plugins/modules/ntnx_ndb_linked_databases.py @@ -286,7 +286,7 @@ def remove_database(module, 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) + result["msg"] = "Database with uuid:{0} will be removed.".format(database_uuid) return _databases = DatabaseInstance(module) diff --git a/plugins/modules/ntnx_ndb_maintenance_window.py b/plugins/modules/ntnx_ndb_maintenance_window.py index 9ce45b97d..52cb11b7d 100644 --- a/plugins/modules/ntnx_ndb_maintenance_window.py +++ b/plugins/modules/ntnx_ndb_maintenance_window.py @@ -239,7 +239,7 @@ def delete_window(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Window with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Window with uuid:{0} will be deleted.".format(uuid) return resp = _maintenance_window.delete(uuid=uuid, data={}) diff --git a/plugins/modules/ntnx_ndb_profiles.py b/plugins/modules/ntnx_ndb_profiles.py index bb953e5a6..311338157 100644 --- a/plugins/modules/ntnx_ndb_profiles.py +++ b/plugins/modules/ntnx_ndb_profiles.py @@ -1185,7 +1185,7 @@ def delete_profile(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Profile with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Profile with uuid:{0} will be deleted.".format(uuid) return resp = profiles.delete(uuid) diff --git a/plugins/modules/ntnx_ndb_slas.py b/plugins/modules/ntnx_ndb_slas.py index 0990d2938..31cc33764 100644 --- a/plugins/modules/ntnx_ndb_slas.py +++ b/plugins/modules/ntnx_ndb_slas.py @@ -209,7 +209,7 @@ def delete_sla(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Sla with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Sla with uuid:{0} will be deleted.".format(uuid) return sla, err = _sla.get_sla(uuid=uuid) diff --git a/plugins/modules/ntnx_ndb_stretched_vlans.py b/plugins/modules/ntnx_ndb_stretched_vlans.py index 4767945da..3a816a249 100644 --- a/plugins/modules/ntnx_ndb_stretched_vlans.py +++ b/plugins/modules/ntnx_ndb_stretched_vlans.py @@ -188,7 +188,7 @@ def delete_stretched_vlan(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Stretched vlan with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Stretched vlan with uuid:{0} will be deleted.".format(uuid) return resp = stretched_vlan.delete_stretched_vlan(uuid) diff --git a/plugins/modules/ntnx_ndb_tags.py b/plugins/modules/ntnx_ndb_tags.py index 8f9392a2b..fda78598d 100644 --- a/plugins/modules/ntnx_ndb_tags.py +++ b/plugins/modules/ntnx_ndb_tags.py @@ -201,7 +201,7 @@ def delete_tags(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Tag with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Tag with uuid:{0} will be deleted.".format(uuid) return resp = tags.delete(uuid=uuid) diff --git a/plugins/modules/ntnx_ndb_time_machine_clusters.py b/plugins/modules/ntnx_ndb_time_machine_clusters.py index f662789de..93f6dd714 100644 --- a/plugins/modules/ntnx_ndb_time_machine_clusters.py +++ b/plugins/modules/ntnx_ndb_time_machine_clusters.py @@ -309,7 +309,7 @@ def delete_data_access_instance(module, 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) + result["msg"] = "Cluster with uuid:{0} will be deleted from Time Machine.".format(cluster_uuid) return resp = tm.delete_data_access_instance(tm_uuid, cluster_uuid) diff --git a/plugins/modules/ntnx_ndb_vlans.py b/plugins/modules/ntnx_ndb_vlans.py index 67c593a45..d2df0f035 100644 --- a/plugins/modules/ntnx_ndb_vlans.py +++ b/plugins/modules/ntnx_ndb_vlans.py @@ -376,7 +376,7 @@ def delete_vlan(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Vlan with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Vlan with uuid:{0} will be deleted.".format(uuid) return resp = vlan.delete(uuid) diff --git a/plugins/modules/ntnx_pbrs.py b/plugins/modules/ntnx_pbrs.py index f7e9b5402..68f2a0b53 100644 --- a/plugins/modules/ntnx_pbrs.py +++ b/plugins/modules/ntnx_pbrs.py @@ -505,7 +505,7 @@ def delete_pbr(module, result): if module.check_mode: result["pbr_uuid"] = pbr_uuid - result["response"] = "Pbr with uuid:{0} will be deleted.".format(pbr_uuid) + result["msg"] = "Pbr with uuid:{0} will be deleted.".format(pbr_uuid) return resp = pbr.delete(pbr_uuid) diff --git a/plugins/modules/ntnx_projects.py b/plugins/modules/ntnx_projects.py index 270d3b4e3..e8e631fcc 100644 --- a/plugins/modules/ntnx_projects.py +++ b/plugins/modules/ntnx_projects.py @@ -745,7 +745,7 @@ def delete_project(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "Project with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "Project with uuid:{0} will be deleted.".format(uuid) return resp = projects.delete(uuid) diff --git a/plugins/modules/ntnx_protection_rules.py b/plugins/modules/ntnx_protection_rules.py index 5abf18ca4..110cadb61 100644 --- a/plugins/modules/ntnx_protection_rules.py +++ b/plugins/modules/ntnx_protection_rules.py @@ -723,7 +723,7 @@ def delete_protection_rule(module, result): if module.check_mode: result["rule_uuid"] = rule_uuid - result["response"] = "Role with uuid:{0} will be deleted.".format(rule_uuid) + result["msg"] = "Role with uuid:{0} will be deleted.".format(rule_uuid) return resp = protection_rule.delete(uuid=rule_uuid) diff --git a/plugins/modules/ntnx_recovery_plans.py b/plugins/modules/ntnx_recovery_plans.py index 770ab122e..d6b9de2e9 100644 --- a/plugins/modules/ntnx_recovery_plans.py +++ b/plugins/modules/ntnx_recovery_plans.py @@ -1104,7 +1104,7 @@ def delete_recovery_plan(module, result): if module.check_mode: result["plan_uuid"] = plan_uuid - result["response"] = "Recovery plan with uuid:{0} will be deleted.".format(plan_uuid) + result["msg"] = "Recovery plan with uuid:{0} will be deleted.".format(plan_uuid) return resp = recovery_plan.delete(uuid=plan_uuid) diff --git a/plugins/modules/ntnx_roles.py b/plugins/modules/ntnx_roles.py index 445e7dd66..6a5de9753 100644 --- a/plugins/modules/ntnx_roles.py +++ b/plugins/modules/ntnx_roles.py @@ -292,7 +292,7 @@ def delete_role(module, result): if module.check_mode: result["role_uuid"] = role_uuid - result["response"] = "Role with uuid:{0} will be deleted.".format(role_uuid) + result["msg"] = "Role with uuid:{0} will be deleted.".format(role_uuid) return resp = roles.delete(uuid=role_uuid) diff --git a/plugins/modules/ntnx_security_rules.py b/plugins/modules/ntnx_security_rules.py index 06242624e..605d53529 100644 --- a/plugins/modules/ntnx_security_rules.py +++ b/plugins/modules/ntnx_security_rules.py @@ -1282,7 +1282,7 @@ def delete_security_rule(module, 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) + result["msg"] = "Security rule with uuid:{0} will be deleted.".format(security_rule_uuid) return security_rule = SecurityRule(module) diff --git a/plugins/modules/ntnx_service_groups.py b/plugins/modules/ntnx_service_groups.py index 9bb67bd93..02dc8c1bf 100644 --- a/plugins/modules/ntnx_service_groups.py +++ b/plugins/modules/ntnx_service_groups.py @@ -239,7 +239,7 @@ def delete_service_group(module, 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) + result["msg"] = "Service group with uuid:{0} will be deleted.".format(service_group_uuid) return service_group = ServiceGroup(module) diff --git a/plugins/modules/ntnx_subnets.py b/plugins/modules/ntnx_subnets.py index e8d92bdcd..8a684298f 100644 --- a/plugins/modules/ntnx_subnets.py +++ b/plugins/modules/ntnx_subnets.py @@ -582,7 +582,7 @@ def delete_subnet(module, result): if module.check_mode: result["subnet_uuid"] = subnet_uuid - result["response"] = "Subnet with uuid:{0} will be deleted.".format(subnet_uuid) + result["msg"] = "Subnet with uuid:{0} will be deleted.".format(subnet_uuid) return resp = subnet.delete(subnet_uuid) diff --git a/plugins/modules/ntnx_user_groups.py b/plugins/modules/ntnx_user_groups.py index fb3c7e190..a15866876 100644 --- a/plugins/modules/ntnx_user_groups.py +++ b/plugins/modules/ntnx_user_groups.py @@ -253,7 +253,7 @@ def delete_user_group(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "User group with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "User group with uuid:{0} will be deleted.".format(uuid) return resp = user_group.delete(uuid) diff --git a/plugins/modules/ntnx_users.py b/plugins/modules/ntnx_users.py index 96862e953..a16995b9d 100644 --- a/plugins/modules/ntnx_users.py +++ b/plugins/modules/ntnx_users.py @@ -268,7 +268,7 @@ def delete_user(module, result): if module.check_mode: result["uuid"] = uuid - result["response"] = "User with uuid:{0} will be deleted.".format(uuid) + result["msg"] = "User with uuid:{0} will be deleted.".format(uuid) return result["response"] = resp diff --git a/plugins/modules/ntnx_vms.py b/plugins/modules/ntnx_vms.py index 9c7f55feb..99d5cd0e9 100644 --- a/plugins/modules/ntnx_vms.py +++ b/plugins/modules/ntnx_vms.py @@ -950,7 +950,7 @@ def delete_vm(module, result): if module.check_mode: result["vm_uuid"] = vm_uuid - result["response"] = "VM with uuid:{0} will be deleted.".format(vm_uuid) + result["msg"] = "VM with uuid:{0} will be deleted.".format(vm_uuid) return resp = vm.delete(vm_uuid) diff --git a/plugins/modules/ntnx_vpcs.py b/plugins/modules/ntnx_vpcs.py index 06e2bbfdc..5ac4f6a8d 100644 --- a/plugins/modules/ntnx_vpcs.py +++ b/plugins/modules/ntnx_vpcs.py @@ -260,7 +260,7 @@ def delete_vpc(module, result): if module.check_mode: result["vpc_uuid"] = vpc_uuid - result["response"] = "VPC with uuid:{0} will be deleted.".format(vpc_uuid) + result["msg"] = "VPC with uuid:{0} will be deleted.".format(vpc_uuid) return resp = vpc.delete(vpc_uuid) From abfb18ab4763399079900075cf71db2e8c4f8787 Mon Sep 17 00:00:00 2001 From: Gevorg-Khachatryaan Date: Tue, 31 Oct 2023 17:42:21 +0400 Subject: [PATCH 3/7] response to msg fix --- plugins/modules/ntnx_ndb_database_clones.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/modules/ntnx_ndb_database_clones.py b/plugins/modules/ntnx_ndb_database_clones.py index 71f4c63d3..236d9771e 100644 --- a/plugins/modules/ntnx_ndb_database_clones.py +++ b/plugins/modules/ntnx_ndb_database_clones.py @@ -889,6 +889,8 @@ def delete_db_clone(module, result): _clones = DatabaseClone(module) uuid = module.params.get("uuid") + result["uuid"] = uuid + if not uuid: module.fail_json(msg="uuid is required field for delete", **result) @@ -901,7 +903,7 @@ def delete_db_clone(module, result): ) if module.check_mode: - result["uuid"] = uuid + result["response"] = spec result["msg"] = "Db clone with uuid:{0} will be deleted.".format(uuid) return @@ -913,7 +915,6 @@ 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 From 75adccec2ac5c7e93f24003b6443eacf699b4d42 Mon Sep 17 00:00:00 2001 From: Alaa Bishtawi Date: Sun, 19 Nov 2023 13:03:57 +0200 Subject: [PATCH 4/7] add tests --- .../targets/ntnx_acps/tasks/delete_acp.yml | 18 +++++++++ .../ntnx_address_groups/tasks/delete.yml | 17 ++++++++ .../ntnx_categories/tasks/all_operations.yml | 18 +++++++++ .../tasks/upload.yml | 19 +++++++++ .../tasks/delete.yml | 18 +++++++++ .../targets/ntnx_images/tasks/delete.yml | 19 +++++++++ .../tasks/crud.yml | 39 ++++++++++++++++++- .../ntnx_karbon_registries/tasks/create.yml | 17 ++++++++ .../targets/ntnx_ndb_clusters/tasks/CRUD.yml | 17 ++++++++ .../ntnx_ndb_database_clones/tasks/clones.yml | 18 +++++++++ .../tasks/all_actions.yml | 20 ++++++++++ .../ntnx_ndb_db_server_vms/tasks/crud.yml | 17 ++++++++ .../tasks/crud.yml | 17 ++++++++ .../ntnx_ndb_profiles/tasks/compute.yml | 18 +++++++++ .../targets/ntnx_ndb_slas/tasks/CRUD.yml | 19 +++++++++ .../targets/ntnx_ndb_tags/tasks/crud.yml | 18 +++++++++ .../data_access_management_and_snapshots.yml | 20 ++++++++++ .../ntnx_ndb_vlans/tasks/create_vlans.yml | 17 ++++++++ .../ntnx_projects/tasks/delete_project.yml | 17 ++++++++ .../tasks/protection_rules.yml | 17 ++++++++ .../tasks/crud.yml | 18 +++++++++ .../targets/ntnx_roles/tasks/delete.yml | 17 ++++++++ .../ntnx_security_rules/tasks/app_rule.yml | 18 +++++++++ .../ntnx_service_groups/tasks/create.yml | 18 +++++++++ .../targets/ntnx_user_groups/tasks/create.yml | 19 +++++++++ .../targets/ntnx_users/tasks/create.yml | 18 +++++++++ .../tasks/create_floating_ips.yml | 18 +++++++++ .../nutanix_pbrs/tasks/create_pbrs.yml | 18 +++++++++ .../nutanix_subnets/tasks/delete_subnet.yml | 20 +++++++++- .../targets/nutanix_vms/tasks/delete.yml | 20 +++++++++- .../targets/nutanix_vpcs/tasks/delete_vpc.yml | 18 +++++++++ 31 files changed, 579 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/ntnx_acps/tasks/delete_acp.yml b/tests/integration/targets/ntnx_acps/tasks/delete_acp.yml index cb5c3d188..5183a9bf3 100644 --- a/tests/integration/targets/ntnx_acps/tasks/delete_acp.yml +++ b/tests/integration/targets/ntnx_acps/tasks/delete_acp.yml @@ -43,6 +43,24 @@ fail_msg: " Unable to Create ACP all specfactions " success_msg: " ACP with all specfactions created successfully " +- name: Delete acp with check mode + ntnx_acps: + state: absent + acp_uuid: "{{ result.response.metadata.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Acp with uuid:{{ result.response.metadata.uuid }} will be deleted." + - output.acp_uuid == "{{ result.response.metadata.uuid }}" + fail_msg: "Acp Policy been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete acp ntnx_acps: diff --git a/tests/integration/targets/ntnx_address_groups/tasks/delete.yml b/tests/integration/targets/ntnx_address_groups/tasks/delete.yml index 7449a209a..123c3c4df 100644 --- a/tests/integration/targets/ntnx_address_groups/tasks/delete.yml +++ b/tests/integration/targets/ntnx_address_groups/tasks/delete.yml @@ -32,6 +32,23 @@ success_msg: "address group created susccessfully" ################################################################################################### +- name: Delete address group with check mode + ntnx_address_groups: + state: absent + address_group_uuid: "{{ test_ag.address_group_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Address group with uuid:{{ test_ag.address_group_uuid }} will be deleted." + - output.address_group_uuid == "{{ test_ag.address_group_uuid }}" + fail_msg: "Address group Policy been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: delete address group ntnx_address_groups: diff --git a/tests/integration/targets/ntnx_categories/tasks/all_operations.yml b/tests/integration/targets/ntnx_categories/tasks/all_operations.yml index 655505426..a3876ae4b 100644 --- a/tests/integration/targets/ntnx_categories/tasks/all_operations.yml +++ b/tests/integration/targets/ntnx_categories/tasks/all_operations.yml @@ -131,6 +131,24 @@ fail_msg: "Fail: unable to update existing category by deleting all values " success_msg: "Passed: update existing category by deleting all values finished successfully" ################# +- name: Delete category with check mode + ntnx_categories: + state: absent + name: "{{ first_category.name }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Category with name:{{ first_category.name }} will be deleted." + - output.category_name == "{{ first_category.name }}" + fail_msg: "category been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delte the category ntnx_categories: state: "absent" diff --git a/tests/integration/targets/ntnx_foundation_image_upload/tasks/upload.yml b/tests/integration/targets/ntnx_foundation_image_upload/tasks/upload.yml index 3cc90a7f5..e7ab67761 100644 --- a/tests/integration/targets/ntnx_foundation_image_upload/tasks/upload.yml +++ b/tests/integration/targets/ntnx_foundation_image_upload/tasks/upload.yml @@ -26,6 +26,25 @@ fail_msg: " Fail : unable to upload image with nos installer_type " success_msg: "Succes: upload image with nos installer_type successfully " +- name: Delete Image with nos installer_type with check mode + ntnx_foundation_image_upload: + state: absent + filename: "integration-test-ntnx-package.tar.gz" + installer_type: nos + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Image with name:integration-test-ntnx-package.tar.gz will be deleted." + - output.image_name == "integration-test-ntnx-package.tar.gz" + fail_msg: "Image with nos installer_type been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete Image with nos installer_type ntnx_foundation_image_upload: state: absent diff --git a/tests/integration/targets/ntnx_image_placement_policy/tasks/delete.yml b/tests/integration/targets/ntnx_image_placement_policy/tasks/delete.yml index 871de54e2..1e6ff764c 100644 --- a/tests/integration/targets/ntnx_image_placement_policy/tasks/delete.yml +++ b/tests/integration/targets/ntnx_image_placement_policy/tasks/delete.yml @@ -23,6 +23,24 @@ fail_msg: "Unable to create image placement policy with minimal spec" success_msg: "Image placement policy with minimal spec created successfully" +- name: Delete image with check mode + ntnx_image_placement_policy: + state: absent + policy_uuid: "{{ result.response.metadata.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Placement policy with uuid:{{ result.response.metadata.uuid }} will be deleted." + - output.policy_uuid == "{{ result.response.metadata.uuid }}" + fail_msg: "Image Policy been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete image placement policy created above ntnx_image_placement_policy: state: absent diff --git a/tests/integration/targets/ntnx_images/tasks/delete.yml b/tests/integration/targets/ntnx_images/tasks/delete.yml index 0f9d360be..5e3b4f86c 100644 --- a/tests/integration/targets/ntnx_images/tasks/delete.yml +++ b/tests/integration/targets/ntnx_images/tasks/delete.yml @@ -20,6 +20,25 @@ fail_msg: "Unable to create image with minimal spec for delete tests" success_msg: "Image with minimal spec created successfully" + +- name: Delete image with check mode + ntnx_images: + state: absent + image_uuid: "{{ result.response.metadata.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Image with uuid:{{ result.response.metadata.uuid }} will be deleted." + - output.uuid == "{{ result.response.metadata.uuid }}" + fail_msg: "Image been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete image created above ntnx_images: state: absent diff --git a/tests/integration/targets/ntnx_karbon_clusters_and_info/tasks/crud.yml b/tests/integration/targets/ntnx_karbon_clusters_and_info/tasks/crud.yml index 7902da501..7ff1b83d1 100644 --- a/tests/integration/targets/ntnx_karbon_clusters_and_info/tasks/crud.yml +++ b/tests/integration/targets/ntnx_karbon_clusters_and_info/tasks/crud.yml @@ -147,6 +147,23 @@ fail_msg: " Fail: unable to create DEV cluster with Flannel network provider" success_msg: " Pass: create DEV cluster with Flannel network provider successfully " ############################# +- name: Delete Cluster with check mode + ntnx_karbon_clusters: + state: absent + name: "{{ result.response.name }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Cluster with name:{{ result.response.name }} will be deleted." + fail_msg: "Cluster been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete dev cluster with Flannel network provider ntnx_karbon_clusters: state: absent @@ -163,7 +180,7 @@ - result.response.status == "SUCCEEDED" fail_msg: " Fail: unable to delete dev cluster with Flannel network provider" success_msg: " Pass: delete dev cluster with Flannel network provider finished successfully" -############################# +############################ - name: create DEV cluster with Calico network provider ntnx_karbon_clusters: cluster: @@ -442,6 +459,26 @@ fail_msg: "Fail: Unable to update pool by decreasing cpu,memory_gb,num_instances and add remove labels " success_msg: "Passed: update pool by decreasing cpu,memory_gb,num_instances and add remove labels finished successfully " ################################ +- name: Delete pool with check mode + ntnx_karbon_clusters_node_pools: + state: absent + node_pool_name: "{{node1_name}}" + cluster_name: "{{karbon_name}}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Pool with name:{{ node1_name }} will be deleted." + - output.cluster_name == "{{karbon_name}}" + - output.node_pool_name == "{{node1_name}}" + fail_msg: "pool been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete pool ntnx_karbon_clusters_node_pools: state: absent diff --git a/tests/integration/targets/ntnx_karbon_registries/tasks/create.yml b/tests/integration/targets/ntnx_karbon_registries/tasks/create.yml index 292d7cf16..f71415b0a 100644 --- a/tests/integration/targets/ntnx_karbon_registries/tasks/create.yml +++ b/tests/integration/targets/ntnx_karbon_registries/tasks/create.yml @@ -87,6 +87,23 @@ fail_msg: "Fail: unable to create registry with username and password" success_msg: "Pass: create registry with username and password finished successfully" ############################################################### +- name: Delete registry with check mode + ntnx_karbon_registries: + state: absent + name: "{{ registry_name }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Registry with name:{{ registry_name }} will be deleted." + fail_msg: "registry been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete registry ntnx_karbon_registries: name: "{{registry_name}}" diff --git a/tests/integration/targets/ntnx_ndb_clusters/tasks/CRUD.yml b/tests/integration/targets/ntnx_ndb_clusters/tasks/CRUD.yml index 405e547c7..482a7306d 100644 --- a/tests/integration/targets/ntnx_ndb_clusters/tasks/CRUD.yml +++ b/tests/integration/targets/ntnx_ndb_clusters/tasks/CRUD.yml @@ -319,6 +319,23 @@ success_msg: "module errored out correctly when incorrect name is given" ################################################################ +- name: Delete Cluster with check mode + ntnx_ndb_clusters: + state: absent + uuid: "{{ todelete }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Cluster with uuid:{{ todelete }} will be deleted." + - output.cluster_uuid == "{{ todelete }}" + fail_msg: "Cluster been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: delete cluster ntnx_ndb_clusters: diff --git a/tests/integration/targets/ntnx_ndb_database_clones/tasks/clones.yml b/tests/integration/targets/ntnx_ndb_database_clones/tasks/clones.yml index 899853d9e..72947d743 100644 --- a/tests/integration/targets/ntnx_ndb_database_clones/tasks/clones.yml +++ b/tests/integration/targets/ntnx_ndb_database_clones/tasks/clones.yml @@ -518,6 +518,24 @@ fail_msg: "creation of spec for unregistration failed" success_msg: "spec for unregistration created successfully" +- name: Delete clone db with check mode + ntnx_ndb_database_clones: + state: absent + uuid: "{{clone_uuid}}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Db clone with uuid:{{ clone_uuid }} will be deleted." + - output.uuid == "{{ clone_uuid }}" + fail_msg: "clone db been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete clone db ntnx_ndb_database_clones: state: "absent" diff --git a/tests/integration/targets/ntnx_ndb_databases_actions/tasks/all_actions.yml b/tests/integration/targets/ntnx_ndb_databases_actions/tasks/all_actions.yml index c75d79436..05b0c8038 100644 --- a/tests/integration/targets/ntnx_ndb_databases_actions/tasks/all_actions.yml +++ b/tests/integration/targets/ntnx_ndb_databases_actions/tasks/all_actions.yml @@ -644,6 +644,26 @@ success_msg: "databases added to database instance successfully" +- name: remove databases in database instance with check mode + ntnx_ndb_linked_databases: + state: absent + db_instance_uuid: "{{db_uuid}}" + database_uuid: "{{linked_databases.test1}}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Database with uuid:{{ db_uuid }} will be removed." + - output.db_uuid == "{{ db_uuid }}" + - output.db_instance_uuid == "{{ linked_databases.test1 }}" + fail_msg: " Remove databases in database instance within check_mode" + success_msg: "Returned As expected" + - name: remove databases in database instance ntnx_ndb_linked_databases: state: "absent" diff --git a/tests/integration/targets/ntnx_ndb_db_server_vms/tasks/crud.yml b/tests/integration/targets/ntnx_ndb_db_server_vms/tasks/crud.yml index 60f07a1c4..398c74ff5 100644 --- a/tests/integration/targets/ntnx_ndb_db_server_vms/tasks/crud.yml +++ b/tests/integration/targets/ntnx_ndb_db_server_vms/tasks/crud.yml @@ -939,6 +939,23 @@ db_server_uuid: "{{result.uuid}}" ################################### DB server VM Delete test ############################# +- name: Delete db server vm with check mode + ntnx_ndb_db_server_vms: + state: absent + uuid: "{{ db_server_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Db server with uuid:{{ db_server_uuid }} will be deleted." + - output.uuid == "{{ db_server_uuid }}" + fail_msg: "db server vm been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: unregister db server vm diff --git a/tests/integration/targets/ntnx_ndb_maintenance_windows/tasks/crud.yml b/tests/integration/targets/ntnx_ndb_maintenance_windows/tasks/crud.yml index 15f1db254..9a036216d 100644 --- a/tests/integration/targets/ntnx_ndb_maintenance_windows/tasks/crud.yml +++ b/tests/integration/targets/ntnx_ndb_maintenance_windows/tasks/crud.yml @@ -314,6 +314,23 @@ ############################################## delete tests #################################### +- name: Delete window with check mode + ntnx_ndb_maintenance_window: + state: absent + uuid: "{{ window1_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Window with uuid:{{ window1_uuid }} will be deleted." + - output.uuid == "{{ window1_uuid }}" + fail_msg: "window been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: delete window 1 ntnx_ndb_maintenance_window: diff --git a/tests/integration/targets/ntnx_ndb_profiles/tasks/compute.yml b/tests/integration/targets/ntnx_ndb_profiles/tasks/compute.yml index 0f3521d25..c70653bd3 100644 --- a/tests/integration/targets/ntnx_ndb_profiles/tasks/compute.yml +++ b/tests/integration/targets/ntnx_ndb_profiles/tasks/compute.yml @@ -147,6 +147,24 @@ fail_msg: "Fail: unable to verify unpublish flow in compute profile " success_msg: "Pass: verify unpublish flow in compute profile finished successfully" ################################################################ +- name: Delete profiles with check mode + ntnx_ndb_profiles: + state: absent + profile_uuid: "{{ todelete[0] }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Profile with uuid:{{ todelete[0] }} will be deleted." + - output.uuid == "{{ todelete[0] }}" + fail_msg: "Profile been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete all created cmpute profiles ntnx_ndb_profiles: state: absent diff --git a/tests/integration/targets/ntnx_ndb_slas/tasks/CRUD.yml b/tests/integration/targets/ntnx_ndb_slas/tasks/CRUD.yml index 9783b72a2..ff899de86 100644 --- a/tests/integration/targets/ntnx_ndb_slas/tasks/CRUD.yml +++ b/tests/integration/targets/ntnx_ndb_slas/tasks/CRUD.yml @@ -252,6 +252,25 @@ success_msg: "module errored out correctly when incorrect name is given" ######################################################################## Delete flow ################################################# + +- name: Delete Sla with check mode + ntnx_ndb_slas: + state: absent + sla_uuid: "{{ todelete[0] }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Sla with uuid:{{ todelete[0] }} will be deleted." + - output.uuid == "{{ todelete[0] }}" + fail_msg: "Sla been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: verify slas delete flow ntnx_ndb_slas: state: absent diff --git a/tests/integration/targets/ntnx_ndb_tags/tasks/crud.yml b/tests/integration/targets/ntnx_ndb_tags/tasks/crud.yml index 82f41e5c9..d34d68e15 100644 --- a/tests/integration/targets/ntnx_ndb_tags/tasks/crud.yml +++ b/tests/integration/targets/ntnx_ndb_tags/tasks/crud.yml @@ -420,6 +420,24 @@ fail_msg: "Unable to delete tag" success_msg: "tag deleted successfully" +- name: Delete Tag with check mode + ntnx_ndb_tags: + state: absent + uuid: "{{ db_server_tag_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Tag with uuid:{{ db_server_tag_uuid}} will be deleted." + - output.uuid == "{{ db_server_tag_uuid }}" + fail_msg: "Tag been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete the database server based tag ntnx_ndb_tags: diff --git a/tests/integration/targets/ntnx_ndb_time_machines_with_multi_clusters/tasks/data_access_management_and_snapshots.yml b/tests/integration/targets/ntnx_ndb_time_machines_with_multi_clusters/tasks/data_access_management_and_snapshots.yml index 2cce408d1..0d7873b61 100644 --- a/tests/integration/targets/ntnx_ndb_time_machines_with_multi_clusters/tasks/data_access_management_and_snapshots.yml +++ b/tests/integration/targets/ntnx_ndb_time_machines_with_multi_clusters/tasks/data_access_management_and_snapshots.yml @@ -195,6 +195,26 @@ success_msg: "snapshot replicated successfully" ####################### +- name: Delete time machine with check mode + ntnx_ndb_time_machine_clusters: + state: absent + time_machine_uuid: "{{ time_machine.uuid }}" + cluster: + uuid: "{{cluster.cluster2.uuid}}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Cluster with uuid:{{ time_machine.uuid}} will be deleted from Time Machine." + - output.time_machine_uuid == "{{ time_machine.uuid }}" + - output.cluster_uuid == "{{cluster.cluster2.uuid}}" + fail_msg: "Time machine been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: delete time machine ntnx_ndb_time_machine_clusters: diff --git a/tests/integration/targets/ntnx_ndb_vlans/tasks/create_vlans.yml b/tests/integration/targets/ntnx_ndb_vlans/tasks/create_vlans.yml index 79089f56b..2b20dd37c 100644 --- a/tests/integration/targets/ntnx_ndb_vlans/tasks/create_vlans.yml +++ b/tests/integration/targets/ntnx_ndb_vlans/tasks/create_vlans.yml @@ -412,6 +412,23 @@ # success_msg: "pass: update ndb_stretched subnet_mask, gateway finished successfully" ################################################################ +- name: Delete vlan with check mode + ntnx_ndb_vlans: + state: absent + vlan_uuid: "{{ result.vlan_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Vlan with uuid:{{ result.vlan_uuid }} will be deleted." + - output.uuid == "{{ result.vlan_uuid }}" + fail_msg: "vlan has been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: Delete all created vlan's ntnx_ndb_vlans: diff --git a/tests/integration/targets/ntnx_projects/tasks/delete_project.yml b/tests/integration/targets/ntnx_projects/tasks/delete_project.yml index e1fc273be..be0799084 100644 --- a/tests/integration/targets/ntnx_projects/tasks/delete_project.yml +++ b/tests/integration/targets/ntnx_projects/tasks/delete_project.yml @@ -16,6 +16,23 @@ fail_msg: "Unable to create project with minimal spec" success_msg: "Project with minimal spec created successfully" +- name: Delete project with check mode + ntnx_projects: + state: absent + project_uuid: "{{ result.project_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Project with uuid:{{ result.project_uuid }} will be deleted." + - output.uuid == "{{ result.project_uuid }}" + fail_msg: "Project has been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: Delete created project ntnx_projects: state: absent diff --git a/tests/integration/targets/ntnx_protection_rules/tasks/protection_rules.yml b/tests/integration/targets/ntnx_protection_rules/tasks/protection_rules.yml index 0571559ca..477cee710 100644 --- a/tests/integration/targets/ntnx_protection_rules/tasks/protection_rules.yml +++ b/tests/integration/targets/ntnx_protection_rules/tasks/protection_rules.yml @@ -341,6 +341,23 @@ ############################################################## DELETE Protection Policy Tests ################################################################## +- name: Delete protection with check mode + ntnx_protection_rules: + state: absent + rule_uuid: "{{ result.rule_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Role with uuid:{{ result.rule_uuid}} will be deleted." + - output.rule_uuid == "{{ result.rule_uuid }}" + fail_msg: "protection policy been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: Delete created protection policy ntnx_protection_rules: diff --git a/tests/integration/targets/ntnx_recovery_plans_and_jobs/tasks/crud.yml b/tests/integration/targets/ntnx_recovery_plans_and_jobs/tasks/crud.yml index baa5ec94b..61b337eba 100644 --- a/tests/integration/targets/ntnx_recovery_plans_and_jobs/tasks/crud.yml +++ b/tests/integration/targets/ntnx_recovery_plans_and_jobs/tasks/crud.yml @@ -673,6 +673,24 @@ success_msg: "Cleanup job run successfully" ############################################################### Delete Recovery Plan Test########################################################################################### +- name: Delete Recovery plan with check mode + ntnx_recovery_plans: + state: absent + plan_uuid: "{{ recovery_plan.plan_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Recovery plan with uuid:{{ recovery_plan.plan_uuid }} will be deleted." + - output.plan_uuid == "{{ recovery_plan.plan_uuid }}" + fail_msg: "Recovery plan has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete recovery plan ntnx_recovery_plans: diff --git a/tests/integration/targets/ntnx_roles/tasks/delete.yml b/tests/integration/targets/ntnx_roles/tasks/delete.yml index 098c0fdeb..d3f23f548 100644 --- a/tests/integration/targets/ntnx_roles/tasks/delete.yml +++ b/tests/integration/targets/ntnx_roles/tasks/delete.yml @@ -31,6 +31,23 @@ success_msg: "Roles with given permissions created susccessfully" ################################################################################################### +- name: Delete rule with check mode + ntnx_roles: + state: absent + role_uuid: "{{ test_role.role_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Role with uuid:{{ test_role.role_uuid}} will be deleted." + - output.role_uuid == "{{ test_role.role_uuid }}" + fail_msg: "Role been deleted successfully within check_mode" + success_msg: "Returned As expected" - name: delete role ntnx_roles: diff --git a/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml b/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml index c7f082897..bfb48e7df 100644 --- a/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml +++ b/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml @@ -120,6 +120,24 @@ fail_msg: ' fail: unable to update app security rule with outbound list ' success_msg: 'pass :update app security rule with outbound list successfully' +- name: Delete app security rule with check mode + ntnx_security_rules: + state: absent + security_rule_uuid: "{{ result.response.metadata.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Security rule with uuid:{{ result.response.metadata.uuid}} will be deleted." + - output.security_rule_uuid == "{{ result.response.metadata.uuid }}" + fail_msg: "app security has rule been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete app security rule ntnx_security_rules: state: absent diff --git a/tests/integration/targets/ntnx_service_groups/tasks/create.yml b/tests/integration/targets/ntnx_service_groups/tasks/create.yml index f5e592a3e..a2723ac10 100644 --- a/tests/integration/targets/ntnx_service_groups/tasks/create.yml +++ b/tests/integration/targets/ntnx_service_groups/tasks/create.yml @@ -159,6 +159,24 @@ - set_fact: todelete: "{{ todelete + [ result.response.uuid ] }}" ################################################################ +- name: Delete service groups with check mode + ntnx_service_groups: + state: absent + service_group_uuid: "{{ result.response.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =='Service group with uuid:{{ result.response.uuid }} will be deleted.' + - output.service_group_uuid == '{{ result.response.uuid }}' + fail_msg: "service groups has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete all created service groups ntnx_service_groups: state: absent diff --git a/tests/integration/targets/ntnx_user_groups/tasks/create.yml b/tests/integration/targets/ntnx_user_groups/tasks/create.yml index d512ad077..bfcb6bea8 100644 --- a/tests/integration/targets/ntnx_user_groups/tasks/create.yml +++ b/tests/integration/targets/ntnx_user_groups/tasks/create.yml @@ -128,6 +128,25 @@ # fail_msg: "Unable to list user groups using ascending name sorting" # success_msg: "user groups listed successfully using ascending name sorting" + +- name: Delete user group with check mode + ntnx_user_groups: + state: absent + user_group_uuid: "{{ user_group_to_delete }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =='User group with uuid:{{ user_group_to_delete }} will be deleted.' + - output.uuid == '{{ user_group_to_delete }}' + fail_msg: "user group has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: delete user group ntnx_user_groups: state: absent diff --git a/tests/integration/targets/ntnx_users/tasks/create.yml b/tests/integration/targets/ntnx_users/tasks/create.yml index 843a46535..0852f2e86 100644 --- a/tests/integration/targets/ntnx_users/tasks/create.yml +++ b/tests/integration/targets/ntnx_users/tasks/create.yml @@ -48,6 +48,24 @@ - set_fact: todelete: "{{ todelete + [ result.user_uuid ] }}" ################################################# +- name: Delete user with check mode + ntnx_users: + state: absent + user_uuid: "{{ result.user_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =='User with uuid:{{ result.user_uuid }} will be deleted.' + - output.uuid == '{{ result.user_uuid }}' + fail_msg: "user has been deleted successfully within check_mode" + success_msg: "Returned As expected" +################################################# - name: Delete created users ntnx_users: state: absent diff --git a/tests/integration/targets/nutanix_floating_ips/tasks/create_floating_ips.yml b/tests/integration/targets/nutanix_floating_ips/tasks/create_floating_ips.yml index 9ae9e8aa8..2e5b297cb 100644 --- a/tests/integration/targets/nutanix_floating_ips/tasks/create_floating_ips.yml +++ b/tests/integration/targets/nutanix_floating_ips/tasks/create_floating_ips.yml @@ -40,6 +40,24 @@ - set_fact: todelete: "{{ todelete + [ result.fip_uuid ] }}" ########################################################## +- name: Delete Floating ip with check mode + ntnx_floating_ips: + state: absent + fip_uuid: "{{ result.fip_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Floating IP with uuid:{{ result.fip_uuid }} will be deleted." + - output.fip_uuid == "{{ result.fip_uuid }}" + fail_msg: "Floating IP been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete all created floating ips ntnx_floating_ips: state: absent diff --git a/tests/integration/targets/nutanix_pbrs/tasks/create_pbrs.yml b/tests/integration/targets/nutanix_pbrs/tasks/create_pbrs.yml index 8e2ffa0d9..460734286 100644 --- a/tests/integration/targets/nutanix_pbrs/tasks/create_pbrs.yml +++ b/tests/integration/targets/nutanix_pbrs/tasks/create_pbrs.yml @@ -243,6 +243,24 @@ - set_fact: todelete: "{{ todelete + [ result.pbr_uuid ] }}" ################################################################################################################## +- name: Delete Pbr with check mode + ntnx_pbrs: + state: absent + pbr_uuid: "{{ result.pbr_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Pbr with uuid:{{ result.pbr_uuid}} will be deleted." + - output.pbr_uuid == "{{ result.pbr_uuid }}" + fail_msg: "Pbr been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete all created pbrs ntnx_pbrs: state: absent diff --git a/tests/integration/targets/nutanix_subnets/tasks/delete_subnet.yml b/tests/integration/targets/nutanix_subnets/tasks/delete_subnet.yml index 3af69c07f..e1ab02d4a 100644 --- a/tests/integration/targets/nutanix_subnets/tasks/delete_subnet.yml +++ b/tests/integration/targets/nutanix_subnets/tasks/delete_subnet.yml @@ -29,7 +29,25 @@ - result.response.status.state == 'COMPLETE' fail_msg: " Unable to create Overlay Subnet with IP_pools and DHCP " success_msg: " Overlay Subnet with IP_pools and DHCP created successfully " - + +- name: Delete subnet with check mode + ntnx_subnets: + state: absent + subnet_uuid: "{{ result.subnet_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="Subnet with uuid:{{ result.subnet_uuid }} will be deleted." + - output.subnet_uuid == "{{ result.subnet_uuid }}" + fail_msg: "Subnet has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete subnet ntnx_subnets: state: absent diff --git a/tests/integration/targets/nutanix_vms/tasks/delete.yml b/tests/integration/targets/nutanix_vms/tasks/delete.yml index 527171727..a3a5629d8 100644 --- a/tests/integration/targets/nutanix_vms/tasks/delete.yml +++ b/tests/integration/targets/nutanix_vms/tasks/delete.yml @@ -15,7 +15,25 @@ - result.response.status.state == 'COMPLETE' fail_msg: ' Unable to create VM with minimum requiremnts ' success_msg: ' VM with minimum requiremnts created successfully ' - + +- name: Delete vm with check mode + ntnx_vms: + state: absent + vm_uuid: "{{ result.response.metadata.uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =='VM with uuid:{{ result.response.metadata.uuid }} will be deleted.' + - output.vm_uuid == '{{ result.response.metadata.uuid }}' + fail_msg: "vm has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete VM ntnx_vms: vm_uuid: '{{ result["response"]["metadata"]["uuid"] }}' diff --git a/tests/integration/targets/nutanix_vpcs/tasks/delete_vpc.yml b/tests/integration/targets/nutanix_vpcs/tasks/delete_vpc.yml index 7d0339fa6..b49e216cd 100644 --- a/tests/integration/targets/nutanix_vpcs/tasks/delete_vpc.yml +++ b/tests/integration/targets/nutanix_vpcs/tasks/delete_vpc.yml @@ -21,6 +21,24 @@ success_msg: " VPC with all specfactions created successfully " +- name: Delete vpc with check mode + ntnx_vpcs: + state: absent + vpc_uuid: "{{ result.vpc_uuid }}" + register: output + ignore_errors: true + check_mode: true + +- name: Creation Status + assert: + that: + - output.failed == false + - output.changed == false + - output.msg =="VPC with uuid:{{ result.vpc_uuid }} will be deleted." + - output.vpc_uuid == "{{ result.vpc_uuid }}" + fail_msg: "vpc has been deleted successfully within check_mode" + success_msg: "Returned As expected" + - name: Delete vpc ntnx_vpcs: state: absent From a0e00516cc1c05f271787c6e47749c93aef15f1b Mon Sep 17 00:00:00 2001 From: Alaa Bishtawi Date: Sun, 19 Nov 2023 13:08:46 +0200 Subject: [PATCH 5/7] black fix --- plugins/modules/ntnx_image_placement_policy.py | 4 +++- plugins/modules/ntnx_ndb_time_machine_clusters.py | 6 +++++- plugins/modules/ntnx_security_rules.py | 4 +++- plugins/modules/ntnx_service_groups.py | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/modules/ntnx_image_placement_policy.py b/plugins/modules/ntnx_image_placement_policy.py index b9ae1b2c2..dabd22b81 100644 --- a/plugins/modules/ntnx_image_placement_policy.py +++ b/plugins/modules/ntnx_image_placement_policy.py @@ -381,7 +381,9 @@ def delete_policy(module, result): if module.check_mode: result["policy_uuid"] = policy_uuid - result["msg"] = "Placement policy with uuid:{0} will be deleted.".format(policy_uuid) + result["msg"] = "Placement policy with uuid:{0} will be deleted.".format( + policy_uuid + ) return policy_obj = ImagePlacementPolicy(module) diff --git a/plugins/modules/ntnx_ndb_time_machine_clusters.py b/plugins/modules/ntnx_ndb_time_machine_clusters.py index 93f6dd714..b09f56e5c 100644 --- a/plugins/modules/ntnx_ndb_time_machine_clusters.py +++ b/plugins/modules/ntnx_ndb_time_machine_clusters.py @@ -309,7 +309,11 @@ def delete_data_access_instance(module, result): if module.check_mode: result["cluster_uuid"] = cluster_uuid result["time_machine_uuid"] = tm_uuid - result["msg"] = "Cluster with uuid:{0} will be deleted from Time Machine.".format(cluster_uuid) + result[ + "msg" + ] = "Cluster with uuid:{0} will be deleted from Time Machine.".format( + cluster_uuid + ) return resp = tm.delete_data_access_instance(tm_uuid, cluster_uuid) diff --git a/plugins/modules/ntnx_security_rules.py b/plugins/modules/ntnx_security_rules.py index 605d53529..5518360a5 100644 --- a/plugins/modules/ntnx_security_rules.py +++ b/plugins/modules/ntnx_security_rules.py @@ -1282,7 +1282,9 @@ def delete_security_rule(module, result): if module.check_mode: result["security_rule_uuid"] = security_rule_uuid - result["msg"] = "Security rule with uuid:{0} will be deleted.".format(security_rule_uuid) + result["msg"] = "Security rule with uuid:{0} will be deleted.".format( + security_rule_uuid + ) return security_rule = SecurityRule(module) diff --git a/plugins/modules/ntnx_service_groups.py b/plugins/modules/ntnx_service_groups.py index 02dc8c1bf..3563a4c9d 100644 --- a/plugins/modules/ntnx_service_groups.py +++ b/plugins/modules/ntnx_service_groups.py @@ -239,7 +239,9 @@ def delete_service_group(module, result): if module.check_mode: result["service_group_uuid"] = service_group_uuid - result["msg"] = "Service group with uuid:{0} will be deleted.".format(service_group_uuid) + result["msg"] = "Service group with uuid:{0} will be deleted.".format( + service_group_uuid + ) return service_group = ServiceGroup(module) From bfe533fd6036cdb1a9ac0e83e8e2d7760522c936 Mon Sep 17 00:00:00 2001 From: Gevorg-Khachatryaan Date: Tue, 21 Nov 2023 12:56:51 +0400 Subject: [PATCH 6/7] fix for check mode --- plugins/modules/ntnx_karbon_clusters_node_pools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/ntnx_karbon_clusters_node_pools.py b/plugins/modules/ntnx_karbon_clusters_node_pools.py index bddd93bf4..9da1d3757 100644 --- a/plugins/modules/ntnx_karbon_clusters_node_pools.py +++ b/plugins/modules/ntnx_karbon_clusters_node_pools.py @@ -320,14 +320,14 @@ def delete_pool(module, result): cluster_name = module.params["cluster_name"] pool_name = module.params["node_pool_name"] - delete_nodes_of_pool(module, result) - if module.check_mode: result["cluster_name"] = cluster_name result["node_pool_name"] = pool_name result["msg"] = "Pool with name:{0} will be deleted.".format(pool_name) return + delete_nodes_of_pool(module, result) + node_pool = NodePool(module, resource_type="/v1-beta.1/k8s/clusters") resp = node_pool.remove_node_pool(cluster_name, pool_name) From 69a39bf6f821d29ee5f61f117a57c4e32a9ae6f7 Mon Sep 17 00:00:00 2001 From: abhinavbansal29 Date: Mon, 23 Sep 2024 21:08:48 +0530 Subject: [PATCH 7/7] Added test for check_mode delete operation ntnx_foundation_central --- .../tasks/image_nodes.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/targets/ntnx_foundation_central/tasks/image_nodes.yml b/tests/integration/targets/ntnx_foundation_central/tasks/image_nodes.yml index 113c4d3a3..ccb49975b 100644 --- a/tests/integration/targets/ntnx_foundation_central/tasks/image_nodes.yml +++ b/tests/integration/targets/ntnx_foundation_central/tasks/image_nodes.yml @@ -53,3 +53,27 @@ fail_msg: "fail: Unable to image nodes or create cluster " success_msg: "succes: Imaging and cluster created successfully " # when: false # make it true or remove to unskip task + +- name: Store imaged cluster uuid + set_fact: + imaged_cluster_uuid: "{{result.imaged_cluster_uuid}}" + +- name: check mode for delete operation + ntnx_foundation_central: + state: absent + imaged_cluster_uuid: "{{imaged_cluster_uuid}}" + check_mode: true + register: result + ignore_errors: true + +- name: Creation Status + assert: + that: + - result.response is defined + - result.failed==false + - result.changed==false + - result.msg =="Cluster with uuid:{{imaged_cluster_uuid}} will be deleted." + - result.imaged_cluster_uuid == "{{imaged_cluster_uuid}}" + fail_msg: "fail: Unable to delete cluster " + success_msg: "succes: Cluster deleted successfully " + # when: false # make it true or remove to unskip task