This repository has been archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bennyz/add_proper_logs
Add a report about fail/successful VMs and templates
- Loading branch information
Showing
14 changed files
with
222 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,53 @@ | ||
# TODO: Add support for connect to multiple targets with the same LUN. | ||
# Every connect should be done using a different ip | ||
- name: Login to iSCSI targets | ||
ovirt_hosts: | ||
state: iscsilogin | ||
name: "{{ ovirt_hosts[0].name }}" | ||
auth: "{{ ovirt_auth }}" | ||
iscsi: | ||
username: "{{ iscsi_storage['dr_' + dr_target_host + '_username']|default('') }}" | ||
password: "{{ iscsi_storage['dr_' + dr_target_host + '_password']|default('') }}" | ||
address: "{{ iscsi_storage['dr_' + dr_target_host + '_address'] }}" | ||
target: "{{ dr_target }}" | ||
# Make port to be optional | ||
port: "{{ iscsi_storage['dr_' + dr_target_host + '_port']|default('3260'|int, true) }}" | ||
with_items: | ||
- "{{ iscsi_storage['dr_' + dr_target_host + '_target'] }}" | ||
loop_control: | ||
loop_var: dr_target | ||
- block: | ||
- name: Login to iSCSI targets | ||
ovirt_hosts: | ||
state: iscsilogin | ||
name: "{{ ovirt_hosts[0].name }}" | ||
auth: "{{ ovirt_auth }}" | ||
iscsi: | ||
username: "{{ iscsi_storage['dr_' + dr_target_host + '_username']|default('') }}" | ||
password: "{{ iscsi_storage['dr_' + dr_target_host + '_password']|default('') }}" | ||
address: "{{ iscsi_storage['dr_' + dr_target_host + '_address'] }}" | ||
target: "{{ dr_target }}" | ||
# Make port to be optional | ||
port: "{{ iscsi_storage['dr_' + dr_target_host + '_port']|default('3260'|int, true) }}" | ||
with_items: | ||
- "{{ iscsi_storage['dr_' + dr_target_host + '_target'] }}" | ||
loop_control: | ||
loop_var: dr_target | ||
|
||
- name: Import iSCSI storage domain | ||
ovirt_storage_domains: | ||
state: imported | ||
id: "{{ iscsi_storage['dr_domain_id'] }}" | ||
name: "{{ iscsi_storage['dr_' + dr_target_host + '_name']|default('') }}" | ||
host: "{{ ovirt_hosts[0].name }}" | ||
auth: "{{ ovirt_auth }}" | ||
data_center: "{{ iscsi_storage['dr_' + dr_target_host + '_dc_name'] }}" | ||
critical_space_action_blocker: "{{ iscsi_storage['dr_critical_space_action_blocker'] }}" | ||
warning_low_space: "{{ iscsi_storage['dr_warning_low_space'] }}" | ||
wipe_after_delete: "{{ iscsi_storage['dr_wipe_after_delete'] }}" | ||
discard_after_delete: "{{ iscsi_storage['dr_discard_after_delete'] }}" | ||
backup: "{{ iscsi_storage['dr_backup'] }}" | ||
# TODO: For import iSCSI there is no need for the iscsi parameters | ||
iscsi: | ||
username: "{{ iscsi_storage['dr_' + dr_target_host + '_username']|default('') }}" | ||
password: "{{ iscsi_storage['dr_' + dr_target_host + '_password']|default('') }}" | ||
address: "{{ iscsi_storage['dr_' + dr_target_host + '_address'] }}" | ||
# We use target since state imported in ovirt_storage_domains.py creates a storage domain | ||
# which calls login, therfore we must have a target althout the targets were already connected before. | ||
# Therefore passing the first target in the list as a transient target. | ||
target: "{{ dr_target }}" | ||
with_items: | ||
- "{{ iscsi_storage['dr_' + dr_target_host + '_target'] }}" | ||
loop_control: | ||
loop_var: dr_target | ||
- name: Import iSCSI storage domain | ||
ovirt_storage_domains: | ||
state: imported | ||
id: "{{ iscsi_storage['dr_domain_id'] }}" | ||
name: "{{ iscsi_storage['dr_' + dr_target_host + '_name']|default('') }}" | ||
host: "{{ ovirt_hosts[0].name }}" | ||
auth: "{{ ovirt_auth }}" | ||
data_center: "{{ iscsi_storage['dr_' + dr_target_host + '_dc_name'] }}" | ||
critical_space_action_blocker: "{{ iscsi_storage['dr_critical_space_action_blocker'] }}" | ||
warning_low_space: "{{ iscsi_storage['dr_warning_low_space'] }}" | ||
wipe_after_delete: "{{ iscsi_storage['dr_wipe_after_delete'] }}" | ||
discard_after_delete: "{{ iscsi_storage['dr_discard_after_delete'] }}" | ||
backup: "{{ iscsi_storage['dr_backup'] }}" | ||
# TODO: For import iSCSI there is no need for the iscsi parameters | ||
iscsi: | ||
username: "{{ iscsi_storage['dr_' + dr_target_host + '_username']|default('') }}" | ||
password: "{{ iscsi_storage['dr_' + dr_target_host + '_password']|default('') }}" | ||
address: "{{ iscsi_storage['dr_' + dr_target_host + '_address'] }}" | ||
# We use target since state imported in ovirt_storage_domains.py creates a storage domain | ||
# which calls login, therfore we must have a target althout the targets were already connected before. | ||
# Therefore passing the first target in the list as a transient target. | ||
target: "{{ dr_target }}" | ||
with_items: | ||
- "{{ iscsi_storage['dr_' + dr_target_host + '_target'] }}" | ||
loop_control: | ||
loop_var: dr_target | ||
- name: Log append to succeed_storage_domains | ||
set_fact: | ||
succeed_storage_domains: "{{ succeed_storage_domains }} + [ \"{{ iscsi_storage['dr_' + dr_target_host + '_name']|default('') }}\" ]" | ||
rescue: | ||
- name: Log append to failed_storage_domains | ||
set_fact: | ||
failed_storage_domains: "{{ failed_storage_domains }} + [ \"{{ iscsi_storage['dr_' + dr_target_host + '_name']|default('') }}\" ]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
- name: Add NFS storage domain | ||
ovirt_storage_domains: | ||
name: "{{ nfs_storage['dr_' + dr_target_host + '_name'] }}" | ||
critical_space_action_blocker: "{{ nfs_storage['dr_critical_space_action_blocker'] }}" | ||
warning_low_space: "{{ nfs_storage['dr_warning_low_space'] }}" | ||
wipe_after_delete: "{{ nfs_storage['dr_wipe_after_delete'] }}" | ||
backup: "{{ nfs_storage['dr_backup'] }}" | ||
host: "{{ ovirt_hosts[0].name }}" | ||
data_center: "{{ nfs_storage['dr_' + dr_target_host + '_dc_name'] }}" | ||
auth: "{{ ovirt_auth }}" | ||
nfs: | ||
path: "{{ nfs_storage['dr_' + dr_target_host + '_path'] }}" | ||
address: "{{ nfs_storage['dr_' + dr_target_host + '_address'] }}" | ||
- block: | ||
- name: Add NFS storage domain | ||
ovirt_storage_domains: | ||
name: "{{ nfs_storage['dr_' + dr_target_host + '_name'] }}" | ||
critical_space_action_blocker: "{{ nfs_storage['dr_critical_space_action_blocker'] }}" | ||
wipe_after_delete: "{{ nfs_storage['dr_wipe_after_delete'] }}" | ||
backup: "{{ nfs_storage['dr_backup'] }}" | ||
host: "{{ ovirt_hosts[0].name }}" | ||
data_center: "{{ nfs_storage['dr_' + dr_target_host + '_dc_name'] }}" | ||
auth: "{{ ovirt_auth }}" | ||
nfs: | ||
path: "{{ nfs_storage['dr_' + dr_target_host + '_path'] }}" | ||
address: "{{ nfs_storage['dr_' + dr_target_host + '_address'] }}" | ||
- name: Log append to failed storage domains | ||
set_fact: | ||
succeed_storage_domains: "{{ succeed_storage_domains }} + [ \"{{ nfs_storage['dr_' + dr_target_host + '_name'] }}\" ]" | ||
|
||
rescue: | ||
- name: Log append to failed_storage_domains | ||
set_fact: | ||
failed_storage_domains: "{{ failed_storage_domains }} + [ \"{{ nfs_storage['dr_' + dr_target_host + '_name'] }}\" ]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- name: | ||
template: | ||
src: report_log_template.j2 | ||
dest: files/{{ dr_report_file }} | ||
|
||
- name: Print report | ||
shell: cat files/{{ dr_report_file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Register unregistered Template | ||
ovirt_templates: | ||
state: registered | ||
storage_domain: "{{ storage.name }}" | ||
id: "{{ unreg_template.id }}" | ||
allow_partial_import: "{{ dr_partial_import }}" | ||
auth: "{{ ovirt_auth }}" | ||
cluster_mappings: "{{ dr_cluster_map }}" | ||
domain_mappings: "{{ dr_domain_map }}" | ||
vnic_profile_mappings: "{{ dr_network_map }}" | ||
role_mappings: "{{ dr_role_map }}" | ||
register: template_register_result | ||
|
||
- name: Log append failed Template to issues failed_template_names | ||
set_fact: | ||
failed_template_names: "{{ failed_template_names }} + [ '{{ unreg_template.name }}' ]" | ||
when: template_register_result | failed | ||
|
||
- name: Log append succeed_template_names | ||
set_fact: | ||
succeed_template_names: "{{ succeed_template_names }} + [ '{{ unreg_template.name }}' ]" | ||
when: template_register_result | succeeded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
- block: | ||
- name: register VMs | ||
ovirt_vms: | ||
state: registered | ||
storage_domain: "{{ storage.name }}" | ||
id: "{{ unreg_vm.id }}" | ||
auth: "{{ ovirt_auth }}" | ||
allow_partial_import: "{{ dr_partial_import }}" | ||
cluster_mappings: "{{ dr_cluster_map }}" | ||
domain_mappings: "{{ dr_domain_map }}" | ||
role_mappings: "{{ dr_role_map }}" | ||
affinity_group_mappings: "{{ dr_affinity_group_map }}" | ||
affinity_label_mappings: "{{ dr_affinity_label_map }}" | ||
vnic_profile_mappings: "{{ dr_network_map }}" | ||
lun_mappings: "{{ dr_lun_map }}" | ||
reassign_bad_macs: "{{ dr_reset_mac_pool }}" | ||
register: vm_register_result | ||
- name: Log append failed VM to failed_vm_names | ||
set_fact: | ||
failed_vm_names: "{{ failed_vm_names }} + [ '{{ unreg_vm.name }}' ]" | ||
when: vm_register_result | failed | ||
|
||
- name: Log append succeed_vm_names | ||
set_fact: | ||
succeed_vm_names: "{{ succeed_vm_names }} + [ '{{ unreg_vm.name }}' ]" | ||
when: vm_register_result | succeeded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% if succeed_vm_names | length > 0 %} | ||
The following VMs registered successfully: {{ succeed_vm_names | unique | join (", ") }} | ||
{% endif %} | ||
{% if failed_vm_names | length > 0 %} | ||
The following VMs failed to be registered: {{ failed_vm_names | unique | join (", ") }} | ||
{% endif %} | ||
{% if succeed_template_names | length > 0 %} | ||
The following Templates registered successfully: {{ succeed_template_names | unique | join (", ") }} | ||
{% endif %} | ||
{% if failed_template_names | length > 0 %} | ||
The following Templates failed to be registered: {{ failed_template_names | unique | join (", ") }} | ||
{% endif %} | ||
{% if succeed_to_run_vms | length > 0 %} | ||
The following VMs started successfully: {{ succeed_to_run_vms | unique | join (", ") }} | ||
{% endif %} | ||
{% if failed_to_run_vms | length > 0 %} | ||
The following VMs failed to run: {{ failed_to_run_vms | unique | join (", ") }} | ||
{% endif %} | ||
{% if succeed_storage_domains | length > 0 %} | ||
The following storage domains were successfully added: {{ succeed_storage_domains | unique | join (", ") }} | ||
{% endif %} | ||
{% if failed_storage_domains | length > 0 %} | ||
The following storage domains were not added: {{ failed_storage_domains | unique | join (", ") }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters