1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from Globals import InitializeClass
16 from Products.ZenModel.ZenModelRM import ZenModelRM
17 from Products.ZenRelations.RelSchema import *
18 from AccessControl import ClassSecurityInfo, Permissions
19
20
22 """ Defines the interface for Link-like objects, which
23 represent a connection between two devices or components
24 """
25
26 link_type = ''
27 OSI_layer = ''
28 entry_type = ''
29
31 """ Returns the event status, determined by:
32 Pingdown on Device owning either endpoint
33 Most severe event on either endpoint
34 """
35 raise NotImplementedError
36
40
42 """ Returns unique endpoint names (see Linkable.getEndpointName)"""
43 raise NotImplementedError
44
48
50 """ Returns data ready for serialization.
51 Format:
52 [ id link as string
53 , endpoint a name
54 , endpoint b name
55 , self.OSI_layer
56 , self.link_type
57 , self.entry_type
58 , self.id
59 ]
60 """
61 raise NotImplementedError
62
64 """ Return the addresses of the endpoints
65 aggregated for the generation of the context
66 """
67 raise NotImplementedError
68
69
70
71 -class Link(ZenModelRM, ILink):
72 """ A link between two Linkable objects,
73 which can have a status and a type.
74 Implements ILink interface.
75 """
76
77 link_type = ''
78 OSI_layer = "1"
79 entry_type = 'manual'
80
81 default_catalog = 'linkSearch'
82
83 _properties = ZenModelRM._properties + (
84 {'id':'link_type','type':'string','mode':'w'},
85 {'id':'OSI_layer', 'type':'string', 'mode':'w'},
86 {'id':'entry_type', 'type':'string', 'mode':'w'},
87 )
88
89 _relations = (
90 ("endpoints",
91 ToMany(ToMany, "Products.ZenModel.Linkable", "links")),
92 ("linkManager",
93 ToOne(ToManyCont, "Products.ZenModel.LinkManager", "links")),
94 )
95
96 factory_type_information = (
97 { 'immediate_view' : 'editLink',
98 'factory' : 'manage_addLink',
99 'actions' :
100 (
101 { 'id' : 'editLink'
102 , 'name' : 'Edit'
103 , 'action' : 'editLink'
104 , 'permissions' : ( "Manage DMD", )
105 },
106 )
107 },
108 )
109
114
117
120
124
127
129 """ Return the link endpoint that is not the one given """
130 eps = self.endpoints()
131 if eps[0]==endpoint:
132 return eps[1]
133 return eps[0]
134
146
148 """ Status of link is determined by:
149 Pingdown on Device owning either endpoint
150 Most severe event on either endpoint
151 """
152 eps = self.endpoints()
153 if max([ep.device().getPingStatus() for ep in eps]) > 0:
154 return 5
155 zem = self.dmd.ZenEventManager
156 return max(map(zem.getMaxSeverity, eps))
157
172 result = map(getancestoraddress, self.endpoints())
173 if result[0]==result[1]: return None
174 result.sort()
175 return tuple(result)
176
177
178
179 InitializeClass(Link)
180