NetXMS Support Forum

English Support => General Support => Topic started by: bikeprata on May 06, 2015, 08:49:27 PM

Title: NxShell Interaction Help - Strange error in script
Post by: bikeprata on May 06, 2015, 08:49:27 PM
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.
Title: Re: NxShell Interaction Help - Strange error in script
Post by: technikcst on May 14, 2015, 03:04:26 PM
Hi,

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

Also using 2.0-M4

Regards,
Christoph
Title: Re: NxShell Interaction Help - Strange error in script
Post by: Victor Kirhenshtein on May 14, 2015, 10:07:59 PM
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
Title: Re: NxShell Interaction Help - Strange error in script
Post by: technikcst on May 15, 2015, 12:58:43 PM
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
Title: Re: NxShell Interaction Help - Strange error in script
Post by: Victor Kirhenshtein on May 15, 2015, 03:43:55 PM
We re-generate javadoc: https://www.netxms.org/documentation/javadoc/latest/ (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
Title: Re: NxShell Interaction Help - Strange error in script
Post by: technikcst on May 22, 2015, 10:54:47 AM
Thank you very much  :)