NetXMS Support Forum

Please login or register.

Login with username, password and session length

Author Topic: [Solved] Script / modifyObject mapgroup / NullPointerException  (Read 398 times)

Fred

  • Newbie
  • *
  • Posts: 5
    • View Profile

Hello,
i have a problem to change  "Status Calculation Method" on mapgroup with a script,  mapgr is a NetworkMapGroup :

Code: [Select]
        print "mapgr.getObjectClassName(): %s " % ( mapgr.getObjectClassName())
        print "mapgr.getStatusCalculationMethod(): %s " % ( mapgr.getStatusCalculationMethod())
        md = NXCObjectModificationData(mapgr.getObjectId())
        print "md.getStatusCalculationMethod() : %s" % (md.getStatusCalculationMethod())
        md.setStatusCalculationMethod(3)
        print "md.getStatusCalculationMethod() : %s" % (md.getStatusCalculationMethod())
        session.modifyObject(md)

result :

Code: [Select]
mapgr.getObjectClassName(): NetworkMapGroup
mapgr.getStatusCalculationMethod(): 1
md.getStatusCalculationMethod() : 0
md.getStatusCalculationMethod() : 3
Traceback (most recent call last):
  File "Creation-de-map_3.py", line 12, in <module>
    session.modifyObject(md)
at org.netxms.client.NXCSession.modifyObject(NXCSession.java:4953)
at org.netxms.client.NXCSession.modifyObject(NXCSession.java:5111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NullPointerException: java.lang.NullPointerException

Why md status calculation is different from mapgr status calculation  ?

Any ideas?
Thanks

NetXMS Server Version 2.2.6 Build 9513 (2.2.6) (UNICODE)
NXCP: 4.48.1.13 (AES-256, Blowfish-256, 3DES, AES-128, Blowfish-128)
Built with: g++ (Debian 4.9.2-10) 4.9.2
« Last Edit: July 31, 2018, 10:35:48 am by Fred »
Logged

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6509
    • View Profile
Re: Script / modifyObject mapgroup / NullPointerException
« Reply #1 on: June 14, 2018, 10:37:03 am »

Hi,

that's an inconsistency in API - you should set all status calculation and propagation properties when modifying any of them. So in your case you have to call on md object: setStatusPropagationMethod, setFixedPropagatedStatus, setStatusShift, setStatusTransformation, setStatusSingleThreshold, setStatusThresholds. You can just pass values from appropriate getters on mdgr object.

Best regards,
Victor
Logged

Fred

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Script / modifyObject mapgroup / NullPointerException
« Reply #2 on: June 15, 2018, 09:39:36 am »

Thanks Victor,
Its working.

Regards
Logged