![]() |
![]() |
Subject: | zenoss batch add nested locations |
Author: | [Not Specified] |
Posted: | 2014-04-28 17:57 |
Hi,
Im looking at ways i can batch add locations under existing organizers.
For insance
i have under locations
/cityA/
/cityB/
How would i add
/cityA/townA
to an existing cityA using batchaddlocations.py script below...if i try to prefix cityA to name it fails.
#!/usr/bin/env python
import Globals
from transaction import commit
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
dmd = ZenScriptBase(connect=True).dmd
file = open('/home/zenoss/provisioning/location.txt', 'r')
for line in file:
line = line.rstrip()
name, address = line.split('\t')
dmd.Locations.manage_addOrganizer(name)
location = getattr(dmd.Locations, name)
location.address = address
commit()
file.close()
Subject: | location organizer syntax updates |
Author: | [Not Specified] |
Posted: | 2014-07-07 19:22 |
cityA = dmd.Locations.unrestrictedTraverse('cityA')
cityA.manage_addOrganizer('sub_cityA')
sub_cityA = cityA.unrestrictedTraverse('sub_cityA')
sub_cityA.address = '186'
commit()
or sub_cityA = dmd.Locations.unrestrictedTraverse('cityA/sub_cityA')
or
sub_cityA = [x for x in cityA.getSubOrganizers() if x.id == 'sub_cityA'][0]
or
sub_cityA = cityA.getObjByPath('sub_cityA')
the usage of unrestrictedTraverse allows for spaces in the location name that other methods wont allow.
Thanks,
Eric
< |
Previous Changing a Config Property in Mass? |
Next Modify File for ZenUp ZUP |
> |