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