From 73e846b3671b35e8a7197e9f5d15b7ddaa7bc894 Mon Sep 17 00:00:00 2001 From: Pradeepsingh Bhati Date: Wed, 25 Oct 2023 15:47:55 +0530 Subject: [PATCH] Add cluster URL to response only when there is cluster creation (#402) * Create cluster url when it is required * Minor fix --- plugins/modules/ntnx_foundation.py | 4 +- .../tasks/image_nodes.yml | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/plugins/modules/ntnx_foundation.py b/plugins/modules/ntnx_foundation.py index 9b2abd41e..f5b7a3d15 100644 --- a/plugins/modules/ntnx_foundation.py +++ b/plugins/modules/ntnx_foundation.py @@ -15,7 +15,7 @@ description: 'Nutanix module to image nodes and optionally create clusters' options: hypervisor_nameserver: - description: to-write + description: name server for hypervisors type: str required: false cvm_gateway: @@ -1244,7 +1244,7 @@ def image_nodes(module, result): # add cluster urls if any cluster created cluster_urls = [] - if spec["clusters"]: + if spec.get("clusters"): for cluster in spec["clusters"]: cluster_urls.append( { diff --git a/tests/integration/targets/ntnx_foundation_sanity/tasks/image_nodes.yml b/tests/integration/targets/ntnx_foundation_sanity/tasks/image_nodes.yml index 49e4b651b..5705fb3a1 100644 --- a/tests/integration/targets/ntnx_foundation_sanity/tasks/image_nodes.yml +++ b/tests/integration/targets/ntnx_foundation_sanity/tasks/image_nodes.yml @@ -116,6 +116,43 @@ fail_msg: " Fail : unable to create spec for imaging nodes" success_msg: "Succes: spec generated successfully" + - name: Image nodes without cluster creation + ntnx_foundation: + timeout: 4500 + cvm_gateway: "{{cvm_gateway}}" + cvm_netmask: "{{cvm_netmask}}" + hypervisor_gateway: "{{hypervisor_gateway}}" + hypervisor_netmask: "{{hypervisor_netmask}}" + default_ipmi_user: "{{default_ipmi_user}}" + current_cvm_vlan_tag: "{{nodes.current_cvm_vlan_tag}}" + nos_package: "{{images.aos_packages[0]}}" + blocks: + - block_id: "{{nodes.block_id}}" + nodes: + - manual_mode: + cvm_ip: "{{nodes.node2.cvm_ip}}" + cvm_gb_ram: 50 + hypervisor_hostname: "{{nodes.node2.hypervisor_hostname}}" + ipmi_netmask: "{{nodes.node2.ipmi_netmask}}" + ipmi_gateway: "{{nodes.node2.ipmi_gateway}}" + ipmi_ip: "{{nodes.node2.ipmi_ip}}" + ipmi_password: "{{nodes.node2.ipmi_password}}" + hypervisor: "{{nodes.node2.hypervisor}}" + hypervisor_ip: "{{nodes.node2.hypervisor_ip}}" + node_position: "{{nodes.node2.node_position}}" + register: result + no_log: true + ignore_errors: True + + - name: Creation Status + assert: + that: + - result.response is defined + - result.failed==false + - result.changed==true + fail_msg: " Fail : unable to image nodes" + success_msg: "Succes: node imaging done successfully" + - name: Image nodes and create cluster out of it ntnx_foundation: timeout: 4500