Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Add use_maintenance_policy parameter
Browse files Browse the repository at this point in the history
This patch add new use_maintenance_policy parameter to handle if the
cluster policy should be switched to cluster_maintenance during upgrade
or if the policy should be unchanged.

Change-Id: I0ec567283282575d0e90bd00a96de5172db0dde9
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1539761
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Feb 13, 2018
1 parent 42386f6 commit 948ecd8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ upgrade_timeout: 1200
cluster_name: Default
check_upgrade: false
reboot_after_upgrade: true
use_maintenance_policy: true
host_statuses:
- up
host_names:
Expand Down
32 changes: 32 additions & 0 deletions tasks/cluster_policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- name: Get cluster facts
ovirt_clusters_facts:
auth: "{{ ovirt_auth }}"
pattern: "name={{ cluster_name }}"
check_mode: "no"

- name: Get name of the original scheduling policy
ovirt_scheduling_policies_facts:
auth: "{{ ovirt_auth }}"
id: "{{ ovirt_clusters[0].scheduling_policy.id }}"
check_mode: "no"

- name: Remember the cluster scheduling policy
set_fact:
cluster_scheduling_policy: "{{ ovirt_scheduling_policies[0].name }}"

- name: Get API facts
# TODO: Change when Ansible 2.5 is released:
# ovirt_api_facts:
ovirt_api_facts_internal_25:
auth: "{{ ovirt_auth }}"
check_mode: "no"

- name: Set in cluster upgrade policy
ovirt_clusters:
auth: "{{ ovirt_auth }}"
name: "{{ cluster_name }}"
scheduling_policy: cluster_maintenance
register: cluster_policy
when:
- (ovirt_api.product_info.version.major >= 4 and ovirt_api.product_info.version.major >= 2) or
(ovirt_api.product_info.version.major == 4 and ovirt_api.product_info.version.major == 1 and ovirt_api.product_info.version.revision >= 4)
36 changes: 3 additions & 33 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,15 @@
when: ovirt_hosts | length == 0

- block:
- name: Get cluster facts
ovirt_clusters_facts:
auth: "{{ ovirt_auth }}"
pattern: "name={{ cluster_name }}"
check_mode: "no"

- name: Get name of the original scheduling policy
ovirt_scheduling_policies_facts:
auth: "{{ ovirt_auth }}"
id: "{{ ovirt_clusters[0].scheduling_policy.id }}"
check_mode: "no"

- name: Remember the cluster scheduling policy
set_fact:
cluster_scheduling_policy: "{{ ovirt_scheduling_policies[0].name }}"
- include: cluster_policy.yml
when: use_maintenance_policy

- name: Get list of VMs in cluster
ovirt_vms_facts:
auth: "{{ ovirt_auth }}"
pattern: "cluster={{ cluster_name }}"
check_mode: "no"

- name: Get API facts
# TODO: Change when Ansible 2.5 is released:
# ovirt_api_facts:
ovirt_api_facts_internal_25:
auth: "{{ ovirt_auth }}"
check_mode: "no"

- name: Set in cluster upgrade policy
ovirt_clusters:
auth: "{{ ovirt_auth }}"
name: "{{ cluster_name }}"
scheduling_policy: cluster_maintenance
register: cluster_policy
when:
- (ovirt_api.product_info.version.major >= 4 and ovirt_api.product_info.version.major >= 2) or
(ovirt_api.product_info.version.major == 4 and ovirt_api.product_info.version.major == 1 and ovirt_api.product_info.version.revision >= 4)

- name: Shutdown VMs which can be stopped
ovirt_vms:
auth: "{{ ovirt_auth }}"
Expand Down Expand Up @@ -104,7 +74,7 @@
auth: "{{ ovirt_auth }}"
name: "{{ cluster_name }}"
scheduling_policy: "{{ cluster_scheduling_policy }}"
when: cluster_policy.changed | default(false)
when: use_maintenance_policy and cluster_policy.changed | default(false)

- name: Start again stopped VMs
ovirt_vms:
Expand Down

0 comments on commit 948ecd8

Please sign in to comment.