Discussion:
Copy/Override Template using zendmd
Gus N
2012-08-17 10:10:14 UTC
Permalink
Gus N [http://community.zenoss.org/people/dg1101] created the discussion

"Copy/Override Template using zendmd"

To view the discussion, visit: http://community.zenoss.org/message/67929#67929

--------------------------------------------------------------
Hello, relative newbie to the world of zenoss here!

I'm looking for a way of copying a template from one deviceClass to another using zendmd (to perform the same operation as the menu item "Override Template") Hoping to use zendmd so our installation/configuration of zenoss can be completely scripted.

I've seen examples of how to apply templates at a device level, but I can't seem to get them to work for a device class.

So, current situation is we have a template from a comunity ZenPack that applies to Devices\Servers. I want to make this apply to Devices\Servers\MyClass - a straightforward operation from within the GUI. (Essentially, I want the template to apply to all devices (existing and new) in \Servers\MyClass by default, but not to ones in \Servers)

So butchering a similar example (from http://community.zenoss.org/docs/DOC-2526 http://community.zenoss.org/docs/DOC-2526), what I've attempted is this:-

template = dmd.Devices.Servers.rrdTemplates.MyTemplate
dest = dmd.Devices.Servers.MyClass
dest._setObject(template.id,template_getCopy(dest))
commit()

This seems to create a copy of the template, but applying to "Devices\MyClass" instead of "Devices\Servers\MyClass"

Can anyone suggest a better method, or point me in the right direction. Apologies if I've performed some horrendous zendmd abuse!

--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/67929#67929]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Gus N
2012-08-17 11:17:09 UTC
Permalink
Gus N [http://community.zenoss.org/people/dg1101] created the discussion

"Re: Copy/Override Template using zendmd"

To view the discussion, visit: http://community.zenoss.org/message/67930#67930

--------------------------------------------------------------
With a bit of playing around, I found the error. The template should be copied to Devices.Server.MyClass.rrdTemplates. This appears to fix my problem, and all is well:

template = dmd.Devices.Server.rrdTemplates.MyTemplate
dest = dmd.Devices.Server.MyClass.rrdTemplates
dest._setObject(template.id,template._getCopy(dest))
commit()

--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/67930#67930]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...