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.

Set NCM Credentials

Hello all -

I've managed to successfully create nodes using v3, and add that node to NCM with v2.  One thing I am not seeing though is  how to set the credentials for NCM?

I used

XmlDocument xdoc = new System.Xml.XmlDocument();

XmlElement[] elem = new System.Xml.XmlElement[1];

XmlElement xel = xdoc.CreateElement("coreNodeId");

this._NodeID.ToString();

client.invoke("Cirrus.Nodes", "AddNodeToNCM", elem);

Is there part of the XML that would set the credentials?

  • Hello, I'm affraid it's not possible to do it by using the verb "AddNodeToNCM" since the only acceptable argument is "CoreNodeId".

    Setting of the credentials is possible via Update/Set operation. Honestly I'm not very familiar with the language you use, but to demonstrate the principle, please see bellow the part of the code written in PowerShell:


    $Target="10.140.2.180"

    $swis = Connect-Swis -host $Target -UserName admin -Password "123" -V2

    [System.Int32]$NodeIdToAddToNCM = 11    ##Specify the nodeId you need to add to NCM

    Invoke-SwisVerb $swis Cirrus.Nodes AddNodeToNcm($NodeIdToAddToNCM)    ## Add Node to NCM

    [System.String] $Uri = Get-SwisData $swis ("SELECT Uri FROM Cirrus.Nodes WHERE CoreNodeID = " + $NodeIdToAddToNCM)    ##Get the Uri of the updated object

    Set-SwisObject $swis $Uri @{UserName='user1'; Password='bla'}    ##Specify the property bag to update and perform the Update action

    I hope this helps at least a bit.

    Honza

  • Thanks Jan.  Doesn't the NCM employ connection profiles?  So, I guess I would want to set the profile name rather than the user / pass.

    Language is c# emoticons_happy.png

  • Hello,

      To set the credentials for NCM,

    1. For adding credentials for already added node, use “UpdateSelectedNodeColumns verb and provide values for Username, Password, EnableLevel, EnablePassword,…
    2. You can also create connection profile using “AddConnectionProfile” and update ConnectionProfile property in Nodes using “UpdateSelectedNodeColumns”.
      Use Connection Profile in case of using the same credentials for multiple nodes.
    3. The credentials can be either encrypted or plain.

    It would be better to encrypt the credentials. To encrypt, use the below mentioned steps

      

    1. Use the verb ”EncryptData” against “Cirrus.Settings” entity to encrypt data. To use this connect to V2 certificate swis service.
    2. You can also decrypt the data using the verb “DecryptData”.  
  • Do I need to pass it in XML or in propertyBags?

    An example would be much appreciated!

  • AddConnectionProfile verb accepts 1 argument.

    1. ConnectionProfile - ConnectionProfile object. Incase you are creating a new connection profile.

    I've provided the ConnectionProfile class and the code to fill in the necessary values and create ConnectionProfile. This sample uses dummy values and fill with real values and use it.

    UpdateSelectedNodeColumns verb accepts 2 arguments.

    1. NCMNode - Node object. You can use GetNode verb to get the node details which can be edited and sent back as input to UpdateSelectedNodeColumns verb.
    2. String[] - Array of Column names which are updated.

    We need to provide these two objects as parameter (As ArrayOfXmlElement).

    Complete Code

    Use this code for creating a new connectionProfile and update a node with the created connection profile. If you have a connection profile already created, just update the node with the profileid.


    #region Creating Connection Profile

                var connectionProfile = new ConnectionProfile
                {
                    Name = "DummyName",
                    UserName = "DummyUserName",
                    Password = "DummyPassword"
                };

                var connectionProfiles = new[] { connectionProfile };

                var dcs = new DataContractSerializer(connectionProfile.GetType());
                var doc = new XmlDocument();
                using (var writer = doc.CreateNavigator().AppendChild())
                {
                    dcs.WriteObject(writer, connectionProfile);
                }

                var connectionProfileArguments = new ArrayOfXmlElement { XDocument.Load(new XmlNodeReader(doc)).Root };
                var cpResult = client.Invoke("Cirrus.Nodes", "AddConnectionProfile", connectionProfileArguments);
                var connectionProfileID = cpResult.Value;

                #endregion

                #region Code for getting a node

                //Getting the Node for given GUID
                var arguments = new ArrayOfXmlElement();
                arguments.Add(XElement.Parse("<Guid>8e1dd779-df78-4068-813c-0069e72bc6d3</Guid>"));
                var result = client.Invoke("Cirrus.Nodes", "GetNode", arguments);

                #endregion

                #region Code for Updating connection profile

                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(result.ToString());

                //Forming the NcmNode input
                XmlDocument xNewDoc = new XmlDocument();
                var rootNode = xNewDoc.CreateElement("NcnNode");
                rootNode.InnerXml = xDoc.FirstChild.InnerXml;
                xNewDoc.AppendChild(rootNode);
                xNewDoc.SelectSingleNode(@"/NcnNode/*[local-name() = 'ConnectionProfile']").InnerText = connectionProfileID;

                arguments = new ArrayOfXmlElement();
                arguments.Add(XElement.Parse(xNewDoc.OuterXml));
                arguments.Add(XElement.Parse("<ArrayOfstring xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><string>ConnectionProfile</string></ArrayOfstring>"));

                var result2 = client.Invoke("Cirrus.Nodes", "UpdateSelectedNodeColumns", arguments);

                #endregion

    ConnectionProfile Class


    [DataContract(Name = "ConnectionProfile", Namespace = "http://schemas.solarwinds.com/2007/08/informationservice/propertybag")]
            public class ConnectionProfile
            {
                public ConnectionProfile()
                {
                    Name = string.Empty;
                    UserName = string.Empty;
                    Password = string.Empty;
                    EnableLevel = "<No Enable Login>";
                    EnablePassword = string.Empty;
                    ExecuteScriptProtocol = "TELNET";
                    RequestConfigProtocol = "TELNET";
                    TransferConfigProtocol = "TELNET";
                    TelnetPort = 23;
                    SSHPort = 22;
                    UseForAutoDetect = false;
                }

                [DataMember(Name = "ID")]
                public int ID { get; set; }

                [DataMember(Name = "Name")]
                public string Name { get; set; }

                [DataMember(Name = "UserName")]
                public string UserName { get; set; }

                [DataMember(Name = "Password")]
                public string Password { get; set; }

                [DataMember(Name = "EnableLevel")]
                public string EnableLevel { get; set; }

                [DataMember(Name = "EnablePassword")]
                public string EnablePassword { get; set; }

                [DataMember(Name = "ExecuteScriptProtocol")]
                public string ExecuteScriptProtocol { get; set; }

                [DataMember(Name = "RequestConfigProtocol")]
                public string RequestConfigProtocol { get; set; }

                [DataMember(Name = "TransferConfigProtocol")]
                public string TransferConfigProtocol { get; set; }

                [DataMember(Name = "TelnetPort")]
                public int TelnetPort { get; set; }

                [DataMember(Name = "SSHPort")]
                public int SSHPort { get; set; }

                [DataMember(Name = "UseForAutoDetect")]
                public bool UseForAutoDetect { get; set; }
            }

  • Thanks madhavan! Why do you have to use v2 to access that verb? Is it something that's on its way out possibly?

  • NCM switched to SWISv3 in version 7.3.

  • do you have anything like this where we can specify connection profiles for NCM in python

    this is what I have:

      print("    Adding nodes to NCM... ", end="")

            self._swis.invoke('Cirrus.Nodes', 'AddNodeToNCM', self._nodeid)

            print("DONE!")

    how can add connection profile to that?

    thanks

  • How would this code look like in Powershell? I tried Creating an object from scratch of type "System.Xml.XmlElement#http://schemas.solarwinds.com/2007/08/informationservice/propertybag#ConnectionProfile" but it seems it does not work like that.

    I am interested in creating a connection profile from scratch using Powershell, right after initial installation, when there is none in the system.

  • This is all pretty out of date. There is just an API verb built in to do this.

    Have you installed the SDK on your server yet?

    GitHub - solarwinds/OrionSDK: SDK for the SolarWinds Orion platform, including tools, documentation, and samples in Powe…

    The format of the xml data you pass is like this, but with your values in the tags:

    <ConnectionProfile xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.solarwinds.com/2007/08/informationservice/propertybag"><EnableLevel></EnableLevel><EnablePassword></EnablePassword><ExecuteScriptProtocol></ExecuteScriptProtocol><ID>0</ID><Name></Name><Password></Password><RequestConfigProtocol></RequestConfigProtocol><SSHPort>0</SSHPort><TelnetPort>0</TelnetPort><TransferConfigProtocol></TransferConfigProtocol><UseForAutoDetect>false</UseForAutoDetect><UserName></UserName></ConnectionProfile>