1 Reply Latest reply on Sep 14, 2016 12:53 PM by tdanner

    Indication subscription

    qbol

      Hello,

       

      I am prototyping a C# client wrapper , which is consuming the Information Service.
      Right now, I'm working on Invoking verbs through the service. I tried calling the PollNow method, but is there any way to get an information about when it's done?
      I want the user to be able to call PollNow once in a while, and AFTER the poll is done, send a query to get the latest information about the node (right now, i just want to know if the node is up or down).

       

      Is there a way to subscribe to SWSQL Indications? Or is there any other way to do that?

       

      Thank you in advance

        • Re: Indication subscription
          tdanner

          For this use case, I think the simplest solution would be to just query the LastSync property until it changes. Like this:

           

          $hostname = "localhost"
          $username = "admin"
          $password = ""
          
          $swis = Connect-Swis -Hostname $hostname -UserName $username -Password $password
          $node = Get-SwisData $swis "SELECT TOP 1 NodeID, LastSync FROM Orion.Nodes ORDER BY LastSync DESC"
          $oldSyncTime = $node.LastSync
          
          Invoke-SwisVerb $swis Orion.Nodes PollNow @("N:" + $node.NodeID) | Out-Null
          Write-Host "Invoked PollNow for node $($node.NodeID)."
          
          Write-Host "Waiting for update..." -NoNewline
          do {
              Start-Sleep -Seconds 1
              Write-Host "." -NoNewline
              $newSyncTime = Get-SwisData $swis "SELECT LastSync FROM Orion.Nodes WHERE NodeID=@nodeId" @{nodeId=$node.NodeID}
          } while ($newSyncTime -eq $oldSyncTime)
          
          Write-Host "done."
          
          $node = Get-SwisData $swis "SELECT Caption, Status, StatusDescription FROM Orion.Nodes WHERE NodeID=@nodeId" @{nodeId=$node.NodeID}
          
          Write-Host "Latest status for $($node.Caption) is $($node.Status) - $($node.StatusDescription)"