ONTAP Rest API Discussions
ONTAP Rest API Discussions
Hello,
Is there a way to set "hard_limit" for specific user using Rest API?
Actually I only need an example of get/post HTTP Request for setting/updating "hard_limit" for a user.
BR,
Pavel
Solved! See The Solution
Hi Pavel,
The answer seems to be no, not really. The hard_limit field is not tied to a single user, but rather to a rule. Each rule has a list of one or more users that it applies to.
If in your system, you create a new QuotaRule for every user, then you can achieve what you want with a single REST call by using the collection patch technique:
curl -iku admin -X PATCH -d '{"files": {"hard_limit": 100}}' https://<mgmt_ip>/api/storage/quota/rules?users.name=fred
A word of caution. This call will patch every quota rule that has the user fred listed in it. But if it's one to one, then that will do what you want. The quota team figured this was basically what the PowerShell Toolkit was doing behind the scenes since they didn't know of any API that was user based as the command would suggest.
This is the example from the API docs:
The following example shows how to update a quota policy rule.
# The API:
PATCH /storage/quota/rules/{uuid}
# The call:
curl -X PATCH "https://<mgmt-ip>/api/storage/quota/rules/364d38eb-8e87-11e8-a806-005056a7e73a" -H 'accept: application/hal+json' -d "@test_quota_patch.txt"
test_quota_patch.txt(body):
{
"space": {
"hard_limit": 16554,
"soft_limit": 8192
},
"files": {
"hard_limit": 40,
"soft_limit": 20
}
}
Or if you are using Python with the netapp-ontap library, the docs are here:
from netapp_ontap import HostConnection
from netapp_ontap.resources import QuotaRule
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = QuotaRule(uuid="364d38eb-8e87-11e8-a806-005056a7e73a")
resource.space.hard_limit = 16554
resource.space.soft_limit = 8192
resource.files.hard_limit = 40
resource.files.soft_limit = 20
resource.patch()
Hello RobertBlackhart,
First of all thank you for your reply once again.
Please correct me if I'm wrong, by changing rule I'm actually changing the rule, that applies not for specific user, but for multiple?
BR,
Pavel
Yes, it would apply to all of the users in that rule's list. If you needed to have different limits for different users, I think you would need to have multiple quota rules.
Hello RobertBlackhart,
If each user has his own quota, is it available to change user's for example "hard_limit"?
I'm asking, because in our company each user has his own quota and there is no rule, which is applied for all.
BR,
Pavel
RobertBlackhart,
In our case I can get user's quota by following PowerShell command:
get-ncquotareport -target "someUser"
Each user has different "soft_limit" and "hard_limit".
Does it still mean there is different rule for each user?
I'm asking, because need to change from time to time "soft_limit" and "hard_limit" for different user.
In PowerShell I can do it based on user and not rule.
My question whether I can do it u based on user using Rest API as I do it with PowerShell?
BR,
Pavel p
The PowerShell command we use for setting quota for user is:
Set-NcQuota -User "domain\user" -volume "someVolume" - disklimit "someLimit".
Is there an option to perform this using Rest API?
BR,
Pavel
I'll forward this thread to the quota team to see if they know better, but from what I see in the API, there is no "quota" object that you can interact with. Only quota rules which then have a list of users.
Hello RobertBlackhart,
I appreciate your help!
BR,
Pavel
Hello RobertBlackhart,
I just wanted to ask whether some answer from Quota Team regarding using Rest API for setting Quota for specific user and not for a Rule?
Thank you in advance!
BR,
Pavel
Hi Pavel,
The answer seems to be no, not really. The hard_limit field is not tied to a single user, but rather to a rule. Each rule has a list of one or more users that it applies to.
If in your system, you create a new QuotaRule for every user, then you can achieve what you want with a single REST call by using the collection patch technique:
curl -iku admin -X PATCH -d '{"files": {"hard_limit": 100}}' https://<mgmt_ip>/api/storage/quota/rules?users.name=fred
A word of caution. This call will patch every quota rule that has the user fred listed in it. But if it's one to one, then that will do what you want. The quota team figured this was basically what the PowerShell Toolkit was doing behind the scenes since they didn't know of any API that was user based as the command would suggest.
Dear RobertBlackhart,
I really appreciate your help - it's just priceless!
If there is no API for setting "hard_limit" based on user and not Rule, then I will just add this PowerShell command to my C# code.
RobertBlackhart, thank you so much for your time and huge help!
BR,
Pavel
No problem. Good luck with the rest of your automation!
RobertBlackhart,
Thank you!
BR,
Pavel