NetXMS Support Forum

Please login or register.

Login with username, password and session length

Author Topic: NXShell change geoLocation  (Read 142 times)

thierryc

  • Newbie
  • *
  • Posts: 4
    • View Profile
NXShell change geoLocation
« on: February 01, 2019, 05:39:16 pm »

Hello,

I am trying to set the geoLocation on some containers using nxshell.
I am not able to find how to set the geolocation neither how to update the geolocation of my node

cd = session.findObjectById(123)
geo = cd.geolocation
print geo

This works but now ...

geo.setLatitude(11.1) or anything  in this way does not work.

And then I can not find a  cd.setGeoLocation()
And neither  cd.geolocation = geo  works as it is a read-only attribute.

Regards.











Logged

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6451
    • View Profile
Re: NXShell change geoLocation
« Reply #1 on: February 02, 2019, 02:24:43 pm »

Hi,

Geolocation is an immutable object, so you have to create new object when you need different location. NetObj and derived classes are also immutable, so you have to use NXCObjectModificationData class and session.modifyObject method. Working example for getting and setting geo location for node:

Code: [Select]
from org.netxms.base import GeoLocation

node = session.findObjectByName("netxms")
print node.getGeolocation()
md = NXCObjectModificationData(node.getObjectId())
md.setGeolocation(GeoLocation(11.0, 22.0))
session.modifyObject(md)

Best regards,
Victor
Logged