Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

copyDashboardState.py

VERSION 2  Click to view document history
Created on: Sep 14, 2009 11:21 AM by Noel Brockett - Last Modified:  Sep 14, 2009 11:21 AM by Zenoss API

Simple script to allow copying one users's dashboard layout to another user.

 

Files attached

 

File contents

#!/usr/bin/env python
import sys
import Globals
from transaction import commit
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
dmd = ZenScriptBase(connect=True).dmd

if len(sys.argv) < 3:
    print "Usage: %s <source_user> <destination_user>" % (sys.argv[0],)
    sys.exit(1)

sourceUser = getattr(dmd.ZenUsers, sys.argv[1], None)
if not sourceUser:
    print "%s is not a valid user." % (sys.argv[1],)
    sys.exit(2)

destUser = getattr(dmd.ZenUsers, sys.argv[2], None)
if not destUser:
    print "%s is not a valid user." % (sys.argv[2],)
    sys.exit(3)

print "Copying dashboard settings from %s to %s" % (sourceUser.id, destUser.id)
destUser.dashboardState = sourceUser.dashboardState
commit()
Attachments:
Note: binary attachments ending in .zip will need to be unzipped before use.
Comments (0)