VMware: New module vmware_vm_host_drs_rule (#50651)

* Added new vmware module for creating DRS VM-HOST rules Host groups in a given cluster
* Fixing punctuation in lib/ansible/modules/cloud/vmware/vmware_vm_host_drs_rule.py
* Added better Docstring
* Better messaging and documentation. Removed unused lib
* Added operation to determine create or update msg
* Fixed class params to only take module. This is less error prone
* Bugfix, undefined names
This commit is contained in:
Karsten Jakobsen
2019-01-28 06:15:45 +01:00
committed by Abhijeet Kasurde
parent be859a9f8e
commit 99a4a3dc33
3 changed files with 541 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
cloud/vcenter
unsupported

View File

@@ -0,0 +1,79 @@
# Test code for the vmware_vm_vm_drs_rule module.
# Copyright: (c) 2017, Karsten Kaj Jakobsen <kj@patientsky.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# TODO: vcsim does not support manage DRS rule
- name: Store the vcenter container ip
set_fact:
vcsim: "{{ lookup('env', 'vcenter_host') }}"
- debug: var=vcsim
- name: Wait for flask server
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: Kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: Start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=2&cluster=1&folder=0&ds=2&pool=2
register: vcsim_instance
- name: Wait for vcsim server
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
# TODO: create host/vm group when vcsim supports this
- name: Create mandatory DRS Affinity rule for VM/Host
vmware_vm_host_drs_rule:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_host_aff_0001
vm_group_name: DC0_C0_VM_GR1
host_group_name: DC0_C0_HOST_GR1
cluster_name: DC0_C0
enabled: True
affinity_rule: True
mandatory: True
register: drs_rule_host_0001_results
- debug: var=drs_rule_host_0001_results
- assert:
that:
- "{{ drs_rule_host_0001_results.changed }}"
# TODO: create host/vm group when vcsim supports this
- name: Create non-mandatory DRS Anti-Affinity rule for VM/Host
vmware_vm_host_drs_rule:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
drs_rule_name: drs_rule_host_aff_0001
vm_group_name: DC0_C0_VM_GR1
host_group_name: DC0_C0_HOST_GR2
cluster_name: DC0_C0
enabled: True
affinity_rule: False
mandatory: False
register: drs_rule_host_0002_results
- debug: var=drs_rule_host_0002_results
- assert:
that:
- "{{ drs_rule_host_0001_results.changed }}"