Add_workflow_for_techpubs |
---|
AUTH1 | UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'} |
---|
JIRAIDAUTH | SYM-22656 |
---|
REV5 | UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'} |
---|
REV6 | UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'} |
---|
REV3 | UserResourceIdentifier{userKey=8a00a02355cd1c2f0155cd26c85500c9, userName='null'} |
---|
REV1 | UserResourceIdentifier{userKey=8a00a02355cd1c2f0155cd26cc5207f0, userName='null'} |
---|
|
...
...
(the current Powershell command
<Invoke-RESTrequest> does not support multi-part upload). cURL does not require any installation.
...
REST API.
This This first request must be executed before you can access any of the other REST Resources on the
Sonus SBC 1000/2000 system. Refer to
Resource - login. Code Block |
---|
### Allow self Sign Cert
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class IDontCarePolicy : ICertificatePolicy {
public IDontCarePolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest wRequest, int certProb) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy
### Login
$BodyValue = "Username=restuser&Password=restpass"
$url = "https://$NodeUrl/rest/login"
$Result = Invoke-RestMethod -Uri $url -Method Post -Body $BodyValue -SessionVariable ps |
Log in with cURLcURL
This operation allows login to the
This operation allows login to the SBC with cURL, and stores the PHP Session ID into Powershell for reuse later.
...
This operation allows installation of Sonus SBC of Communication service updates on the ASM. Refer to Resource - sbaconfig.
Query
Code Block |
---|
curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://134.56.226.215/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@setup.msi |
...
To ensure the Lync SBA is running the latest Lync Server patches, administrators should install the . Refer to to Resource - sbaconfig.
Query
Code Block |
---|
curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://134.56.226.215/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@ASM_Lync_2013_CU4.pkg |
...
To ensure the ASM is running the latest Windows Updates patches, administrators should install the latest RollUp PackASM Rollup Update. Refer to Resource - sbaconfig .
Command to upload the Windows updates
...
Code Block |
---|
### Return the result of the request
Function BasicHandlerCurl {
Param($MyResult)
$FiltredMyResult = ""
foreach ($line in $MyResult) {
if ($line.StartsWith("<")) {
$FiltredMyResult += $line
} elseif ($line.StartsWith(" ")) {
$FiltredMyResult += $line
}
}
[xml]$XmlResult = $FiltredMyResult
if($XmlResult.root.status.http_code.contains("200")) {
return 1
} else {
return "Error Code:<"+$XmlResult.root.status.app_status.app_status_entry.code+"> Param:<"+$XmlResult.root.status.app_status.app_status_entry.params+">"
}
}
|
Code Block |
---|
### Return the result of the last action
function LookCompletionStatus {
Param($MyNodeUrl, $MyPs)
$url = "https://$MyNodeUrl/rest/sbaactionstatus"
$timer = 0
while($timer -lt 3600) {
|
Code Block |
---|
$Result = Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs
if ((BasicHandler $Result) -ne 1) { return 0}
[xml]$FinalResult= $Result.Substring(5)
if ($FinalResult.root.sbaactionstatus.rt_Success -eq 1) {
if ($FinalResult.root.sbaactionstatus.rt_PercentComplete -eq 100) { return 1 }
} else {
return $FinalResult.root.sbaactionstatus.rt_StatusText
}
sleep 10
$timer += 10
write-host "- "$FinalResult.root.sbaactionstatus.rt_PercentComplete"% "$FinalResult.root.sbaactionstatus.rt_StatusText
}
return "Timout out"
}
###################################
#### Main Code
###################################
$ActualStep = 0
|
Code Block |
---|
### 1. Log in with Powershell
$ActualStep = "1. Log in with Powershell"
### Allow self Sign Cert
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates; |
Code Block |
---|
public class IDontCarePolicy : ICertificatePolicy {
public IDontCarePolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest wRequest, int certProb) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy
### Login
$BodyValue = "Username=restuser&Password=restpass"
$url = "https://$NodeUrl/rest/login"
$Result = Invoke-RestMethod -Uri $url -Method Post -Body $BodyValue -SessionVariable ps
### 2. Log in with Curl
$ActualStep = "2. Log in with Curl"
$login = ./curl.exe -k --data "Username=$NodeLogin&Password=$NodePassword" -i -v https://$NodeUrl/rest/login
$PHPSESSID = 0
foreach ($line in $login) {
if ($line.contains("PHPSESSID=")) {
$correctline = $line.split(";")
$splitedline = $correctline.split("=")
$PHPSESSID = $splitedline[1]
}
}
|
Code Block |
---|
### 3. Update SbcComms
$ActualStep = "3. Update SbcComms"
$Result = ./curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://$NodeUrl/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@$SbcCommsFilePath
if ((BasicHandlerCurl $Result) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandler $Result)
return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandlerCurl $Result)
return 0
}
### 4. Install the Latest Lync SBA Cumulative Update (CU)
$ActualStep = "4. Install the Latest Lync SBA Cumulative Update (CU)"
$Result = ./curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://$NodeUrl/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@$LyncCU
if ((BasicHandlerCurl $Result) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandler $Result)
return 0
}
|
Code Block |
---|
# We need to log again since we may timeout
### Login
$BodyValue = "Username=restuser&Password=restpass"
$url = "https://$NodeUrl/rest/login"
$Result = Invoke-RestMethod -Uri $url -Method Post -Body $BodyValue -SessionVariable ps
# Check for the completion of the CU install
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandlerCurl $Result)
return 0
}
# We need to log again since we may timeout
|
Code Block |
---|
### Log in with Curl
$login = ./curl.exe -k --data "Username=$NodeLogin&Password=$NodePassword" -i -v https://$NodeUrl/rest/login
$PHPSESSID = 0
foreach ($line in $login) {
if ($line.contains("PHPSESSID=")) {
$correctline = $line.split(";")
$splitedline = $correctline.split("=")
$PHPSESSID = $splitedline[1]
}
} |
Code Block |
---|
### 5. Install the Latest Sonus Windows Update pack
$ActualStep = "5. Install the Latest Sonus Windows Update pack"
$Result = ./curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://$NodeUrl/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@$WindowsUpdate
if ((BasicHandlerCurl $Result) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandler $Result)
return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandlerCurl $Result)
return 0
}
while (1) {
$url = "https://$NodeUrl/rest/sbaconfig"
$ResultGeneral = Invoke-RestMethod -Uri $url -Method GET -WebSession $ps
if ((BasicHandler $ResultGeneral) -ne 1) {
write-host $ActualStep" Failed: "(BasicHandler $ResultGeneral)
return 0
} |
...