安裝授權
產品版本:10.11
最後修改日期:2024年7月31日
安裝產品授權。詳情請參閱「授權」部分。
終點
https://<Director_IP_address>:4443/c/router
請求範例
此方法接受一個 multipart/form-data 上傳資料,而非 JSON 內容。傳送每個請求欄位(action, method, data, type,以及 tid) 作為獨立的表單欄位傳送。請將授權檔案作為 licenseFile 表單欄位傳送:它並非 data。
curl --request POST \
--url https://<Director_IP_address>:4443/c/router \
--cookie cookies.txt \
--header "content-type: multipart/form-data" \
--form licenseFile=@ent.lic \
--form action=LicensingManagement \
--form method=installLicense \
--form tid=1 \
--form type=rpc \
--form data=[true]
請求欄位
|
領域
|
類型
|
值(們)
|
Description |
|---|---|---|---|
licenseFile |
字串 |
|
待上傳的授權檔案位置 |
action |
字串 |
|
所呼叫的動作 |
method
|
字串 |
|
被呼叫的方法 |
data
|
陣列 |
|
包含一個元素(布林值)的陣列: true 在背景中安裝授權, false 並等待授權安裝完成。在 false 在必須等待安裝完成的腳本中 |
type
|
字串 |
|
通訊協定類型 |
tid
|
整數 |
|
交易編號。用於讓客戶端和伺服器雙方識別該請求 |
注意!!!
您可以透過 PowerShell 腳本安裝您的授權。請參閱下方的範例。
# Get the cookies from the login call
$Cookie = New-Object System.Net.Cookie;
$Cookie.Name = "JSESSIONID-1518008951"; # Example, replace the string
$Cookie.Value = "1B02CE0DD33B4BFB926EFD44516523AB"; # Example, replace the string
$Cookie.Domain = "localhost";
$WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession;
$WebSession.Cookies.Add($Cookie);
$LF = "`r`n";
$boundary = [System.Guid]::NewGuid().ToString()
$fileBytes = [System.IO.File]::ReadAllBytes('e:\trial.bin'); # License file, replace the path
$fileEnc = [System.Text.Encoding]::GetEncoding('iso-8859-1').GetString($fileBytes);
$tid = 1; # Use an auto-increment instead of fixed number
# Build body for the form-data manually since PS does not support multipart/form-data out of the box
$bodyLines = (
"--$boundary",
"Content-Disposition: form-data; name=`"action`"",
'',
'LicensingManagement',
"--$boundary",
"Content-Disposition: form-data; name=`"method`"",
'',
'installLicense',
"--$boundary",
"Content-Disposition: form-data; name=`"type`"",
'',
'rpc',
"--$boundary",
"Content-Disposition: form-data; name=`"tid`"",
'',
$tid,
"--$boundary",
"Content-Disposition: form-data; name=`"data`"",
'',
'[true]', # true=async, false=sync (wait for install)
"--$boundary",
"Content-Disposition: form-data; name=`"licenseFile`"; filename=`"trial.bin`"",
"Content-Type: application/octet-stream",
'',
$fileEnc,
"--$boundary--"
) -join $LF
# Allow self-signed certificate
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
# Use TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$uri = 'https://localhost:4443/c/router';
Invoke-RestMethod -Verbose -Uri $uri -Method Post -ContentType "multipart/form-data; boundary=$boundary" -Body $bodyLines -WebSession $webSession;
回應範例
{
"action": "LicensingManagement",
"method": "installLicense",
"tid": "1",
"type": "rpc",
"message": null,
"where": null,
"cause": null,
"data": null
}
回應欄位
|
領域
|
價值
|
Description
|
|---|---|---|
message
|
字串 | 若請求失敗,請顯示此訊息 |
where
|
字串 | 關於發生問題的方法的說明 |
cause
|
字串 | 故障原因 |
| 資料 | 字串 |
|