NxShell Interaction Help - Strange error in script

Started by bikeprata, May 06, 2015, 08:49:27 PM

Previous topic - Next topic

bikeprata

Hello everyone!

I'm creating a script to populate nodes from my network, getting them from a ".csv" file. It's working pretty fine, but I can't use the method "setIpAdress()" from NXCObjectCreationData. In the method call bellow "cd" is a NXCObjectCreationData object and "objectIp" is a string with the IP formated such as in "192.168.2.1".

cd.setIpAddress(InetAddress.getByName(objectIp))

When I execute the script I get the following error:

QuoteTypeError: setIpAddress(): 1st arg can't be coerced to org.netxms.base.InetAddressEx

I couldn't find the class org.netxms.base.InetAddressEx on the API and it's stated on the NCXObjectCreationData reference that "setIpAdress()" should receive an InetAdress instance.

Could you guys help me on this?

Thanks in advance!

Edit: I'm using the 2.0.M4 version.

technikcst

Hi,

i am getting the same error in my script. Are there any solutions?

Also using 2.0-M4

Regards,
Christoph

Victor Kirhenshtein

Hi,

problem is that javadoc is outdated. In version 2.0-M4 NXCObjectCreationData.setIpAddress expects object of type InetAddressEx. You can create it as follows:

InetAddressEx(InetAddress.getByName(objectIp), 0)

but preferred way for creating node objects is to use setPrimaryName instead:

cd.setPrimaryName(objectIp)

Best regards,
Victor

technikcst

Hi Victor,

thank you  for your answer =)
I was trying to set the ip and netmask manually for an object because if i create a node in GUI, the netmask of the generated node is wrong. But as i see now, the API seems to be really outdated ('org.netxms.client.NXCObjectCreationData' object has no attribute 'setIpNetMask') is there a new documentation somewhere?

Thanks for your help,
Christoph

Victor Kirhenshtein

We re-generate javadoc: https://www.netxms.org/documentation/javadoc/latest/. Now it is for actual development branch (you can consider it 2.0-M4 as there was no changes in API since last release).

Best regards,
Victor