1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__ = "Manage ZenPack-provided daemons"
15
16 import Globals
17 import os
18
19 from Products.ZenUtils.PkgResources import pkg_resources
20
21 from Products.ZenUtils.CmdBase import CmdBase
22 from Products.ZenUtils.ZenPackCmd import ZENPACK_ENTRY_POINT
23 from Products.ZenModel.ZenPackLoader import ZPLDaemons
24 from Products.ZenUtils.Utils import zenPath
25
26
28 """
29 Return a list of the names of the daemons provided by the given ZenPack.
30 If no ZenPack is specified then list all daemons provided by all ZenPacks.
31 """
32 dList = []
33 zpl = ZPLDaemons()
34
35 for entry in pkg_resources.iter_entry_points(ZENPACK_ENTRY_POINT):
36 module = entry.load()
37 dList += zpl.list(os.path.dirname(module.__file__), None)
38
39 prodDir = zenPath('Products')
40 for item in os.listdir(prodDir):
41 if not item.startswith('.'):
42 dList += zpl.list(os.path.join(prodDir, item), None)
43 return dList
44
45
47 """
48 Utilities for handling ZenPack-provided daemons
49 """
50
52 """
53 Execute the user's request.
54 """
55
56 if self.options.list:
57 dList = NameZenPackDaemons()
58 if dList:
59 print '\n'.join(dList)
60 else:
61 self.parser.print_help()
62
63
65 self.parser.add_option('--list',
66 dest='list',
67 default=False,
68 action='store_true',
69 help='List the names of ZenPack-supplied daemons'
70 )
71 CmdBase.buildOptions(self)
72
73
74 if __name__ == '__main__':
75 zp = ZenPackDaemons()
76 zp.run()
77