NetApp / ontap-rest-python

This repository contains sample code illustrating how to access the ONTAP REST API using Python. This Repository also contains ONTAPI Usage reporting code that helps to identify ONTAPI usage in your environment using ONTAP REST APIs.
BSD 3-Clause "New" or "Revised" License
60 stars 41 forks source link

Unable to use LocalCifsGroupMembers #47

Closed albinpopote closed 6 months ago

albinpopote commented 6 months ago

Hello,

I try to use the LocalCifsGroupMembers class to associate local user(s) from an SVM to a local group (cifs workgroup). Based on the documentation: https://library.netapp.com/ecmdocs/ECMLP2885777/html/resources/local_cifs_group_members.html#overview, I try to simply get information of members on my local group "cifs_group":

print(list(LocalCifsGroup.get_collection(fields="*", **{"svm.name": 'test_svm'})))
--> [LocalCifsGroup({'_links': {'self': {'href': 'xxxx'}}, 'name': 'SVM_TEST_01\\cifs_group', 'sid': 'S-1-5-21-1704451965-2597020852-3779635676-1001', 'svm': {'_links': {'self': {'href': 'xxxx'}}, 'name': 'test_svm', 'uuid': '60f0f740-cf56-11ee-a9e3-00a098a97a62'}})]

When I try to request the LocalCifsGroupMembers with group SID: print(list(LocalCifsGroupMembers.get_collection("S-1-5-21-1704451965-2597020852-3779635676-1001")))

I got the following NetAppRestError: Could not compute the location of the LocalCifsGroupMembers collection. Values for ['svm.uuid', 'local_cifs_group.sid'] are required. Caused by AttributeError("'LocalCifsGroupMembers' object has no attribute 'svm'")

I've tried to pass the SID from user in place of the group SID, the complete local group response object, svm.uuid and local_cifs_group.sid as parameters but I got always the same error....

Environment: netapp-ontap 9.14.1.0 NetApp Release 9.11.1P12: Fri Sep 22 11:58:50 UTC 2023

Regards ^^

github-actions[bot] commented 6 months ago

Thank you for reporting an issue! If you haven't already joined our Discord community, then we invite you to do so. This is a great place to get help and ask questions from our community.

noorbuchi commented 6 months ago

Hi @albinpopote,

It looks like the example in the official netapp_ontap documentation page is incorrect. You need to pass the SVM uuid as well as the local_cifs_group sid. The code would then look something like this:

print(list(LocalCifsGroupMembers.get_collection("<svm_uuid>", "<local_cifs_group.sid>")))

You can also refer to the official REST API documentation where the same example exists correctly using curl

https://docs.netapp.com/us-en/ontap-restapi//ontap/protocols_cifs_local-groups_svm.uuid_local_cifs_group.sid_members_endpoint_overview.html#overview

Can you please try that out and let us know if it works. Thanks!

Best, Noor

albinpopote commented 6 months ago

Hello @noorbuchi,

Yes It works if you pass directly the arguments (*args) to the get_collection. It doesn't work if you try to use kwargs arguments on the get_collection function:

print(list(LocalCifsGroupMember.get_collection(**{'svm.uuid': '<svm_uuid>', 'local_cifs_group.sid': '<local_cifs_group.sid>'})

Thks for your help ^^

noorbuchi commented 6 months ago

Glad to hear that it works!

For get_collection, netapp_ontap expects that all parent keys/path keys to be provided as *args. On the other hand, values passed as **kwargs are sent as query parameters in the REST request. I hope this clears it up.