NetXMS Support Forum

English Support => General Support => Topic started by: MarcusH on May 10, 2022, 08:26:40 AM

Title: Trusted Nodes
Post by: MarcusH on May 10, 2022, 08:26:40 AM
Hi,

Are there any ways to manage trusted nodes in bulk or do you need to righ click every single node and add trusted node?
Title: Re: Trusted Nodes
Post by: Filipp Sudanov on May 10, 2022, 12:54:44 PM
First of all, you can turn checking of trusted nodes on server level by changing CheckTrustedNodes server configuration parameter.

Mass changins of node properties is only possible with nxshell - you'd need to create a script using jithon. nxshell communicates with the same api as management client, so everything that could be done via client can be done in nxshell.
API documentation is here: https://www.netxms.org/documentation/javadoc/latest/index.html
Some information about nxshell is here: https://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations
Title: Re: Trusted Nodes
Post by: MarcusH on May 10, 2022, 02:48:18 PM
Perfect thanks alot, i have had trusted nodes active for a long time just first time i need to add a trusted node on a lot of nodes.
Title: Re: Trusted Nodes
Post by: MarcusH on May 11, 2022, 08:39:11 AM
Got a script working that loops all nodes in a container but i cannot get setTrustedNodes to work, i think i have it down to NXCObjectModificationData not working in my case, happy for any pointers :)

Tried this simple code for verification and it does not work only get NoneType from data.

print node.getObjectId()
data = NXCObjectModificationData(node.getObjectId())
print data.getName()
Title: Re: Trusted Nodes
Post by: MarcusH on May 11, 2022, 09:44:23 AM
Here is the entire code i am trying to get working, i get TypeError: setTrustedNodes(): 1st arg can't be coerced to java.lang.Long[]

# Add trusted nodes to list
trustednodes = [session.findObjectById(objectID)]

# Container to add trusted nodes to
container = session.findObjectById(objectID)

# Loop nodes in container
for node in container.getAllChildren(objects.GenericObject.OBJECT_NODE):
print node.getObjectName()
data = NXCObjectModificationData(node.getObjectId())
data.setTrustedNodes(trustednodes)
session.modifyObject(data)
Title: Re: Trusted Nodes
Post by: Victor Kirhenshtein on May 11, 2022, 10:20:16 AM
Argument for setTrustedNodes is array of object identifiers, not array of objects, so probably something like this will work:
data.setTrustedNodes([trustedNodeId])
where trustedNodeId is an ID of node to be set as trusted.

Best regards,
Victor
Title: Re: Trusted Nodes
Post by: MarcusH on May 11, 2022, 10:25:12 AM
Ah i got it working with trustednodes = [session.findObjectById(objectID).getObjectId()] but data.setTrustedNodes([trustedNodeId]) is cleaner
Title: Re: Trusted Nodes
Post by: Victor Kirhenshtein on May 11, 2022, 10:33:13 AM
session.findObjectById(objectID).getObjectId() is kind of pointless - you already know object ID, but you use it to find object by that ID, only to get that same ID from object...
Title: Re: Trusted Nodes
Post by: MarcusH on May 11, 2022, 10:38:49 AM
Indeed i was deep in loops of trial and error to get it to work and i just tested it and it worked and just as i saw your reply i got how simple it was and how unnecessary advanced i made it :)