ONTAP Rest API Discussions

How to set "hard_limit" using Rest API?

PAVLENYCH
7,682 Views

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

1 ACCEPTED SOLUTION

RobertBlackhart
7,424 Views

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.

View solution in original post

13 REPLIES 13

RobertBlackhart
7,674 Views

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()

 

PAVLENYCH
7,637 Views

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

RobertBlackhart
7,616 Views

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.

PAVLENYCH
7,607 Views

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

 

PAVLENYCH
7,605 Views

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

PAVLENYCH
7,603 Views

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

RobertBlackhart
7,594 Views

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.

PAVLENYCH
7,580 Views

Hello RobertBlackhart,

 

I appreciate your help!

 

BR,

Pavel

PAVLENYCH
7,428 Views

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

RobertBlackhart
7,425 Views

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.

PAVLENYCH
7,417 Views

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

 

RobertBlackhart
7,415 Views

No problem. Good luck with the rest of your automation!

PAVLENYCH
7,413 Views

RobertBlackhart,

 

Thank you!

 

BR,

Pavel

Public