Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mm bugfix/drs threshold backwards #73

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/73-fix_drs_backwards_vmotion_rate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- cluster_drs - fixed backwards vMotion rate (input 1 set rate to 5 in vCenter) (https://github.com/ansible-collections/vmware.vmware/issues/68)
11 changes: 10 additions & 1 deletion plugins/modules/cluster_drs.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
self.cluster = self.get_cluster_by_name(self.params.get('cluster'), fail_on_missing=True, datacenter=datacenter)

self.enable_drs = self.params.get('enable')
self.drs_vmotion_rate = self.params.get('drs_vmotion_rate')
self.drs_enable_vm_behavior_overrides = self.params.get('drs_enable_vm_behavior_overrides')
self.drs_default_vm_behavior = self.params.get('drs_default_vm_behavior')
self.predictive_drs = self.params.get('predictive_drs')
Expand All @@ -168,6 +167,16 @@
self.cluster.configurationEx.drsConfig.option
)

@property
def drs_vmotion_rate(self):
mikemorency marked this conversation as resolved.
Show resolved Hide resolved
"""
When applying or reading this rate from the vCenter config, the values are reversed. So
for example, vCenter thinks 1 is the most aggressive when docs/UI say 5 is most aggressive.
We present the scale seen in the docs/UI to the user and then adjust the value here to ensure
vCenter behaves as intended.
"""
return 6 - self.params.get('drs_vmotion_rate')

Check warning on line 178 in plugins/modules/cluster_drs.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/cluster_drs.py#L178

Added line #L178 was not covered by tests

def check_drs_config_diff(self):
"""
Check the active DRS configuration and determine if desired configuration is different.
Expand Down
21 changes: 20 additions & 1 deletion tests/integration/targets/vmware_cluster_drs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
advanced_settings: "{{ drs_advanced_settings }}"
predictive_drs: "{{ drs_predictive_drs }}"
register: _out
- name: Set DRS Settings In Test Cluster Again - Idempotence
vmware.vmware.cluster_drs:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }}"
cluster: "{{ test_cluster }}"
port: "{{ vcenter_port }}"
drs_enable_vm_behavior_overrides: "{{ drs_enable_vm_behavior_overrides}}"
drs_default_vm_behavior: "{{ drs_default_vm_behavior }}"
drs_vmotion_rate: "{{ drs_vmotion_rate }}"
advanced_settings: "{{ drs_advanced_settings }}"
predictive_drs: "{{ drs_predictive_drs }}"
register: _idempotence_check
- name: Gather Cluster Settings
community.vmware.vmware_cluster_info:
validate_certs: false
Expand All @@ -59,12 +74,16 @@
cluster_name: "{{ test_cluster }}"
port: "{{ vcenter_port }}"
register: _cluster_info
# drs vmotion rate reported by vcenter api is backwards. So 1 is actually 5 in the UI
# and 5 is actually 1 in the UI. When we migrate cluster_info there is a ticket to fix the output
# so the number we return to the user makes sense, but for now we will fix it here with (6 - <user_input>)
- name: Check DRS Settings Were Applied
ansible.builtin.assert:
that:
- _idempotence_check is not changed
- _config.drs_default_vm_behavior == drs_default_vm_behavior
- _config.drs_enable_vm_behavior_overrides == drs_enable_vm_behavior_overrides
- _config.drs_vmotion_rate == drs_vmotion_rate
- _config.drs_vmotion_rate == (6 - drs_vmotion_rate)
- _config.enabled_drs == drs_enable
vars:
_config: "{{ _cluster_info.clusters[test_cluster] }}"
Expand Down
Loading