Isilon: Powershell with Platform API 사용 - 오브젝트 생성 및 RAN

Summary: 이 문서에서는 OneFS 플랫폼 API와 함께 Powershell을 사용하여 오브젝트 및 RAN을 생성하는 방법에 대해 설명합니다.

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Symptoms

필요 없음

Cause

필요 없음

Resolution

JSON 소개

PAPI는 JSON을 데이터 교환 형식으로 사용하며 이를 활용하여 PAPI를 사용하여 리소스를 생성, 수정 또는 삭제하는 방법을 이해하는 것이 중요합니다. www.json.org JSON에 대해 자세히 알아볼 수 있지만 핵심 원칙은 완전한 독립 프로그래밍 언어이며 다음 두 가지 구조를 기반으로 구축된다는 것입니다.
  • 이름/값 쌍 모음
  • 순서가 지정된 값 목록

시스템 객체를 가져오는 출력의 예는 다음과 같습니다.

{
"<object>": {
"<property>": <value>,
...
}

오브젝트를 생성하기 위해 POST에 필요한 JSON 텍스트를 알아보려면 GET /platform/1/quota/quotas라는 요청을
전송하여 PAPI 자체 설명서를 확인하십시오.

관련 Powershell 코드는 다음과 같습니다. 

할당량
에 대한 #GET PAPI 자체 설명서$resource = "/platform/1/quota/quotas?describe"
$uri = $baseurl + $resource
$ISIObject = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get
$ISIObject

 

아래 출력 예에서는 새 할당량을 생성하기 위해 POST에 필요한 사항을 간략하게 설명합니다. 해당 isi 명령에 필요한 속성이 동일하지 않을 수 있으므로 필요한 속성에 주의를 기울입니다.

SLN319398_en_US__1i_isilon_1-powershell

이 예시 속성을 사용하여 디렉토리 하드 할당량을 생성하는 데 사용할 수 있는 예시 JSON 문자열은 다음과 같습니다.

$QuotaObject = @"
{"type":"directory","include_snapshots": false,"container": true, "path": /ifs/home/user1", "적용됨": true, "thresholds": {"hard":10000000},"thresholds_include_overhead": false}
" @ 

JSON 문자열이 완료되면, 남은 것은 Invoke-RestMethod 매개변수를 구축하고 제출하는 것입니다. 아래의 예제 코드에서 JSON 문자열은 POST의 본문이며 콘텐츠 유형은 애플리케이션/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

모든 것을 하나로 통합

예를 들어, 환경에 단일 상위 디렉토리 아래 사용자에 대한 홈 디렉토리가 많다고 가정해 보겠습니다(예: /ifs/home) 각 홈 디렉토리에 대한 디렉토리 할당량을 설정하려고 합니다. Isilon RESTful Access to the Namespace (RAN) API를 사용하여 각 사용자 홈 디렉토리에 대한 경로를 가져옵니다. 다음 코드는 지정된 경로의 하위 디렉토리를 가져옵니다. 그런 다음 각 하위 디렉토리에 디렉토리 할당량을 설정합니다.
 

# 지정된
경로의 하위디렉토리 가져오기$resource = '/namespace/' + $path
$uri = $baseurl + $resource
$ISIObject = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get
#Loop 각 디렉토리를 통해 할당량
ForEach($ISIObject.children에서 $folder) {

#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", "적용됨": true, "thresholds": {"hard":$quotasize},"thresholds_include_overhead": false}
"@
$headers = @{"Authorization"="Basic $($EncodedPassword)"}
$uri = $baseurl + $resource
$ISIObject 2 = Invoke-RestMethod -Uri $uri -Headers $headers -Body $QuotaObject -ContentType "application/json; charset=utf-8" -Method POST
Write-Host " Resulting Quota ID: " $ISIObject2.id
}

다음은 이 게시물에서 첨부된 스크립트를 실행하는 출력입니다.

SLN319398_en_US__2i_isilon_2-powershell
SLN319398_en_US__3i_isilon_3-powershell

Affected Products

Isilon, PowerScale OneFS, Isilon Platform API
Article Properties
Article Number: 000132770
Article Type: Solution
Last Modified: 12 Oct 2023
Version:  5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.