Created
July 6, 2011 16:51
-
-
Save cluther/1067739 to your computer and use it in GitHub Desktop.
Changing Zenoss Permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
log = logging.getLogger('zen.ZenPack') | |
import Globals | |
from AccessControl import ClassSecurityInfo | |
from Products.ZenModel.Location import Location | |
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase | |
from Products.ZenModel.ZenossSecurity import ZEN_COMMON, ZEN_VIEW | |
from Products.ZenWidgets.ZenossPortlets import ZenossPortlets | |
Location.security = ClassSecurityInfo() | |
Location.security.declareProtected(ZEN_COMMON, 'getChildLinks') | |
Location.security.declareProtected(ZEN_COMMON, 'numMappableChildren') | |
Location.security.declareProtected(ZEN_COMMON, 'getGeomapData') | |
Location.security.declareProtected(ZEN_COMMON, 'getChildGeomapData') | |
Location.security.declareProtected(ZEN_COMMON, 'getSecondaryNodes') | |
Globals.InitializeClass(Location) | |
new_portlets = [] | |
for portlet in ZenossPortlets.portlets: | |
portlet['permission'] = ZEN_COMMON | |
new_portlets.append(portlet) | |
ZenossPortlets.portlets = new_portlets | |
class ZenPack(ZenPackBase): | |
def install(self, app): | |
super(ZenPack, self).install(app) | |
self.allowAuthenticatedRender(app.zport.RenderServer) | |
self.updatePortletPermissions(app.zport.ZenPortletManager) | |
def allowAuthenticatedRender(self, renderServer): | |
log.info('Allowing any authenticated access to RenderServer') | |
renderServer.manage_permission(ZEN_VIEW, ['Authenticated']) | |
def updatePortletPermissions(self, portletManager): | |
log.info("Enabling common access to all portlets.") | |
for portlet in ZenossPortlets.portlets: | |
portletManager.register_portlet(**portlet) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment