SBA requires the following updates:
All of these updates can be completed through WebUI, but they can also be triggered using the RibbonREST API that can be scripted with Powershell. This article describes the steps required to update an SBA. It also contains an "All In One" script that completely updates an ASM automatically.
cURL is a free cross platform library and command-line tool used to transfer data using HTTP. In the example below, cURL is used to upload the file into the SBC (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 Ribbon SBC REST API. This first request must be executed before you can access any of the other REST Resources on the Ribbon SBC 1000/2000 system. Refer to Resource - login.
### 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
This operation allows login to the SBC with cURL, and stores the PHP Session ID into Powershell for reuse later.
$login = ./curl.exe -k --data "Username=restuser&Password=restpass" -i -v https://192.168.123.53/rest/login $PHPSESSID = 0 foreach ($line in $login) { if ($line.contains("PHPSESSID=")) { $correctline = $line.split(";") $splitedline = $correctline.split("=") $PHPSESSID = $splitedline[1] } }
This operation allows installation of Ribbon SBC Communication service updates on the ASM. Refer to Resource - sbaconfig.
curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://134.56.226.215/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@setup.msi
<?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> </root>
$url = "https://134.56.226.215/rest/sbaactionstatus" Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs <?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> <sbaactionstatus href="https://134.56.226.215/rest/sbaactionstatus"> <rt_Success>1</rt_Success> <rt_ActionType>15</rt_ActionType> <rt_PercentComplete>100</rt_PercentComplete> <rt_Duration>5</rt_Duration> <rt_StatusText>setup.msi: Update Complete</rt_StatusText> <rt_AllActionsBitmap>0</rt_AllActionsBitmap> <rt_ActionStartTime>0</rt_ActionStartTime> </sbaactionstatus> </root>
To ensure the Lync SBA is running the latest Lync Server patches, administrators should install the Cumulative Update. Refer to Resource - sbaconfig.
curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://134.56.226.215/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@ASM_Lync_2013_CU4.pkg
<?xml version="1.0"?><root> <status> <http_code>200</http_code> </status> </root>
$url = "https://134.56.226.215/rest/sbaactionstatus" Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs <?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> <sbaactionstatus href="https://134.56.226.215/rest/sbaactionstatus"> <rt_Success>1</rt_Success> <rt_ActionType>15</rt_ActionType> <rt_PercentComplete>100</rt_PercentComplete> <rt_Duration>0</rt_Duration> <rt_StatusText>updates installed</rt_StatusText> <rt_AllActionsBitmap>127</rt_AllActionsBitmap> <rt_ActionStartTime>0</rt_ActionStartTime> </sbaactionstatus> </root>
To ensure the ASM is running the latest Windows Updates patches, administrators should install the latest ASM Rollup Update. Refer to Resource - sbaconfig .
curl.exe --cookie PHPSESSID=$PHPSESSID -k -i https://134.56.226.215/rest/sbaconfig?action=sbaupgrade -F sbaInstallFilename=@ASM_Rollup_2014-01.pkg
<?xml version="1.0"?><root> <status> <http_code>200</http_code> </status> </root>
$url = "https://134.56.226.215/rest/sbaactionstatus" Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs <?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> <sbaactionstatus href="https://134.56.226.215/rest/sbaactionstatus"> <rt_Success>1</rt_Success> <rt_ActionType>15</rt_ActionType> <rt_PercentComplete>100</rt_PercentComplete> <rt_Duration>0</rt_Duration> <rt_StatusText>updates installed</rt_StatusText> <rt_AllActionsBitmap>127</rt_AllActionsBitmap> <rt_ActionStartTime>0</rt_ActionStartTime> </sbaactionstatus> </root>
$url = "https://134.56.226.215/rest/sbaconfig" Invoke-RestMethod -Uri $url -Method GET -WebSession $ps
<?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> <sbaconfig href="https://192.168.123.53/rest/sbaconfig"> <AclEnable>1</AclEnable> <DHCPEnabled>0</DHCPEnabled> <DNSServer1>192.168.123.101</DNSServer1> <DNSServer2>192.168.123.102</DNSServer2> <RemoteDesktopEnabled>1</RemoteDesktopEnabled> <ipv4Address>192.168.123.54</ipv4Address> <ipv4Gateway>192.168.123.1</ipv4Gateway> <ipv4Netmask>255.255.255.0</ipv4Netmask> <rt_AsmReachable>1</rt_AsmReachable> <rt_AsmSupportMode>1</rt_AsmSupportMode> <rt_DHCPEnabled>0</rt_DHCPEnabled> <rt_Domain>sonuslab.ads</rt_Domain>
<rt_GpoDetected>2</rt_GpoDetected> <rt_HostName>SBA2000C</rt_HostName> <rt_IPv4Address>192.168.123.54</rt_IPv4Address> <rt_IPv4Gateway>192.168.123.1</rt_IPv4Gateway> <rt_IPv4Netmask>255.255.255.0</rt_IPv4Netmask> <rt_ImageDescription>Lync Server 2013 SBA</rt_ImageDescription> <rt_Licensed>1</rt_Licensed> <rt_LoginNames></rt_LoginNames> <rt_MediationCpuTime>6</rt_MediationCpuTime> <rt_MediationMemUsage>48002608</rt_MediationMemUsage> <rt_MediationSvcState>0</rt_MediationSvcState> <rt_MediationVersion>5.0.8308.0</rt_MediationVersion> <rt_NumEthPorts>2</rt_NumEthPorts> <rt_PendingRestartNeeded>2</rt_PendingRestartNeeded> <rt_QoEReportFailure>0</rt_QoEReportFailure> <rt_QoEReportSuccess>0</rt_QoEReportSuccess> <rt_RDPEnabled>1</rt_RDPEnabled> <rt_RegistrarCpuTime>0</rt_RegistrarCpuTime> <rt_RegistrarMemUsage>23866632</rt_RegistrarMemUsage> <rt_RegistrarSvcState>0</rt_RegistrarSvcState>
<rt_RegistrarVersion>5.0.8308.0</rt_RegistrarVersion> <rt_ReplicationErrors></rt_ReplicationErrors> <rt_ReplicationFQDN>SBA2000C.SONUSLAB.ADS</rt_ReplicationFQDN> <rt_ReplicationLastStatusReport>1418394867</rt_ReplicationLastStatusReport> <rt_ReplicationLastUpdateCreation>1418394863</rt_ReplicationLastUpdateCreation> <rt_ReplicationProductVersion>5.0.8308.0</rt_ReplicationProductVersion> <rt_ReplicationUpToDate>1</rt_ReplicationUpToDate> <rt_SQLCpuTime>0</rt_SQLCpuTime> <rt_SQLMemUsage>233693796</rt_SQLMemUsage> <rt_SQLSvcState>0</rt_SQLSvcState> <rt_SQLVersion>2011.110.2100.60</rt_SQLVersion> <rt_StatusText>none</rt_StatusText> <rt_UXComVersion>3.2.0.315</rt_UXComVersion> <rt_UXSBACpuTime>15</rt_UXSBACpuTime> <rt_UXSBAMemUsage>108333744</rt_UXSBAMemUsage> <rt_UpTime>537</rt_UpTime> <rt_UpdateState>1</rt_UpdateState> <rt_WinCpuUsage>23</rt_WinCpuUsage>
<rt_WinMemFree>2047868928</rt_WinMemFree> <rt_WindowsVersion>6.1.0.7601</rt_WindowsVersion> <rt_ASM_BIOSManufacturer>American Megatrends Inc.</rt_ASM_BIOSManufacturer> <rt_ASM_BIOSVersion>10.03.02</rt_ASM_BIOSVersion> <rt_ASM_ComputerModel>Calpella Platform</rt_ASM_ComputerModel> <rt_ASM_HDDSize>160GB</rt_ASM_HDDSize> <rt_ASM_ImageType>Lync Server 2013 SBA</rt_ASM_ImageType> <rt_ASM_PhysicalMemory>3950MB RAM</rt_ASM_PhysicalMemory> <rt_ASM_ProcessorCPUs>4</rt_ASM_ProcessorCPUs> <rt_ASM_ProcessorClockSpeed>~2.5GHz</rt_ASM_ProcessorClockSpeed> <rt_ASM_ProcessorName>Intel(R) Core(TM) i7 CPU 610 @ 2.53GHz</rt_ASM_ProcessorName> <CardType>11</CardType> <LineCardLicenseType>0</LineCardLicenseType> <LineCardNumLicensedPorts>0</LineCardNumLicensedPorts> <Location>11</Location> <MfgWeek>36</MfgWeek> <MfgYear>10</MfgYear> <PartNumber>423-40007</PartNumber> <SerialNumber>C4000710360046</SerialNumber> <Vendor>Sonus</Vendor> <VersionNumber>101</VersionNumber> </sbaconfig> </root>
$url = "https://134.56.226.215/rest/sbaconfig?action=installwindowsupdates" Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps
<?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> </root>
$url = "https://134.56.226.215/rest/sbaactionstatus" Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs <?xml version="1.0"?> <root> <status> <http_code>200</http_code> </status> <sbaactionstatus href="https://134.56.226.215/rest/sbaactionstatus"> <rt_Success>1</rt_Success> <rt_ActionType>35</rt_ActionType> <rt_PercentComplete>100</rt_PercentComplete> <rt_Duration>7050</rt_Duration> <rt_StatusText>Install Updates complete</rt_StatusText> <rt_AllActionsBitmap>127</rt_AllActionsBitmap> <rt_ActionStartTime>0</rt_ActionStartTime> </sbaactionstatus> </root>
### 1. Login $NodeUrl = "192.168.123.53" $NodeLogin = "restuser" $NodePassword = "restpass" ### 3. Update SbcComms $SbcCommsFilePath = "C:\Users\plessisa\Desktop\Demo REST\Setup\setup.msi" ### 4. Install the Latest Lync SBA Cumulative Update (CU) $LyncCU = "C:\Users\plessisa\Desktop\Demo REST\Setup\ASM_Lync_2013_CU8.pkg" ### 5. Install the Latest Sonus Windows Update pack $WindowsUpdate = "C:\Users\plessisa\Desktop\Demo REST\Setup\ASM_Rollup_2014-10.pkg" ################################### #### Define some function Helper ################################### ### Return the result of the request Function BasicHandler { Param($MyResult) [xml]$XmlResult = $MyResult.Substring(5) 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+">" } }
### 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+">" } }
### Return the result of the last action function LookCompletionStatus { Param($MyNodeUrl, $MyPs) $url = "https://$MyNodeUrl/rest/sbaactionstatus" $timer = 0 while($timer -lt 3600) { $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
### 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; 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] } }
### 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 } # 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
### 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] } } ### 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 }
[xml]$XmlResultGeneral = $ResultGeneral.Substring(5) switch ($XmlResultGeneral.root.sbaconfig.rt_UpdateState) { 0 {write-host "Status is Unknown"; return 0; break;} 1 {write-host "Status is UpToDate"; $url = "https://$NodeUrl/rest/sbaconfig" $Result = Invoke-RestMethod -Uri $url -Method GET -WebSession $ps if ((BasicHandler $Result) -ne 1) { write-host $ActualStep" Failed: "(BasicHandler $Result) return 0 } [xml]$XmlResult = $Result.Substring(5) if($XmlResult.root.sbaconfig.rt_PendingRestartNeeded.contains("1")) { # Restart the ASM to apply the Update $url = "https://$NodeUrl/rest/sbaconfig?action=asmreboot" $Result = Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps if ((BasicHandler $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 } break; } return 0; break;} 5 {write-host "Status is Error"; return 0; break;} 2 {
### 6. Apply the update include into the Latest Sonus Windows Update pack $url = "https://$NodeUrl/rest/sbaconfig?action=installwindowsupdates" $Result = Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps if ((BasicHandler $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 } break; } 3 {write-host "Wait for a install to end"; Start-Sleep -m 3; break;} 4 {write-host "Wait for a final status"; Start-Sleep -m 3; break;} default {write-host "Found an unpredictable state for the Update. Shutdown..."; return 0} } }