Hi,
I have a question. Can be added a node via SWIS (Orion SDK) ? Can you help me about that? -like sample code-
(I'm working on ASP .Net / C# project about that subject.)
Thanks.
Hello again,
That below code is adding an existing Node (created runtime) to NCM. There is only question & problem. If I want to use AddNode method, I don't know to pass NCMNode object to AddNode Verb by XML. Can you give any suggest?
XmlDocument xdoc = new XmlDocument();XmlElement[] elem = new System.Xml.XmlElement[1];XmlElement xel = xdoc.CreateElement("coreNodeId");xel.InnerText = nodeID;elem[0] = xel;
client.Invoke("Cirrus.Nodes", "AddNodeToNCM", elem);
I'm not 100% sure on this, but I don't think so because, by default, SWIS is a read-only system.
For example, Orion's SDK documentation states:
"Common SQL Constructs Not Supported
SWQL does not support the following common SQL constructs:
* SELECT * FROM … (You must list the actual properties you want to select.)
* UPDATE, INSERT, DELETE, etc. (You can only use SWQL to read data.)"
And I believe what you're looking for is an insert.
I'm actually learning to work with Orion and ASP.NET and C# at the moment, too. What are you trying to do?
I want to add node to NCM. I can add/delete/update node to Solarwinds via SWIS. I researched and found AddNode and AddNodeToNCM on SWQL at Cirrus.Nodes entity. I can't add existing node at Solarwinds to NCM via AddNode method, passing coreNodeID. I got an error "Node Id 2 does not exist Parameter name: nodeId". So, how can I add existing node at Solarwinds to NCM?
The verb you are looking for is Cirrus.Nodes.AddNodeToNCM. Just pass the node id (i.e., "2") and it should do what you want.
satventures, SWIS does not support write operations (INSERT/UPDATE/DELETE) through the Query interface, but it does have a different interface for handling write operations. It has specific calls for Create, Update, and Delete plus a general purpose Invoke method for doing more complex operations that do not map to simple Create/Update/Delete. juniordev's "add an existing NPM node to NCM" is an example of one of these more complex operations.
Ah, awesome, thank you! I've only been working with SQL, Orion, C#, ASP.NET, and networking for about a month now, so that helps a lot.
Thanks tdanner. I don't have to try yet but it's helpful. I have just another question. Can I add node directly to standalone NCM (not relative to NPM) via AddNode method which is required SolarWinds.NCM.Contracts.InformationService.NCMNode ?
PS: When I try to AddNode method, I gave "Access Cirrus.Node is denied" error.
That's my code.
string uri = swis.Create("Orion.Nodes", new PropertyBag
{
{"EntityType", "Orion.Nodes"},
{"IPAddress", "192.168.1.1"},
{"Caption", "192.168.1.1"},
{"SysName", "192.168.1.1"},
{"DynamicIP", false},
{"EngineID", 1},
{"Status", 1},
{"Allow64BitCounters", true},
{"ObjectSubType", "SNMP"},
{"SysObjectID", ""},
{"MachineType", ""},
{"VendorIcon", ""},
{"Community", ""},
{"SNMPVersion", 2},
{"MemoryUsed", -2},
{"CPULoad", -2},
{"PercentMemoryUsed", -2 }
//,{"Test", "CustomPropTest"}
});
string nodeID = uri.Replace("swis://./Orion/Orion.Nodes/NodeID=", "");
string uriCM = swis.Create("Cirrus.Nodes", new PropertyBag
{"coreNodeId", nodeID}
Console.WriteLine(uriCM);
I'm still researching. I got this error below code part. : "Cirrus.Nodes.AddNodeToNCM: Cannot find assembly". I couldn't find the required assembly for that adding process.
ProxyMarshalHelper helper = new ProxyMarshalHelper();
helper.ArgsStart();
helper.ArgsAdd(typeof(System.Int32), nodeID);
var element = new ArrayOfXmlElement();
element.AddRange(helper.ArgsEnd());
client.Invoke("Cirrus.Nodes", "AddNodeToNCM", element);
Don't use AddNode. Instead, add your node to Orion using the documented method (call Create on Orion.Nodes, then Create on Orion.Pollers to set up polling) then call Cirrus.Nodes.AddNodeToNCM.
Yo T! ( ;D )
So, is it possible to add Node(s) [to Orion.Nodes] via C# and the REST API, and if so, ya got any sample code? I've been reading the SDK doc (Orion SDK (1.8)) and the only example is for PowerShell and since I'm using REST, I've got no idea how to extrapolate that code into what I need.
Help much appreciated!
Thanks,
Scott
Here's the REST equivalent of some of the PowerShell operations in the CRUD.AddNode.ps1 sample:
PowerShell
New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $nodeProps
return value: new object's Uri
POST https://server:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes
body: node properties as a Json object
response: new object's Uri as a Json string
Get-SwisObject $swis -Uri $newNodeUri
return value: node's properties as a PowerShell object
GET https://server:17778/SolarWinds/InformationService/v3/Json/swis://server/Orion/Orion.Nodes/NodeID=1234
response: node properties as a Json object
POST https://server:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Pollers
body: poller properties as a Json object
Hope that helps. Let me know if you need more detail - I'm assuming you are already handling the REST authentication and so on.
Ok, great!
Now, I've noticed the following in the document (Orion SDK); "IPAddressGUID [is a] Node’s IP address encoded in [a] GUID value" Umm, ok. Seems a tad odd, but ok. The only problem is that I have no idea how to do this encoding. And what's more frustrating is that I'd SWEAR I've seen it discussed .. somewhere, but can't remember for the life of me. Can someone point me at the instructions for how to do this?
Also, while I'm ask'en questions; When you say "body: node properties as a Json object," is the following what we're talking about?
{"EntityType":"Orion.Nodes", "IPAddress":"10.0.0.1", "IPAddressGUID":"0100000a-0000-0000-0000-000000000000", ... "Community":"public"}
Thanks again!
Scott Fraley
Yes, it is definitely a tad odd. I'm trying to get that cleaned up so SDK users do not have to deal with that. Here's PowerShell code for making the IPAddressGUID value:
function ip2guid($ipString) { $ip = [System.Net.IPAddress]::Parse($ipString) $src = $ip.GetAddressBytes(); $data = new-object byte[] 16 $src.CopyTo($data, $data.Length - $src.Length) $dest = new-object byte[] 16 [Array]::Copy($data, 12, $dest, 0, 4) [Array]::Copy($data, 10, $dest, 4, 2) [Array]::Copy($data, 8, $dest, 6, 2) [Array]::Copy($data, 6, $dest, 8, 2) [Array]::Copy($data, 0, $dest, 10, 6) return (New-Object Guid (,$dest)).ToString()}
And yes, that's exactly what I mean by "node properties as a json object".
Great, I've got that converted to C# and will be testing it as soon as other issues have been put to bed.
re: the json payload for adding a Node, I don't suppose I can do the following?
{"EntityType":"Orion.Nodes", "IPAddress":"10.10.220.32", ... "Community":"public", "HardwareHealthInfos.Model":"ModelNumberString", "HardwareHealthInfos.ServiceTag":"SerialNumberString"} ?
No, you can't use navigation properties in that context. Only the actual (direct) properties of Orion.Nodes.
Has anyone seen a python script for properly adding a new node to NPM?
Never mind. I found some samples in the Orion SDK.
orionsdk-python/add_node.py at master · solarwinds/orionsdk-python · GitHub
Here's one approach: https://github.com/solarwinds/orionsdk-python/blob/master/samples/add_node.py
And here's another: https://github.com/solarwinds/orionsdk-python/blob/master/samples/discover_one_node.py