Loading...
Loading...
Not required
Not required
Introduction to JSON The PAPI uses JSON as the data-interchange format. It is critical to understand how to leverage it to use PAPI to create, modify, or delete resources. Additional information about JSON is available at www.json.org . The key principle is that it is a complete independent programming language and is built on two structures: A collection of name and value pairs An ordered list of values Example output from getting an API object could look like this: { "<object>": { "<property>": <value>, ... } To know what JSON text outputs are available, we must issue a POST command to create an object; look at the PAPI self-documentation by sending the following request: GET /platform/1/quota/quotas?describe Here is the relevant Powershell code: #Get PAPI self documentation for quotas $resource = "/platform/1/quota/quotas?describe" $uri = $baseurl + $resource $ISIObject = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get $ISIObject The example output below outlines what you must POST to create a new quota. Pay attention to the required properties since they may not be the same properties required for the corresponding isi command. Using the example properties, the following is an example JSON string that can be used to create a directory hard quota: $QuotaObject = @" {"type":"directory","include_snapshots": false,"container": true, "path": /ifs/home/user1", "enforced": true, "thresholds": {"hard":10000000},"thresholds_include_overhead": false} "@ With the JSON string completed, all that is left is to build the Invoke-RestMethod parameters and submit. In the example code below, the JSON string is the body of the POST and that the content type is application/json : $headers = @{"Authorization"="Basic $($EncodedPassword)"} $uri = $baseurl + $resource $ISIObject = Invoke-RestMethod -Uri $uri -Headers $headers -Body $QuotaObject -ContentType "application/json; charset=utf-8" -Method POST Write-Host " Resulting Quota ID: " $ISIObject.id Putting It All Together Using an example, let us assume your environment has many home directories for users under a single parent directory, (example: /ifs/home ) and you want to set directory quotas for each of these home directories. Use the Isilon RESTful Access to the namespace (RAN) API to get the paths to each user home directory. The following code gets the subdirectories of a specified path and then set a directory quota on each subdirectory: # Get subdirectories of path specified $resource = '/namespace/' + $path $uri = $baseurl + $resource $ISIObject = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get #Loop through each directory and set the quota ForEach($folder in $ISIObject.children) { #Create quota $resource ="/platform/1/quota/quotas" Write-Host "Setting a $quotasize byte quota on $quotapath" $QuotaObject = @" {"type":"directory","include_snapshots": false,"container": true, "path": "$quotapath", "enforced": true, "thresholds": {"hard":$quotasize},"thresholds_include_overhead": false} "@ $headers = @{"Authorization"="Basic $($EncodedPassword)"} $uri = $baseurl + $resource $ISIObject2 = Invoke-RestMethod -Uri $uri -Headers $headers -Body $QuotaObject -ContentType "application/json; charset=utf-8" -Method POST Write-Host " Resulting Quota ID: " $ISIObject2.id } Here is the output from running the script attached to this post:
Click on a version to see all relevant bugs
Dell Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.