With the changes from ZAPI to REST in the API for ONTAP, the majority of all our modules are being updated to handle both, so almost no changes to your playbooks will be necessary.  There are two exceptions to this though.  That is the na_ontap_info and na_ontap_command.  Because of the vastly different ways the function of these modules input, and output differ from ZAPI to REST, these modules are being replaced with na_ontap_rest_info and na_ontap_rest_cli.  In this post I will be looking at using the new na_ontap_rest_info

Here are a couple examples of the na_ontap_rest_info module in use.   I will explain the different things happening.

First, how it would normally look if it was the same as the ZAPI na_ontap_info.

---
- hosts: localhost
  collections:
  - netapp.ontap
  tasks:
  - name: REST info module
    na_ontap_rest_info:
      gather_subset:
        - cluster_node_info
      hostname: "172.16.167.10"
      username: "admin"
      password: "netapp123"
      https: true
      validate_certs: false

However, the output when run with a -vvv is the following for a two-node cluster.

"ontap_info": {
        "cluster/nodes": {
            "_links": {
                "self": {
                    "href": "/api/cluster/nodes?max_records=1024"
                }
            },
            "num_records": 2,
            "records": [
                {
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/2e49496b-51e2-11ec-be57-00505694ef14"
                        }
                    },
                    "name": "Cluster1-01",
                    "uuid": "2e49496b-51e2-11ec-be57-00505694ef14"
                },
                {
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/f4d99f28-5206-11ec-b613-005056949984"
                        }
                    },
                    "name": "Cluster1-02",
                    "uuid": "f4d99f28-5206-11ec-b613-005056949984"
                }
            ]
        }
    }

As you can see the name and uuid of the nodes is the only information returned.  This is because the REST API only returns information fields that contain data that is unique to each entry.  For Nodes it is only name and uuid.  To get all the standard fields that REST will return you need to specify that you want the wildcard for fields.

---
- hosts: localhost
  collections:
  - netapp.ontap
  tasks:
  - name: REST info module
    na_ontap_rest_info:
      gather_subset:
        - cluster_node_info
      fields:
        - '*'
      hostname: "172.16.167.10"
      username: "admin"
      password: "netapp123"
      https: true
      validate_certs: false

Done this way you will receive more information rich output like this:

