NetXMS Support Forum

English Support => General Support => Topic started by: suphu on October 01, 2020, 06:15:48 PM

Title: Create new Zone using nxshell
Post by: suphu on October 01, 2020, 06:15:48 PM
Hi,

Is it possible to create a new zone using nxshell in version 3.5?

Thanks.
Title: Re: Create new Zone using nxshell
Post by: Filipp Sudanov on October 01, 2020, 06:22:10 PM
nxshell allows to do anything the management console can do.

Zone creation should be similar to node creation (see examples here: https://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations#Create_Container_and_some_nodes)
you just need to specify another object class
Title: Re: Create new Zone using nxshell
Post by: suphu on October 02, 2020, 08:23:22 PM
Thanks.  I will give that a try and post my code snippet when I get it working.
Title: Re: Create new Zone using nxshell
Post by: suphu on October 06, 2020, 09:29:36 PM
Yep - worked like a charm!

parentId = objects.GenericObject.NETWORK # Entire Network root
cd = NXCObjectCreationData(objects.GenericObject.OBJECT_ZONE, "Sample Zone", parentId);
zoneId = session.createObject(cd) # createObject return ID of newly created object
print '"Sample Zone" created, id=%d' % (zoneId, )