#List volumes containing certain name conv

1 messages · Page 1 of 1 (latest)

split torrent
#

Hello, i see the list volumes documenation, is there a way to only list volumes that start with a certain patern? an example would be only list volumes that start with DEV_

thank you in advance.

unique edge
#

You can pass patterns along as a parameter using the na_ontap_rest_info module:

#

- name: Gather volumes starting with DEV_ netapp.ontap.na_ontap_rest_info: <<: *login gather_subset: - storage/volumes parameters: name: "DEV_*" is_svm_root: false fields: - name register: volumes

split torrent
#

said error using rest for version error 404 client error not found for ufl /ap/cluster?fields-version. error using REST version, status_code: 404

split torrent
#

That was pointed at a svm. I pointed at the cluster and got this error:

Error using RESt for version, error HTTPSConnectionPool host IP port=443 max retries exceeded with url /api/cluster?fields=version (caused by newconnectionerror ('<urllib3.connection.VerifiedHTTPSConnection object at >; Failed to establish a new conenction Errno 111 connection refused' ERROR useing rest for version, status_code : None

whole plinth
#

What version of ONTAP are you using?

split torrent
#

9.13.1

whole plinth
#

Could you try the following for me

curl --user <username>:<password> -kX GET https://<hostip>/api/cluster -H 'accept: application/hal+json'

You should get an Response back like the one below

carchi@carchi-mac-1 ~ $ curl --user <username>:<password> -kX GET https://<hostip>/api/cluster -H 'accept: application/hal+json'
{
"name": "ontap_cluster_1",
"uuid": "f6c9633d-9310-11ed-926e-005056b34578",
"version": {
"full": "NetApp Release Yellowdog__9.12.1: Thu Jan 12 13:14:09 UTC 2023",
"generation": 9,
"major": 12,
"minor": 1
},

split torrent
#

curl (7) failed to connect to IP por t443 connection refused

whole plinth
#

OK so it look like the rest api on your system isn't enable or responding. By default it should be enable. you may want to reach out #1063542514780475493 and see how to renable it

I don't believe the getting started guide with Rest api https://docs.netapp.com/us-en/ontap-automation/get-started/ontap_automation_options.html talks about how to renable it but you way want to double check.

split torrent
#

i made progress!

#

but im getting Error: Fields: [name], only one subset will be allowed

split torrent
#

Was able to get the curl command working via help from the api forum, now getting this error

Error useing REST for version, error HTTPSConnectionPool (host= 'ip', port=443) Max retries exceeded with url: /api/cluster?fields=version (caused by Connecttimeouterror (<urllib3.connection.verifiedHTTPSConnection object at 1x7fe875eafa90>, connection to ip timed out (connect timeout = 60) error using REST cor version, status_code: none

whole plinth
#

So it looks like the REST API was waiting 60 second and hit the connection timeout. Not sure what causing your system to be really slow (or getting info on a lot of results) to hit the timeout limit

split torrent
#

is there a way to extend that?

split torrent
#

Making Progress, need to figure out how just to pull the name, right now its pulling more:

  • hosts: localhost
    gather_facts: true
    become: false

    collections:

    • netapp.ontap
    • netapp.Um_Info

    tasks:

    • name: Gather Volumes starting with
      netapp.ontap.na_ontap_rest_info:
      hostname: ip
      username: "user"
      password: "password"
      validate_certs: "false"
      https: "true"
      gather_subset:

      • volume_info
        parameters:
        name: "tkg_*"
        fields:
      • 'name'
        register: volumes
    • name: print volume list
      debug:
      msg: "{{ volumes }}"

OUTPUT:

            {
                "_links": {
                    "self": {
                        "href": "/api/storage/volumes/04c3f560-3626-11ee-9939-d039ea3ac245"
                    }
                },
                "name": "tkg_bravo_lab3_pvc_c2e22858_b7fe_4aa4_bdfb_38ee37ab84a9",
                "uuid": "04c3f560-3626-11ee-9939-d039ea3ac245"
            },
whole plinth
#

uuid, and _links is always returned by the rest api

If you are looking to just get the name you'll need to do something similar to what i have in this playbook that returning the SVM names.

split torrent
#

hmmmmm, that screen shot didnt work

#

how would i pull the name of the volume out as a variable then to send to use else where?

#

interesting, screen shot worked on different machine. ill give that a try now, thank you

#

would i have to change ontap_info.svm_svms_records to something else?

whole plinth
#

Yes if you just print out {{ result }} you'll see the Json structure.

Volume i believe is storage_volume

split torrent
#

that didnt seem to work

#

here is a print of result

#

task path: /runner/project/volume_list.yml:26
ok: [localhost] => {
"msg": {
"changed": false,
"failed": false,
"ontap_info": {
"storage/volumes": {
"links": {
"self": {
"href": "/api/storage/volumes?max_records=1024&fields=name&name=tkg
%2A"
}
},
"num_records": 181,
"records": [

#

i dont see it listed

whole plinth
#

you need to add use_python_keys to your playbook

split torrent
#

oh......other then the text line is there anything else i need?

whole plinth
#

then it would be results.ontap_info.storage_volumes.records

split torrent
#

still getting this:
fatal: [localhost]: FAILED! => {
"msg": "'dict object' has no attribute 'storage_volume'"

whole plinth
#

volumes

split torrent
#

task path: /runner/project/volume_list.yml:27
ok: [localhost] => (item={'uuid': '003c0b46-150b-11ee-a6bd-d039eaa7292b', 'name': 'tkg_itg_pvc_a0ed24d2_8f30_4000_b8a1_1f929db79f1a', '_links': {'self': {'href': '/api/storage/volumes/003c0b46-150b-11ee-a6bd-d039eaa7292b'}}}) => {
"msg": "tkg_itg_pvc_a0ed24d2_8f30_4000_b8a1_1f929db79f1a"

#

so is that what i want?

whole plinth
split torrent
#

true. I guess i shold i have specified a little more. i need to get all the volumes in a variable so i use it in another task to register it in our backup solution

whole plinth
#

You can use that loop, in other tasks to loop through each name to do something

split torrent
#

Like in another task in the same playbook find a way to just pull the name I want out

whole plinth
split torrent
#

Thank you!

#

this what you thinking?
Registering variables with a loop
You can register the output of a loop as a variable. For example

  • name: Register loop output as a variable
    ansible.builtin.shell: "echo {{ item }}"
    loop:
    • "one"
    • "two"
      register: echo