ONTAP Discussions

Get volume mapped CIFS shares with ONTAPI

Madhurish
2,523 Views

I'm using ONTAPI version 1.3 and I'm trying to collect cifs share information. In the response XML I'm only seeing the volume name, I wish to get the volume UUID as well.

I'm using cifs-share-get-iter to collect the cifs share information.

Should I be using some other API to get the mapping with the volume uuid? I'm completely new to NetApp ecosystem so any help would be much appreciated.

5 REPLIES 5

parisi
2,496 Views

ONTAP 9.6 and later leverages REST API calls. ONTAP 9.8 introduced CIFS sessions support for REST.

 

parisi_0-1623782675968.png

 

 

You can find the relevant REST APIs you need via the following link:

 

https://yourclustermgmtIP/docs/api

 

Then you login with your cluster creds. That gives a complete set of docs and even an "evaluate" button to test out/generate REST API calls.

 

For CIFS share info, you could use something like this:

 

https://yourclustermgmtIP/api/protocols/cifs/sessions?return_timeout=15&return_records=true&fields=client_ip,protocol

 

That would give output like this:

 

{
  "records": [
    {
      "node": {
        "uuid": "c981bb41-2cc9-11e6-bcc4-41d03af547fe",
        "name": "ontap9-tme-8040-01",
        "_links": {
          "self": {
            "href": "/api/cluster/nodes/c981bb41-2cc9-11e6-bcc4-41d03af547fe"
          }
        }
      },
      "svm": {
        "uuid": "7e3cc08e-d9b3-11e6-85e2-00a0986b1210",
        "name": "DEMO",
        "_links": {
          "self": {
            "href": "/api/svm/svms/7e3cc08e-d9b3-11e6-85e2-00a0986b1210"
          }
        }
      },
      "identifier": 5162532547850141697,
      "connection_id": 1011507766,
      "client_ip": "x.x.x.x",
      "protocol": "smb3",
      "_links": {
        "self": {
          "href": "/api/protocols/cifs/sessions/c981bb41-2cc9-11e6-bcc4-41d03af547fe/7e3cc08e-d9b3-11e6-85e2-00a0986b1210/5162532547850141697/1011507766"
        }
      }
    }
  ],

Madhurish
2,477 Views

Thank you @parisi for the explanation.

I also have Clusters running ONTAP 8.3 Cluster mode, so I can't rely on RESTful APIs as the older version don't support REST APIs, is there any way that I can get the mappings without using the REST APIs?

Any thoughts on this would be of great help. Thanks in Advance!

parisi
2,414 Views

cifs-share-get-iter just gives you basic CIFS share info (such as the volume name)

 

If you want the volume UUID, you'd need to use whatever volume name the ZAPI gave you and then use volume-get-iter for the UUID (which uses <uuid>):

 

For example, this ZAPI call would search for the volume name "home" and return the UUID:

 

<?xml version="1.0" encoding="UTF-8"?>

<netapp xmlns="http://www.netapp.com/filer/admin" version="1.21">
  <volume-get-iter>
    <query>
      <volume-attributes>
        <volume-id-attributes>
          <name>home</name>
        </volume-id-attributes>
       </volume-attributes>
    </query>
    <desired-attributes>
      <volume-attributes>
        <volume-id-attributes>
          <uuid></uuid>
        </volume-id-attributes>
       </volume-attributes>
    </desired-attributes>
  </volume-get-iter>
</netapp>

This is the result:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE netapp SYSTEM "file:/etc/netapp_gx.dtd">

<netapp xmlns="http://www.netapp.com/filer/admin" version="1.180">
  <results status="passed">
    <attributes-list>
      <volume-attributes>
        <volume-id-attributes>
          <name>home</name>
          <owning-vserver-name>DEMO</owning-vserver-name>
          <uuid>4b1e1bdf-af6f-11ea-ae2a-00a0986b1223</uuid>
        </volume-id-attributes>
      </volume-attributes>
    </attributes-list>
    <num-records>1</num-records>
  </results>
</netapp>

 

Compare to the CLI:

 

::*> vol show -vserver DEMO -volume home -fields uuid
vserver volume uuid
------- ------ ------------------------------------
DEMO    home   4b1e1bdf-af6f-11ea-ae2a-00a0986b1223

 

For CIFS session information,  you can use "cifs-session-get-iter"

 

This is what you'd see for that. No vol UUID there.

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE netapp SYSTEM "file:/etc/netapp_gx.dtd">

<netapp xmlns="http://www.netapp.com/filer/admin" version="1.180">
  <results status="passed">
    <attributes-list>
      <cifs-session>
        <address>x.x.x.x</address>
        <auth-mechanism>kerberos</auth-mechanism>
        <connected-time>8d 3h 47m 29s</connected-time>
        <connection-count>4</connection-count>
        <connection-id>1011507766</connection-id>
        <continuously-available>no</continuously-available>
        <files>2</files>
        <idle-time>6m 33s</idle-time>
        <is-large-mtu-enabled>true</is-large-mtu-enabled>
        <is-session-signed>false</is-session-signed>
        <lif-address>x.x.x.y</lif-address>
        <netbios-name>demo</netbios-name>
        <node>node1</node>
        <other>0</other>
        <protocol-version>smb3</protocol-version>
        <session-id>5162532547850141697</session-id>
        <shares>1</shares>
        <smb-encryption-status>unencrypted</smb-encryption-status>
        <unix-user>admin</unix-user>
        <user-type>domain_user</user-type>
        <vserver>DEMO</vserver>
        <win-unix-creds>-</win-unix-creds>
        <windows-user>NTAP\Administrator</windows-user>
      </cifs-session>
    </attributes-list>
    <num-records>1</num-records>
  </results>
</netapp>

Madhurish
2,410 Views

@parisi  I understand that I can use those queries for getting the volume UUID and also the shares separately. In my original query I wanted to get the mapping between the volumes and the CIFS shares. And since CIFS share XML only returns the volume name, I wasn't feeling too sure of using the volume name as the key to map the CIFS share to the corresponding volume.

Especially in setups where I have multiple clusters working together. Can I rely on the volume name of CIFS collected from ZAPI using cifs-share-get-iter to then map to the Volumes collected via volume-get-iter ?

In other words can name alone be the "primary key" per-se when I have used these two queries and want to find the mapping between these objects? 

parisi
2,405 Views

If you have multiple clusters with volumes that have the same name, there's not really a way to uniquify those names unless you include information such as the cluster/SVM names in the queries. cifs-shares-get-iter will only show you the output you'd see from the CLI command "cifs shares show" - you'd have to incorporate some scripting to filter things properly.

 

The "cifs-session-get-iter" provides recent session info and client IP/volume relationship, but it sounds like you're going to have to use several data sources to do what you want to do here.

Public