From cf34cefbdc516f5dbbf85b4caecb905f9a255858 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 19 Jul 2017 16:13:51 +0530 Subject: [PATCH] Add FindByUUID testcase for vmware_guest_facts (#27022) Signed-off-by: Abhijeet Kasurde --- .../cloud/vmware/vmware_guest_facts.py | 1 - .../targets/vmware_guest_facts/tasks/main.yml | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py index d067e95d7af..3a04c33b8ba 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py @@ -173,7 +173,6 @@ def main(): folder=dict(required=False, type='str', default='/vm'), datacenter=dict(required=True, type='str'), ), - required_together=[('name', 'folder')], required_one_of=[['name', 'uuid']], ) diff --git a/test/integration/targets/vmware_guest_facts/tasks/main.yml b/test/integration/targets/vmware_guest_facts/tasks/main.yml index b79f9e5b0ae..22196a7a906 100644 --- a/test/integration/targets/vmware_guest_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_facts/tasks/main.yml @@ -80,3 +80,26 @@ that: - "guest_facts_0001['instance']['hw_name'] == vm1 | basename" - "guest_facts_0001['instance']['hw_product_uuid'] is defined" + +- set_fact: vm1_uuid="{{ guest_facts_0001['instance']['hw_product_uuid'] }}" + +- debug: var=vm1_uuid + +# Testcase 0002: Get details about virtual machines using UUID +- name: get list of facts about virtual machines using UUID + vmware_guest_facts: + validate_certs: False + hostname: "{{ vcsim }}" + username: "{{ vcsim_instance['json']['username'] }}" + password: "{{ vcsim_instance['json']['password'] }}" + datacenter: "{{ dc1 | basename }}" + uuid: "{{ vm1_uuid }}" + register: guest_facts_0002 + +- debug: msg="{{ guest_facts_0002 }}" + +- assert: + that: + - "guest_facts_0002['instance']['hw_name'] == vm1 | basename" + - "guest_facts_0002['instance']['hw_product_uuid'] is defined" + - "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"