I am looking for a way to a get a dict of all the non-root volumes that has zero luns but they are online ? is it possible to have an ansible task do this ? I can search how many LUNs inside of a volume with luns.ontap_info.storage_luns.records but there are no information regarding LUNs from volumes.ontap_info.storage_volumes.records
#How can I find all empty volumes ?
1 messages · Page 1 of 1 (latest)
You could generate a list of volumes from the LUN info and compare against all existing volumes. See https://docs.ansible.com/ansible/latest/collections/ansible/builtin/difference_filter.html
thank you, is there another way, or through CLI ?
What I am trying to do is get the list of volumes that has less than 7 LUNs. But since I generate the volume list based on the number of LUNs it does not take into account the volumes that has zero LUNs. If I use the difference filter, it will also give me those more than 7. Here is my code for more visibility
` - name: Get LUNS info
netapp.ontap.na_ontap_rest_info:
gather_subset: storage/luns
use_python_keys: true
hal_linking: false
fields:
- location
register: luns
- name: Get all non-root volumes from clusters
netapp.ontap.na_ontap_rest_info:
gather_subset:
- "storage/volumes"
fields:
- "*"
parameters:
is_svm_root: false
use_python_keys: true
hal_linking: false
register: volumes
- name: Check LUNs Number in all volumes with same type
ansible.builtin.set_fact:
count_lun: "{{ count_lun | default({}) | combine({item.name: (luns.ontap_info.storage_luns.records | selectattr('location.volume.name', 'equalto', item.name) | length )}) }}"
vol_type: "{{ cluster_id }}_{{ db_type }}_{{ infra_type }}{{ oracle_cluster_id }}_{{ data_type }}"
loop: "{{ volumes.ontap_info.storage_volumes.records }}"
when: ( luns.ontap_info.storage_luns.num_records | int > 0) and (volumes.ontap_info.storage_volumes.num_records | int > 0)
register: lun_volume_find
- name: Search Volume
when: (volumes.ontap_info.storage_volumes.num_records | int != 0)
block:
- name: Choose an existing volume matching LUN type
ansible.builtin.set_fact:
volume_chosen_list: "{{ volume_chosen_list | default([]) + [ item.key ] }}"
with_items: "{{ count_lun | dict2items }}"
when:
- item.value < 5
- item.key | regex_search('(.*' + vol_type + '.*)')
register: volume_find`
count_lun already contains volumes with 0 LUNs. You look at the wrong things.