def getZenPackName(self): ''' ''' if not self.ZENPACKID: from ZenPack import ZenPackException raise ZenPackException('The class %s must define ZENPACKID ' % str(self.__class__) + 'or override getZenPackName().') # Should we check to make sure ZENPACKID matches the name of an # installed ZenPack? return self.ZENPACKID
def manage_addZenPack(self, packId, REQUEST=None, devDir=''): """ Create a new zenpack on the filesystem with the given info. Install the pack. If REQUEST then render the REQUEST otherwise return the new zenpack. """ import Products.ZenUtils.ZenPackCmd as ZenPackCmd if not getattr(self.dmd, 'ZenPackManager'): msg = 'Your Zenoss database appears to be out of date. Try ' \ 'running zenmigrate to update.' if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Error', msg, priority=messaging.WARNING) return self.callZenScreen(REQUEST) from ZenPack import ZenPackNeedMigrateException raise ZenPackNeedMigrateException(msg) # Make sure a zenpack can be created with given info canCreate, msgOrId = ZenPackCmd.CanCreateZenPack(self, packId) if canCreate: packId = msgOrId else: if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Add ZenPack', msgOrId) return self.callZenScreen(REQUEST, redirect=False) from ZenPack import ZenPackException raise ZenPackException(msgOrId) if devDir == "": devDir = varPath("ZenPackSource") # Create it zpDir = ZenPackCmd.CreateZenPack(packId, devDir=devDir) # Install it zenPacks = ZenPackCmd.InstallEggAndZenPack(self.dmd, zpDir, link=True, forceRunExternal=True) zenPack = self.packs._getOb(packId, None) audit('UI.ZenPack.Create', packId) if REQUEST: if zenPack: return REQUEST['RESPONSE'].redirect( zenPack.getPrimaryUrlPath()) messaging.IMessageSender(self).sendToBrowser( 'Error', 'There was an error creating the ZenPack.', priority=messaging.WARNING) return self.callZenScreen(REQUEST) return zenPack