Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Add_workflow_for_techpubs
AUTH1UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'}
JIRAIDAUTHSYM-22656
REV5UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'}
REV6UserResourceIdentifier{userKey=8a00a0c85bb25531015bc4122a4f0003, userName='null'}
REV3UserResourceIdentifier{userKey=8a00a02355cd1c2f0155cd26c85500c9, userName='null'}
REV1UserResourceIdentifier{userKey=8a00a02355cd1c2f0155cd26cc5207f0, userName='null'}

Panel
titleTable of Contents

Table of Contents
maxLevel4

...

...

 cURL is a free cross platform library and command-line tool used to transfer  data transfer data using HTTP. In the example below, cURL is used to upload the file into the SBC  the 

Spacevars
0product2
(the current Powershell command <Invoke-RESTrequest> does not support multi-part upload). cURL does not require any installation.

...

The action below defines the Login resource used to log into the Sonus SBC

Spacevars
0company
 
Spacevars
0product2
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
Spacevars
0company
Spacevars
0longproduct
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 

Spacevars
0product2
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 

Spacevars
0company
 
Spacevars
0product2
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 Cumulative Update. 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
    }

...