1
2
3
4
5
6
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')
25 """
26 A JSON/ExtDirect interface to operations on ZenPacks
27 """
28
30 return Zuul.getFacade('zenpack', self.context)
31
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')
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
74