#Hi please confirm on below one I see in

1 messages · Page 1 of 1 (latest)

vital oriole
#

Yes, it should work with something like "lag_time": "PT8H35M42S",

You can find the documentation at:
https://github.com/ansible-collections/netapp.ontap/blob/main/plugins/filter/na_filter_iso8601_duration_to_seconds.yml

(It was not properly processed by the Ansible web site. We'll look into it).

GitHub

Ansible collection to support NetApp ONTAP configuration. - netapp.ontap/na_filter_iso8601_duration_to_seconds.yml at main · ansible-collections/netapp.ontap

prime knoll
#

Do I have to add na_filter_iso8601.py filer file and add content of na_filter_iso8601_duration_to_seconds.yml ?

vital oriole
#

In your playbook, you would just use the filter. | pipes the contents into the filter, and iso8601_duration_to_seconds is the name of the filter.
So the example shows: "{{ iso_duration | iso8601_duration_to_seconds }}"

where iso_duration is any variable that contains a duration in the ISO8601 format. This will evaluates to second.

#

If the plugin is not recognized, you will need to manually add the path to the filter directory in filter_plugins.

vital oriole
#

Or I wonder if ```
"{{ iso_duration | netapp.ontap.iso8601_duration_to_seconds }}"

prime knoll
#

i have added na_filter_iso8601.py in filter_plugins but seems like there small issue so i am getting lag_time: null

#

Here my playbook:

#

  • hosts: localhost
    gather_facts: false
    collections:
    • netapp.ontap
      vars_files:
    • /home/u630850/facts/var_file.yml
    • /home/u630850/facts/admin_clusters.yml
      vars:
      dst_hostname: ''
      dst_vserver: '
      '
      dst_volume: ''
      source_vserver: '
      '
      source_volume: ''
      #admin_ip: abc.wellsfargo.com
      #svm_name: '
      '
      login: &login
      #hostname: "{{ admin_ip }}"
      username: "{{ admin_username }}"
      password: "{{ admin_password }}"
      validate_certs: false
      tasks:
    • name: Information gathering
      na_ontap_rest_info:
      <<: *login
      gather_subset: snapmirror_info
      parameters:
      destination.path: "{{ dst_vserver }}:{{ dst_volume }}"
      source.path: "{{ source_vserver }}:{{ source_volume }}"
      fields:
      - lag_time
      hostname: "{{ item }}"
      use_python_keys: true
      register: ontap
      loop: "{{ admin_clusters }}"
      loop_control:
      label: "{{ item }}"
      #no_log: false
    • debug: var=ontap
    • set_fact:
      volumes: "{{ volumes|default({}) | combine( {item.item: item.ontap_info | json_query(get_attrs) }) }}"
      vars:
      get_attrs: "snapmirror_relationships.records[*].{source_path: source.path, destinatoin_path: destination.path, lag_time: lag_time|netapp.ontap.iso8601_duration_to_seconds }"
      loop: "{{ ontap.results }}"
    • debug: var=volumes
vital oriole
#

I don't think you can use it in get_attrs, it is the query for json_query.

prime knoll
#

Oh ok, will need to check other way. Any suggestions I can request?

vital oriole
#

It looks a bit complicated. I would keep the first set_facts as you have, but with lag_time as returned by ONTAP. And add another step to do the conversion.

prime knoll
#

Yes seems complicated 😕

vital oriole
#

I agree. What are you trying to achieve?

prime knoll
#

I want to fetch source_path, dest_path, lag_time . I had got struck for lag_time . It should be like 00:25:59 ( h : m : s) this is how we get in putty output