2017-12-10 16:55:55 +01:00
|
|
|
# Test code for the vmware_datastore_facts module.
|
2018-02-26 08:53:22 +01:00
|
|
|
# Copyright (c) 2017, Tim Rightnour <thegarbledone@gmail.com>
|
|
|
|
# Copyright (c) 2018, Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2017-12-10 16:55:55 +01:00
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
|
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
|
|
|
vars:
|
|
|
|
setup_attach_host: true
|
|
|
|
setup_datastore: true
|
|
|
|
|
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- name: get list of facts about datastores from the ESXi
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-05-16 15:36:48 +02:00
|
|
|
hostname: '{{ item }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-04-30 12:22:50 +02:00
|
|
|
register: facts_from_esxi
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ esxi_hosts }}"
|
2019-04-30 12:22:50 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "facts_from_esxi.results[0].datastores|length == 2"
|
|
|
|
|
2017-12-10 16:55:55 +01:00
|
|
|
- name: get list of facts about datastores
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
|
|
|
gather_nfs_mount_info: true
|
|
|
|
register: facts_from_vcenter_with_dc_filter
|
|
|
|
|
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- name: get list of facts about datastores
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
gather_nfs_mount_info: true
|
|
|
|
register: facts_from_vcenter_with_no_filter
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "facts_from_vcenter_with_dc_filter.datastores|length == 2"
|
|
|
|
- "facts_from_vcenter_with_no_filter.datastores|length == 2"
|
|
|
|
- "facts_from_vcenter_with_no_filter.datastores[0]['capacity'] is defined"
|
2017-12-10 16:55:55 +01:00
|
|
|
|
|
|
|
# Testcase 0002: Get a full list of datastores in a cluster
|
|
|
|
- name: get list of facts about datastores - no dc
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
cluster: "{{ ccr1 }}"
|
2017-12-10 16:55:55 +01:00
|
|
|
register: datastore_facts_0002
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: "{{ datastore_facts_0002 }}"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "datastore_facts_0002['datastores'][0]['capacity'] is defined"
|
|
|
|
|
|
|
|
# Testcase 0003: Find a specific datastore
|
|
|
|
- name: get list of facts about one datastore
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
|
|
|
name: "{{ ds1 }}"
|
2017-12-10 16:55:55 +01:00
|
|
|
register: datastore_facts_0003
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: "{{ datastore_facts_0003 }}"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-04-30 12:22:50 +02:00
|
|
|
- "datastore_facts_0003['datastores'][0]['name'] == ds1"
|
2017-12-10 16:55:55 +01:00
|
|
|
- "datastore_facts_0003['datastores'][0]['capacity'] is defined"
|
2018-10-11 12:22:30 +02:00
|
|
|
|
|
|
|
- name: get list of extended facts about one datastore
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
2018-10-11 12:22:30 +02:00
|
|
|
name: "{{ ds1 | basename }}"
|
|
|
|
gather_nfs_mount_info: True
|
|
|
|
gather_vmfs_mount_info: True
|
|
|
|
register: datastore_facts_0004
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: "{{ datastore_facts_0004 }}"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-04-30 12:22:50 +02:00
|
|
|
- "datastore_facts_0004['datastores'][0]['name'] == ds1"
|
2018-10-11 12:22:30 +02:00
|
|
|
- "datastore_facts_0004['datastores'][0]['capacity'] is defined"
|
|
|
|
|
|
|
|
- name: get list of facts about one datastore in check mode
|
|
|
|
vmware_datastore_facts:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
2018-10-11 12:22:30 +02:00
|
|
|
name: "{{ ds1 | basename }}"
|
|
|
|
register: datastore_facts_0005
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: "{{ datastore_facts_0005 }}"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-04-30 12:22:50 +02:00
|
|
|
- "datastore_facts_0005['datastores'][0]['name'] == ds1"
|
2018-10-11 12:22:30 +02:00
|
|
|
- "datastore_facts_0005['datastores'][0]['capacity'] is defined"
|