Trusted Nodes

Started by MarcusH, May 10, 2022, 08:26:40 AM

Previous topic - Next topic

MarcusH

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?

Filipp Sudanov

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

MarcusH

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.

MarcusH

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()

MarcusH

#4
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)

Victor Kirhenshtein

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

MarcusH

Ah i got it working with trustednodes = [session.findObjectById(objectID).getObjectId()] but data.setTrustedNodes([trustedNodeId]) is cleaner

Victor Kirhenshtein

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...

MarcusH

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 :)