4 Replies Latest reply on Apr 26, 2013 6:53 AM by adat

    How to create a NCM JOB through SDK


      Hi ,

      How we can create a job in NCM through SDK which will run a script/Change template, where there will be few variables which will be taken as input through API.

      From the service definition we identified  various methods like Invoke, Update, Read etc. Among these which method should we need to call to effect the change.?

      The SDK sample program and doc mentions only about using Invoke method for acknowledging an alert.

      We are using C# as coding language. Any Help will be much appreciated.

        • Re: How to create a NCM JOB through SDK

          Change templates are not currently available through the SDK, but you can execute a script. I don't have a C# sample for that handy, but here's one in PowerShell that shows how to make the relevant Query and Invoke calls. Let me know if you need help translating it.


          # This sample script demonstrates how to execute a script on a device managed

          # by NCM and display the results.


          # Please update the hostname and credential setup to match your configuration,

          # and reference to an existing node.



          if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

              Add-PSSnapin "SwisSnapin"




          $hostname = "tdanner-vm-08r2"

          $username = "admin"

          $password = New-Object System.Security.SecureString

          $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

          $swis = Connect-Swis -v2 -host $hostname -cred $cred



          $ip = ''

          $nodeId = get-swisdata $swis "SELECT NodeID FROM Cirrus.Nodes WHERE AgentIP=@ip" @{ip=$ip}



          $script = "show clock"



          $nodeIdList = New-Object -TypeName "System.Guid[]" 1

          $nodeIdList[0] = $nodeId



          Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username) | Out-Null



          $transferID = "{$nodeId}:${username}:ExecuteScript"



          do {

              Start-Sleep -Seconds 1

              $status = Get-SwisData $swis "SELECT T.Status, T.Error FROM Cirrus.TransferQueue T WHERE T.TransferID=@transfer" @{transfer=$transferID}

              Write-Host $status.Status


          while (($status.Status -ne 'Complete') -and (-not $status.Error))



          $output = Get-SwisData $swis "SELECT T.Log FROM Cirrus.TransferQueue T WHERE T.TransferID=@transfer" @{transfer=$transferID}



          Write-Host $output