mirror of https://github.com/ansible/ansible.git
VMware: Modifying Rest Client to use vSphere-Api-Client instead of individual service(#55804)
* Same api client can be used for other service as well * Incorporated Review comments. Modified Category and Guest Fact modules which are also dependent on vmware_rest_client module util * Adding Integration Tests for vmware_rest_client changes * Changes to incroporate changes in vcsim testware * Change to get vm name to attach the tagpull/56268/head
parent
0bead3672f
commit
34a8594c91
@ -0,0 +1,2 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
@ -0,0 +1,6 @@
|
||||
# Test code for the vmware_tag Operations.
|
||||
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- include: tag_crud_ops.yml
|
||||
- include: tag_manager_ops.yml
|
@ -0,0 +1,78 @@
|
||||
# Test code for the vmware_tag CRUD Operations.
|
||||
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
|
||||
# Testcase Create Category
|
||||
- name: Create Category
|
||||
vmware_category:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: False
|
||||
category_name: Sample_Cat_0006
|
||||
category_description: Sample Description
|
||||
category_cardinality: 'multiple'
|
||||
state: present
|
||||
register: category_create
|
||||
|
||||
- name: Check Category is created
|
||||
assert:
|
||||
that:
|
||||
- category_create.changed
|
||||
|
||||
- name: Set Cat_ID Paramter. Required for Tag creation
|
||||
set_fact: Cat_ID={{ category_create['category_results']['category_id'] }}
|
||||
|
||||
# Testcase Create Tag
|
||||
- name: Create a tag
|
||||
vmware_tag:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: no
|
||||
tag_name: Sample_Tag_0001
|
||||
category_id: "{{ Cat_ID }}"
|
||||
tag_description: Sample Description
|
||||
state: present
|
||||
register: tag_creation
|
||||
|
||||
- name: Check tag is created
|
||||
assert:
|
||||
that:
|
||||
- tag_creation.changed
|
||||
|
||||
# Testcase Update Tag Description (reconfig)
|
||||
- name: Update Tag Description
|
||||
vmware_tag:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: no
|
||||
tag_name: Sample_Tag_0001
|
||||
tag_description: Some fancy description
|
||||
state: present
|
||||
register: update_tag_desc
|
||||
|
||||
- name: Check tag description updated
|
||||
assert:
|
||||
that:
|
||||
- update_tag_desc.changed
|
||||
|
||||
# Testcase Delete the Tag
|
||||
- name: Delete Tag
|
||||
vmware_tag:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: no
|
||||
tag_name: Sample_Tag_0001
|
||||
state: absent
|
||||
register: delete_tag
|
||||
|
||||
- name: Check Tag is Deleted
|
||||
assert:
|
||||
that:
|
||||
- delete_tag.changed
|
@ -0,0 +1,49 @@
|
||||
# Test code for the vmware_tag Manager Operations.
|
||||
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
|
||||
# Get VM name to attach the tag
|
||||
- name: Get VM Facts
|
||||
vmware_vm_facts:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: False
|
||||
register: vm_facts
|
||||
|
||||
- set_fact: vm_name="{{ vm_facts['virtual_machines'][0]['guest_name'] }}"
|
||||
|
||||
# Get Tagname
|
||||
- name: Get facts about tag
|
||||
vmware_tag_facts:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: False
|
||||
register: tag_facts
|
||||
|
||||
- set_fact: Tag_Name={{ tag_facts['tag_facts'].keys() | list }}
|
||||
|
||||
- debug: var=Tag_Name
|
||||
|
||||
# Testcase Assign tag to virtual Machine
|
||||
- name: Add tags to a virtual machine
|
||||
vmware_tag_manager:
|
||||
hostname: '{{ vcenter_hostname }}'
|
||||
username: '{{ vcenter_username }}'
|
||||
password: '{{ vcenter_password }}'
|
||||
validate_certs: no
|
||||
tag_names:
|
||||
- "{{ Tag_Name[0] }}"
|
||||
object_name: "{{ vm_name }}"
|
||||
object_type: VirtualMachine
|
||||
state: add
|
||||
register: tag_manager_ops
|
||||
|
||||
- name: Check Category is created
|
||||
assert:
|
||||
that:
|
||||
- tag_manager_ops.changed"
|
Loading…
Reference in New Issue