1
2
3
4
5
6
7
8
9
10
11
12
13
14 """
15 Utility functions for command plugins.
16 """
17
18
19 from time import strftime
20
21 from Products.ZenUtils import Utils
22
23 from Products.DataCollector.plugins.DataMaps \
24 import RelationshipMap, ObjectMap, MultiArgs
25
26
35
36
38 """
39 Create a software dictionary that can be passed as the data parameter when
40 constructing an ObjectMap that represents a Software entity.
41 """
42 return {"id": Utils.prepId(prodKey),
43 "setProductKey": MultiArgs(prodKey, Utils.prepId(vendor)),
44 "setDescription": description,
45 "setInstallDate": formatDate(installDate)}
46
47
49 """
50 Takes a list of software dictionaries and returns a RelationshipMap that
51 represents that software collection.
52 """
53 kwargs = dict(compname="os", modname="Products.ZenModel.Software")
54 objmaps = []
55
56 for softwareDict in softwareDicts:
57 objmaps.append(ObjectMap(softwareDict, **kwargs))
58
59 return RelationshipMap("software", objmaps=objmaps, **kwargs)
60