"ontap_info": {
        "cluster/nodes": {
            "_links": {
                "self": {
                    "href": "/api/cluster/nodes?max_records=1024&fields=%2A"
                }
            },
            "num_records": 2,
            "records": [
                {
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/2e49496b-51e2-11ec-be57-00505694ef14"
                        }
                    },
                    "cluster_interfaces": [
                        {
                            "_links": {
                                "self": {
                                    "href": "/api/network/ip/interfaces/64c1177f-51e4-11ec-be57-00505694ef14"
                                }
                            },
                            "ip": {
                                "address": "169.254.239.20"
                            },
                            "name": "Cluster1-01_clus1",
                            "uuid": "64c1177f-51e4-11ec-be57-00505694ef14"
                        },
                        {
                            "_links": {
                                "self": {
                                    "href": "/api/network/ip/interfaces/64c108a3-51e4-11ec-be57-00505694ef14"
                                }
                            },
                            "ip": {
                                "address": "169.254.251.18"
                            },
                            "name": "Cluster1-01_clus2",
                            "uuid": "64c108a3-51e4-11ec-be57-00505694ef14"
                        }
                    ],
                    "controller": {
                        "over_temperature": "normal"
                    },
                    "date": "2021-11-30T15:31:12+00:00",
                    "location": "",
                    "membership": "member",
                    "model": "SIMBOX",
                    "name": "Cluster1-01",
                    "serial_number": "4082368-50-7",
                    "service_processor": {
                        "state": "node_offline"
                    },
                    "state": "up",
                    "system_id": "4082368507",
                    "uptime": 5813,
                    "uuid": "2e49496b-51e2-11ec-be57-00505694ef14",
                    "version": {
                        "full": "NetApp Release 9.8: Wed Dec 09 01:07:39 UTC 2020",
                        "generation": 9,
                        "major": 8,
                        "minor": 0
                    }
                },
                {
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/f4d99f28-5206-11ec-b613-005056949984"
                        }
                    },
                    "cluster_interfaces": [
                        {
                            "_links": {
                                "self": {
                                    "href": "/api/network/ip/interfaces/a3e0d802-51e4-11ec-b614-005056949984"
                                }
                            },
                            "ip": {
                                "address": "169.254.153.132"
                            },
                            "name": "Cluster1-02_clus1",
                            "uuid": "a3e0d802-51e4-11ec-b614-005056949984"
                        },
                        {
                            "_links": {
                                "self": {
                                    "href": "/api/network/ip/interfaces/a3e10ee6-51e4-11ec-b614-005056949984"
                                }
                            },
                            "ip": {
                                "address": "169.254.29.49"
                            },
                            "name": "Cluster1-02_clus2",
                            "uuid": "a3e10ee6-51e4-11ec-b614-005056949984"
                        }
                    ],
                    "controller": {
                        "over_temperature": "normal"
                    },
                    "date": "2021-11-30T15:31:12+00:00",
                    "location": "",
                    "membership": "member",
                    "model": "SIMBOX",
                    "name": "Cluster1-02",
                    "serial_number": "4034389-06-2",
                    "service_processor": {
                        "state": "node_offline"
                    },
                    "state": "up",
                    "system_id": "4034389062",
                    "uptime": 5809,
                    "uuid": "f4d99f28-5206-11ec-b613-005056949984",
                    "version": {
                        "full": "NetApp Release 9.8: Wed Dec 09 01:07:39 UTC 2020",
                        "generation": 9,
                        "major": 8,
                        "minor": 0
                    }
                }
            ]
        }
    }

 

Even the wildcard field may not always give you the information you want.  ONTAP REST API now has a concept called ‘Expensive Properties’.  These are bits of information that require a higher level of CPU overhead to pull.  Not necessarily a lot, just more than the average.  The node info has fields in two categories that fall into that group.  The metrics.* and the statistics.*.  If you want these returned they must be added as specified field calls :

---
- hosts: localhost
  collections:
  - netapp.ontap
  tasks:
  - name: REST info module
    na_ontap_rest_info:
      gather_subset:
        - cluster_node_info
      fields:
        - '*'
        - 'metrics.*'
        - 'statistics.*'
      hostname: "172.16.167.10"
      username: "admin"
      password: "netapp123"
      https: true
      validate_certs: false

I still have the ‘*’ field because I am adding onto it. In the same way I could pull only the fields I wanted no matter if they were ‘Expensive’ or not by only having those as the fields entry instead of using wildcards.

It should also be noted that while I used the subset of cluster_node_info, the correct REST API subset is cluster/nodes.  Some subsets are not in REST API and REST will have some subsets that were not in ZAPI.  Use ‘ansible-doc netapp.ontap.na_ontap_rest_info’ to see the documentation and all available subsets for the version of the module you have installed.

So how do you know what fields are available and which are ‘Expensive’?  You need to use the REST API documentation for that.  The ‘Expensive Properties’ are listed with each GET call section.  You can look at the REST API documentation for various versions of ONTAP here – https://devnet.netapp.com/restapi.php

Since our Ansible modules utilize REST APIs,  we are limited in what we can do to what the API allows.  If you have any questions about REST APIs there is a Slack channel for that in thePub Workspace that is #api.  As always myself and several of the developers of the Ansible modules are in #configurationmgmt.  If you don’t have an invite to thePub Slack workspace you can get one at www.netapp.io/slack

David Blackwell on Linkedin
David Blackwell
Technical Marketing Engineer at NetApp
David is a twenty year IT veteran who has been an admin for just about every aspect of a DataCenter at one time or another. When not working, or tinkering with new software at home, David spends most of his free time with his six year old son and his lovely wife.

Pin It on Pinterest