Package Products :: Package Zuul :: Package routers :: Module zenpack
[hide private]
[frames] | no frames]

Source Code for Module Products.Zuul.routers.zenpack

 1  ############################################################################## 
 2  #  
 3  # Copyright (C) Zenoss, Inc. 2009, all rights reserved. 
 4  #  
 5  # This content is made available according to terms specified in 
 6  # License.zenoss under the directory where your Zenoss product is installed. 
 7  #  
 8  ############################################################################## 
 9   
10   
11  """ 
12  Operations for ZenPacks. 
13   
14  Available at:  /zport/dmd/zenpack_router 
15  """ 
16   
17  import logging 
18  from Products.ZenUtils.Ext import DirectRouter, DirectResponse 
19  from Products import Zuul 
20  from Products.Zuul.decorators import require 
21  from Products.ZenMessaging.audit import audit 
22   
23  log = logging.getLogger('zen.ZenPackRouter') 
24 -class ZenPackRouter(DirectRouter):
25 """ 26 A JSON/ExtDirect interface to operations on ZenPacks 27 """ 28
29 - def _getFacade(self):
30 return Zuul.getFacade('zenpack', self.context)
31
32 - def getEligiblePacks(self, **data):
33 """ 34 Get a list of eligible ZenPacks to add to. 35 36 @rtype: DirectResponse 37 @return: B{Properties}: 38 - packs: ([dictionary]) List of objects representing ZenPacks 39 - totalCount: (integer) Total number of eligible ZenPacks 40 """ 41 devZenPacks = self._getFacade().getDevelopmentZenPacks() 42 packs = [{'name': zp.getId()} for zp in devZenPacks] 43 packs = sorted(packs, key=lambda pack: pack['name']) 44 return DirectResponse(packs=packs, totalCount=len(packs))
45 46 @require('Manage DMD')
47 - def addToZenPack(self, topack, zenpack):
48 """ 49 Add an object to a ZenPack. 50 51 @type topack: string 52 @param topack: Unique ID of the object to add to ZenPack 53 @type zenpack: string 54 @param zenpack: Unique ID of the ZenPack to add object to 55 @rtype: DirectResponse 56 @return: Success message 57 """ 58 self._getFacade().addToZenPack(topack, zenpack) 59 audit('UI.ZenPack.AddObject', zenpack, object=topack) 60 return DirectResponse.succeed()
61
62 - def getZenPackMetaData(self, zenpacks=None):
63 """ 64 Return the list of meta-data information about installed ZenPacks. 65 66 @type topack: list of strings 67 @param topack: Unique IDs of the installed ZenPack 68 @rtype: DirectResponse 69 @return: Success message 70 """ 71 infos = self._getFacade().getZenPackInfos(zenpacks) 72 data = Zuul.marshal(infos) 73 return DirectResponse.succeed(count=len(infos), data=data)
74