Discussion:
Bulk remove all groups
deklan Van
2013-10-03 11:45:11 UTC
Permalink
deklan Van [http://community.zenoss.org/people/deklan] created the discussion

"Bulk remove all groups"

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

--------------------------------------------------------------
Hi All,

I have been using Zenoss for a large amount of time, however im faced with a requirement to delete all groups on a Zenoss server. There are currently more than 2000. I am able to use ZenCMD however im unsure as to a command that i can use to delete all groups on the server. all the groups are empty.

Any help would be much appricated.

Kind Regards
Deklan
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
mwcotton
2013-10-05 21:50:11 UTC
Permalink
mwcotton [http://community.zenoss.org/people/mwcotton] created the discussion

"Re: Bulk remove all groups"

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

--------------------------------------------------------------
I am speaking about older version, dont know about these newfangeled versions but I I would shut down all daemons except zenhub, then delete from the gui, it should go quick. Then when finished zenpack if you know what that is, and then shutdown zenoss and restart.
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jcurry
2013-10-07 09:50:51 UTC
Permalink
jcurry [http://community.zenoss.org/people/jcurry] created the discussion

"Re: Bulk remove all groups"

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

--------------------------------------------------------------
I have just done a very similar job on Systems, which should be identical to Groups.  In my case, I wanted to delete everything under my RIGS system.  I have a wee Python program which includes:

#!/usr/bin/env python
import Globals

from ZODB.transact import transact
from transaction import commit

from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from Products.ZenUtils.Utils import unused
unused(Globals)

dmd = ZenScriptBase(connect=True, noopts=True).dmd

@transact
def delOrgs():
    dmd.Systems.manage_deleteOrganizer('/Systems/RIGS')

delOrgs()
commit()


!!! I would make very sure that I had a Zenoss backup (zenbackup) before I did anything potentially this destructive!!!

Good practice appears to be that you create a little function with the @transact decorator - I cannot find any good documentation about this but I am finding more examples around Zenoss code that uses it and it does seem to provide much better stability if you are modifying the Zenoss Zope database.  Then you simply call your function and use commit to write back to the ZODB database.

Cheers,
Jane
--------------------------------------------------------------

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

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