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.

How can I set application custom properties with the Orion SDK?

FormerMember
FormerMember

This might be an easy one, but I am getting an error when attempting to set SAM Application Custom Properties with the SDK.

Basically, I'm following the example for setting custom properties for nodes, but I'm replacing node-related information in the URI with application information.

Here is the resulting URI, which I'm guessing is invalid: "swis://my_orion_server/Orion/Orion.APM.Application/ApplicationID=replace_with_application_id/CustomProperties"

Simplified script:

$hostname = my_orion_server

$appID = app_id_of_interest

$swis = Connect-Swis -Trusted -Hostname $hostname

$customProps = @{ Comments="Custom comment"; }

$uri = "swis://$hostname/Orion/Orion.APM.Application/ApplicationID=$appID/CustomProperties"

Set-SwisObject $swis -Uri $uri -Properties $customProps

Error message: "Entity Orion.APM.Application is hosted by entity Orion.Nodes."

Thanks in advance for any help!

  • You are very close! The format for an application custom properties uri is this:

    swis://$hostname/Orion/Orion.Nodes/NodeID=$nodeID/Applications/ApplicationID=$appID/CustomProperties

  • FormerMember
    0 FormerMember in reply to tdanner

    Hey Tim,

    So, if I want to do a REST call to do this, it's a POST to

    https://orionServer:17778/SolarWinds/InformationService/v3/Json/swis://orionServer/Orion/Orion.Nodes/NodeID=<NodeId>/CustomProperties

    and the payload/body data would look something like: ["fieldName":"NewValue"] ?


    Thanks!
    Scott

  • FormerMember
    0 FormerMember in reply to FormerMember

    Well hot dog, I found it!

    Right here in fact!

    Re: SWIS REST/JSON API

  • FormerMember
    0 FormerMember in reply to tdanner

    Hey guys and gals,

    So, I figured out (with the help of the post I found) how to set custom properties on Nodes. Using the information, I just assumed that setting them on Interface(s) would work pretty much the same way. So, I came up with the following:

    https://lsdorioneast:17778/SolarWinds/InformationService/v3/Json/swis://lsdorioneast/Orion/Orion.NPM.Interfaces/InterfaceID=18089/CustomProperties

    Body: {"i_mute":true,"i_muteStartTime":"2014-05-16T17:55:30","i_muteDuration":12}

    But of course that would make too much sense. I got the following message, which I'm pretty sure is trying to tell me something, but I'm not quite picking up what it's trying to lay down.

    "Message": "Entity Orion.NPM.Interfaces is hosted by entity Orion.Nodes.\r\nParameter name: entity"

    But then I remembered some examples I'd seen in the docs, so, I tried the following based on this example from the Orion SDK pdf: (ex: swis://localhost/Orion/Orion.Nodes/NodeID=1/Interfaces/InterfaceID=2)

    swis://lsdorioneast/Orion/Orion.Nodes/NodeID=467/Interfaces/InterfaceID=18089/CustomProperties

    which got me: "Message": "No such entity instance.\r\nParameter name: uri"

    So I give. Can someone please tell me how to set a custom property on an interface?


    Thanks,
    Scott Fraley

  • That's the message you would get if there were no interfaces with InterfaceID=18089 and NodeID=467. Are you sure those values are correct? In general, to find out the right form of the Uri for a given thing, you can run a query: SELECT Uri FROM <thing> WHERE <conditions>.

  • FormerMember
    0 FormerMember in reply to tdanner

    Yes, with face comfortably in palm I got that. I found another example in the doc which showed that my Uri was correct (and thanks for the tip on getting those btw!). I'd have sworn that number was correct, but once I found another that was definitely correct, it worked great.

    Thanks for your patients and help.  emoticons_wink.png

    -Scott Fraley

  • FormerMember
    0 FormerMember in reply to tdanner

    Having another problem I don't understand. I'm writing a Cmdlet to 'mute' a given node, as well as it's connected interfaces. So, I get the NodeID of the node the user provides by name or IP address, then I do the following query to get the InterfaceIDs of said connected interfaces so that I can mute them too.

    "SELECT DestInterfaceID, N.NodeName, I.InterfaceName FROM Orion.TopologyConnections TC JOIN Orion.NPM.Interfaces I ON I.InterfaceID = TC.DestInterfaceID JOIN Orion.Nodes N ON N.NodeID = I.NodeID WHERE SrcNodeID = {Specified Node's ID} AND DestInterfaceID IS NOT NULL";

    Once I've set the Node's custom properties (which 'mutes' the node), I query [Orion.TopologyConnections] for the collection of connected Interfaces per the above query. Then I go into a foreach and try to set the custom properties of each connected Interface [in order to mute it].

    Here is the Uri & body data that I POST to Orion.

    DEBUG: PerformNodeMuting(): Uri:
    https://orioneast:17778/SolarWinds/InformationService/v3/Json/swis://lsdorioneast/Orion/Orion.Nodes/NodeID=467/Interfaces/InterfaceID=17764/CustomProperties
    DEBUG: PerformNodeMuting(): Payload: {"i_mute":true,"i_muteStartTime":"2014-05-16T13:54:50","i_muteDuration":12}

    And then I get this:

    Set-DeviceMute : HttpClient.SendAsync(HttpWebRequest) call failed.
    At line:1 char:1
    + Set-DeviceMute NODE_NAME $true 12 $creds
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (StatusCode: 400...ication/json
    }:HttpResponseMessage) [Set-DeviceMute], Exception
        + FullyQualifiedErrorId : 400 (Bad Request),Microsoft.XBOX.LsdNet.CSCmdlets.SetDeviceMuteCmdlet

    Now, if I try this via SoapUI, I get "Message": "No such entity instance.\r\nParameter name: uri". I guess my question is, what the heck is wrong with my query (or is that the wrong table for what I need) that it's giving me these IDs that then supposedly don't exist, or who's custom properties I can't set?

    P.S. 400 (Bad Request) seems like a strange error to get given what Orion seems to actually be trying to tell me. Although I guess 404 could make you think your call was bad, and not the data item you were trying to affect.

    TIA,

    Scott

  • Re: HTTP response codes. Looking at the code, it appears we are returning 401 Unauthorized for bad credentials, 403 Forbidden for good credentials but not allowed to perform requested operation, and 400 Bad Request for all other conditions. I agree that 404 would make sense in this case, and 500 would probably be a better choice for generic unhandled exception.

    Without seeing how you are building up the Uri in PerformNodeMuting, I have to guess at the cause. Are you combining SrcNodeID with DestInterfaceID to form the Uri? Because those are from different devices, so a Uri made by combining them will not refer to anything. What if you ask SWIS for the Uri in your initial query? Like this:

    SELECT DestInterfaceID, N.NodeName, I.InterfaceName, I.Uri FROM Orion.TopologyConnections TC JOIN Orion.NPM.Interfaces I  ...