This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Is the Network Configuration Manager programmable?

FormerMember
FormerMember

We want to automate the execution of scripts on our devices and thus I'm wondering if it's possible to drive the Network Configuration Manager with an API or what have you?

Thanks

  • Yes, you can tell NCM to execute a script on a device (or many devices). In the Samples\PowerShell directory, the NCM.ExecuteScript.ps1 script should get you started. Let me know if you need any other details.

  • FormerMember
    0 FormerMember in reply to tdanner

    Great! Now, lets start with my favorite question; Can this be done with C# / REST call(s) ?

    emoticons_wink.png

  • You bet. SWIS only has six basic operations: Query, Invoke, Create, Read, Update, Delete. All of the interfaces (REST, SOAP, and PowerShell) support all of these operations. Anything you can do with one, you can do with the others. Only the syntax will be different.

  • FormerMember
    0 FormerMember in reply to tdanner

    Excellent.

    I can see that most of it is just queries, of which I've done enough to be confident that I can translate the PS into C#. However, here are the parts I'm going to run by you to make sure my assumptions are correct.

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

    Will translate to something like this:
    Url: */v3/json/Execute/Cirrus.Nodes/Cirrus.ConfigArchive, yes?

    And the body data will be something like:
    { [GuidNodeID(s) e.g. "<guid>", "<guid>" ], "script_Text", "<username>" }

    Correct? Or should the whole be an array as well as the Guids?
    [ [ "<guid>", "<guid>" ], "script_Text", "<username>" ]

    Then there's this line.
    $transferID = "{$nodeId}:${username}:ExecuteScript"

    I assume it will translate to something like this?
    string transferID = "{340}:{userScott}:ExecuteScript"

  • Pretty close. The body for an Invoke call is always an array. For Cirrus.ConfigArchive/Execute, the first argument is also an array. The "transfer ID" string uses the NCM NodeID (which is a GUID), not the integer NodeID, and the username segment is not wrapped in {braces} - that's just powershell string interpolation syntax.

    So this command: Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username)

    Turns into this HTTP request:

    POST /SolarWinds/InformationService/v3/Json/Invoke/Cirrus.ConfigArchive/Execute

    [

        ["44550400-8415-4209-b78e-c5596cdfe086"],

        "show clock",

        "admin"

    ]

    And the transfer id string would be "{44550400-8415-4209-b78e-c5596cdfe086}:admin:ExecuteScript"

    I use a Chrome extension called "postman" to test REST APIs. I attached example requests to this reply. If you are having trouble with these calls, you might find it helpful to install postman and load up this file.

    NCM%20SWIS.json.postman_collection
  • FormerMember
    0 FormerMember in reply to tdanner

    When calling / EXEC'ing the */v3/Json/Invoke/Cirrus.ConfigArchive/Execute verb, do I need to make this call against the NCM server, or is the regular old 'call against the Orion server (NPM)' ok?

    I ask because I make the call as follows, then get a 500 (Internal Server Error). And of course that's ALL the info I get, so I have no clue as to why it's .. throwing.

    URL:
    https://<NPM_IP>:17778/SolarWinds/InformationService/v3/Json/Invoke/Cirrus.ConfigArchive/Execute

    Body data:
    [["b5d9898e-09d7-43e5-8290-8274f78d02e8"], "show version", "userName"]

  • Do you have NPM and NCM installed separately? I thought they were on the same server. If they are separate, then this call would need to go to the one with NCM.

    If the exception info is not coming back with the 500 error, you should be able to find it in the log file: C:\ProgramData\SolarWinds\InformationService\v3.0\Orion.InformationService.log.

  • FormerMember
    0 FormerMember in reply to tdanner

    Yes, they moved the NCM to it's own server. So, to re-test I called:

    https://NcmServer:17778/SolarWinds/InformationService/v3/Json/Invoke/Cirrus.ConfigArchive/Execute with data: [["b5d9898e-09d7-43e5-8290-8274f78d02e8"], "show version", "MGMT\v-MyAlias"] and got the following.

    HTTP/1.1 500 Internal Server Error
    Content-Length: 39
    Content-Type: application/json
    Server: Microsoft-HTTPAPI/2.0
    Date: Mon, 13 Apr 2015 14:14:29 GMT

    "Encountered unexpected character 'v'."

    So I figured I'd escape the '\' and re-POSTed the call with the same body data save for "MGMT\\v-MyAlias", then got:

    HTTP/1.1 400 Bad Request
    Content-Length: 79
    Content-Type: application/json
    Server: Microsoft-HTTPAPI/2.0
    Date: Mon, 13 Apr 2015 14:18:23 GMT

    {"Message":"System.Data.SqlClient.SqlException --> Incorrect syntax near ')'."}

    And I have an exception / stack trace from the log file you pointed me to. Not sure if you want me to post it here, or to your direct e-mail. Please advise.

    (It's weird that I got a SQL exception given that I'm not trying to run a query, at least not explicitly.)

    And thanks!

  • FormerMember
    0 FormerMember in reply to tdanner

    When I query our two Orion servers for Node data to then use to run scripts against said Nodes, is there a field I can check to make sure the Node is also in the NCM database?

    I fixed up my code per our conversation and am again getting a dang 500 Internal Server Error, and it's definitely a record that's not in the NCM. I hate to 'work around' a 500, but unless I can get nodes I'm sure are in the NCM, I'll have to catch the 500 and just assume it's a row/record not found error.