diff --git a/plugins/modules/ntnx_acps.py b/plugins/modules/ntnx_acps.py index 04f1f1f56..d26b69e4b 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["msg"] = "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..4ba0d0950 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["msg"] = "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..a92324bef 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["msg"] = "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..367643561 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["msg"] = "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..c5535d6cd 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["msg"] = "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..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,6 +97,12 @@ 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["msg"] = "Image with name:{0} will be deleted.".format(fname) + return + resp = image.delete_image(fname, itype) result["changed"] = True diff --git a/plugins/modules/ntnx_image_placement_policy.py b/plugins/modules/ntnx_image_placement_policy.py index 087e7ea56..dabd22b81 100644 --- a/plugins/modules/ntnx_image_placement_policy.py +++ b/plugins/modules/ntnx_image_placement_policy.py @@ -379,8 +379,16 @@ 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["msg"] = "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..27d6f39ff 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["msg"] = "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..af2e58ec4 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["msg"] = "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..9da1d3757 100644 --- a/plugins/modules/ntnx_karbon_clusters_node_pools.py +++ b/plugins/modules/ntnx_karbon_clusters_node_pools.py @@ -320,6 +320,12 @@ def delete_pool(module, result): cluster_name = module.params["cluster_name"] pool_name = module.params["node_pool_name"] + 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") diff --git a/plugins/modules/ntnx_karbon_registries.py b/plugins/modules/ntnx_karbon_registries.py index 9be9f76cd..3c9cd7f88 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["msg"] = "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..aa55960fc 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["msg"] = "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..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) @@ -902,6 +904,7 @@ def delete_db_clone(module, result): if module.check_mode: result["response"] = spec + 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 b4720f672..9e795cae2 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["msg"] = "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..b41a16c70 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["msg"] = "Db server with uuid:{0} will be deleted.".format(uuid) + return + resp = db_servers.delete(uuid=uuid, data=spec) ops_uuid = resp["operationId"] @@ -1525,6 +1531,8 @@ def delete_instance(module, result): if module.check_mode: result["response"] = spec + result["uuid"] = 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 d8a57c320..ab2b889a4 100644 --- a/plugins/modules/ntnx_ndb_db_server_vms.py +++ b/plugins/modules/ntnx_ndb_db_server_vms.py @@ -685,6 +685,8 @@ def delete_db_server(module, result): if module.check_mode: result["response"] = spec + result["uuid"] = 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 5dbabbaa6..b12c472fb 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["msg"] = "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..52cb11b7d 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["msg"] = "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..311338157 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["msg"] = "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..31cc33764 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["msg"] = "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..3a816a249 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["msg"] = "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..fda78598d 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["msg"] = "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..b09f56e5c 100644 --- a/plugins/modules/ntnx_ndb_time_machine_clusters.py +++ b/plugins/modules/ntnx_ndb_time_machine_clusters.py @@ -305,8 +305,21 @@ 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[ + "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) + 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..d2df0f035 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["msg"] = "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..68f2a0b53 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["msg"] = "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..e8e631fcc 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["msg"] = "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..110cadb61 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["msg"] = "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..d6b9de2e9 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["msg"] = "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..6a5de9753 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["msg"] = "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..5518360a5 100644 --- a/plugins/modules/ntnx_security_rules.py +++ b/plugins/modules/ntnx_security_rules.py @@ -1280,6 +1280,13 @@ 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["msg"] = "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..3563a4c9d 100644 --- a/plugins/modules/ntnx_service_groups.py +++ b/plugins/modules/ntnx_service_groups.py @@ -237,6 +237,13 @@ 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["msg"] = "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..8a684298f 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["msg"] = "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..a15866876 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["msg"] = "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..a16995b9d 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["msg"] = "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..99d5cd0e9 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["msg"] = "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..5ac4f6a8d 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["msg"] = "VPC with uuid:{0} will be deleted.".format(vpc_uuid) + return + resp = vpc.delete(vpc_uuid) result["changed"] = True result["response"] = resp 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_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 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