TECHZEN Zenoss User Community ARCHIVE  

Obtaining a dmd object in a ZenPack init file top level

Subject: Obtaining a dmd object in a ZenPack init file top level
Author: Pheripheral Pheripheral
Posted: 2016-10-03 10:24


Im attempting to develop a ZenPack to carry out some data loading from a config file and push it into zenoss via direct dmd manipulation. This is on Zenoss 4.2.5

Ive got this working when driven by independent user actions in the GUI (via some new menu additions) and when called from inside the ZenPack class in the init file of the ZenPack.

However, Id also like this to be run from the top level of the init file, so that the config is picked up whenever zenoss is restarted.

When run from inside the zenpack class I can grab a dmd object via app.zport.dmd as the app is passed into the install method.

What Im having a problem with is obtaining a dmd object to pass to my code from this top level of the init file.

Can anyone suggest a way this can be done from here

Subject: What are you trying to load?
Author: Jay Stanley
Posted: 2016-10-11 13:51

What are you trying to load I assume the config file can be changed and that is why you need to load it each time What are you using this data for within Zenoss

Just trying to get an idea of what you are trying to accomplish, so I can help accordingly.

Subject: Yep, as the config file may
Author: Pheripheral Pheripheral
Posted: 2016-10-12 03:07

Yep, as the config file may change i want to be able to auto load ta new config on a zenoss restart. I've got it reading a flag from the config regarding whether or not to reload a config on restart.

The config is loading in various aspects of the zenoss configuration - system settings, organiser tree hierarchy, device list, users data... and these are loaded in via calls to various methods on the facades etc. (e.g. dmd.ZenUsers.manage_addUser or deviceFacade.addDevice ...)

So hoping to find a method of grabbing a dmd object from within the top level of the init file to pass into the methods that then call the various addDevice etc... methods.

Thanks for replying!

Subject: So, you are using an outside
Author: Jay Stanley
Posted: 2016-10-14 10:36

So, you are using an outside config file that basically configures your Zenoss environment. And these settings can change from restart to restart

Subject: Yep that's pretty much what
Author: Pheripheral Pheripheral
Posted: 2016-10-17 03:29

Yep that's pretty much what we're trying to do, essentially be able to reconfigure zenoss from our config file on startup without a user having to get involved.


Subject: Hi,
Author: [Not Specified]
Posted: 2017-01-11 10:05


Maybe this may help you:

It instantiates zope application and takes dmd from it.

app =
zport = app.zport
dmd = zport.dmd

< Previous
zenup issue, product not found: zenoss-core-4.2.5
Create development environment