solarwinds / OrionSDK

SDK for the SolarWinds Orion platform, including tools, documentation, and samples in PowerShell, C#, Go, Perl, and Java.
https://thwack.com/OrionSDK
Apache License 2.0
397 stars 139 forks source link

SWIS exception after SolarWinds upgrade #305

Closed oceania-npc closed 2 years ago

oceania-npc commented 2 years ago

After upgrading NCM from 2020.2.4 to 2020.2.6 HF2, our existing integration breaks with the following error:

ERROR SolarWinds.InformationService.Core.InformationService - (null) (null) Exception caught in method SolarWinds.InformationService.Core.InformationService.Invoke SolarWinds.InformationService.Verb.VerbExecutorException: ?Verb Cirrus.ConfigArchive.Execute: Not Found at SolarWinds.InformationService.Core.InformationService.Invoke[T](String entity, String verb, Action'1 setupParameters, Func'2 extractReturnValue)

Contacted Solarwinds support and they are washing their hands of it. Created a Thwack thread in attempt to get help:

https://thwack.solarwinds.com/product-forums/the-orion-platform/f/orion-sdk/92749/provisioning-of-node-fails-after-hf-update

Any idea what to check or look for regarding this error? Everything was working perfectly pre-upgrade - no changes to our integration recently.

oceania-npc commented 2 years ago

Debug from the Orion SWIS v3.0 information service log. Changed sensitive information but same error: `2021-10-25 08:24:33,418 [85] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null) Exception for Operation:

eea284f9-5aea-4052-ab6b-b2f08faaa562 system set host-name "BRRO_135415_NC3132_5314" port set port 2 desc "BRRO_12341_NC4314_1352/5" snmp set location "123 Road 5 ,BlahBlah" vlan remove vlan 1 port 2 config save portal

2021-10-25 08:24:33,418 [85] ERROR SolarWinds.InformationService.Core.InformationService - (null) (null) Exception caught in method SolarWinds.InformationService.Core.InformationService.Invoke SolarWinds.InformationService.Verb.VerbExecutorException: Verb Cirrus.ConfigArchive.Execute: Not found at SolarWinds.InformationService.Core.InformationService.Invoke[T](String entity, String verb, Action1 setupParameters, Func2 extractReturnValue)`

danjagnow commented 2 years ago

See the response from @kmsigma here. The Execute verb was deprecated in favor of the ExecuteScript, ExecuteScriptOnNodes, and ExecuteScriptePerNode verbs.

oceania-npc commented 2 years ago

Thanks @danjagnow

The THWACK mod mentioned Cirrus.ConfigArchive may go away. Is there any current replacement for ExecuteScript in the NPM module?

I am now seeing that Cirrus.TransferQueue is also deprecated. There is an NPM.TransferResults in SWQL Studio but I do not see the Status, Error, and Log columns that existed for Cirrus.TransferQueue. We use this to get the result of the script.

Our current code looks like this:

"SELECT T.Status, T.Error, T.Log FROM Cirrus.TransferQueue T WHERE T.TransferID=@transferId", new {transferId}

Any idea what the equivalent replacement would be?

kmsigma commented 2 years ago

The THWACK mod mentioned Cirrus.ConfigArchive may go away. Is there any current replacement for ExecuteScript in the NPM module?

For clarity: What I stated is that the Cirrus name is incredibly old and may be slowly phased over to the newer NCM (not NPM as stated above) namespace.

That said, it looks like NCM.TransferResults contains what you are requesting.

SELECT Status, ErrorMessage AS [Error], DeviceOutput AS [Log] FROM NCM.TransferResults WHERE TransferID = @TransferID

This was also answered on the above thread.

oceania-npc commented 2 years ago

Thanks @kmsigma! I see there is a TransferResults link in the SWQL Studio for ConfigArchive. I assume that would be the results object, and if so, how do we go about accessing that result object via an SWIS query?

kmsigma commented 2 years ago

You should be able to use: SELECT Status, ErrorMessage AS [Error], DeviceOutput AS [Log] FROM NCM.TransferResults WHERE TransferID = @TransferID Instead of the query you are referencing above.

Note: In my lab, I don't have data in this entity, but the field names appear to line up. Test it with your own environment in SWQL Studio.

oceania-npc commented 2 years ago

Thanks @kmsigma! First we run Cirrus.ConfigArchive.ExecuteScript, which executes the commands. Then we want to grab the result of that ExecuteScript which according to SWQL Studio has a link to TransferResult. In order to query the TransferResults table, we need the correct TransferID. How is that generated or discovered? i.e. once ExecuteScript is run, how do we get the results in TransferResult? The TransferID is generated after ExecuteScript runs, so is there a way to know what the TransferID will be beforehand in order to pull the result of the execution? Or does ExecuteScript return the TransferID?

kmsigma commented 2 years ago

Isn't TransferId returned after you call the ExecuteScript verb? image

<Return>
    <guid>TransferId</guid>
</Return>

Then you just use the above query with that transfer ID.

oceania-npc commented 2 years ago

Ah that did the trick, @kmsigma! The previous developer went through some convoluted way of getting the TransferId. One more question - previously we used the Error field (now NCM.TransferResults.ErrorMessage) to determine if there was an error with the script. Previously It could be false or true but now it can be null with Error Message. I would prefer to use the Status field to determine success/fail - what are the possible values for the Status field and what do they translate to regarding success, failure, etc?

kmsigma commented 2 years ago

I'd have to defer this to another individual who has more in depth details on the NCM/Cirrus entities.

What I've (personally) done in the past is to find correlations is query the table in question (NCM.TransferResults) for all entities and see if you can determine a relationship between the fields (Status and ErrorMessage in your case).

SELECT [TransferResults].TransferID
     , [TransferResults].NodeID
     , [TransferResults].Action
     , [TransferResults].RequestedConfigType
     , [TransferResults].RequestedScript
     , [TransferResults].RequestedReboot
     , [TransferResults].ConfigID
     , [TransferResults].TransferProtocol
     , [TransferResults].[Status]
     , [TransferResults].ErrorMessage
     , [TransferResults].DeviceOutput
     , [TransferResults].[DateTime]
     , [TransferResults].UserName
FROM NCM.TransferResults AS [TransferResults]
ORDER BY [DateTime] DESC
oceania-npc commented 2 years ago

Thanks @kmsigma! Found what the possible Status field values are: https://github.com/solarwinds/OrionSDK/wiki/NCM-Config-Transfer

Status - enum status of transfer: Queued = 0 - means transfer is waiting for execution in queue, Transferring = 1 - means transfer is executing right now, Complete = 2, Error = 3 ErrorMessage - transfer error message. Value is populating only in case Status is equal to Error