master
go 228 lines 9.01 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package vsphere
4
5 import topologyv1 "github.com/netdata/netdata/go/plugins/pkg/topology/v1"
6
7 func vsphereTopologyPresentation() *topologyv1.Presentation {
8 return &topologyv1.Presentation{
9 ProfileVersion: "vsphere.inventory.v1",
10 Selection: &topologyv1.SelectionPresentation{
11 ActorClick: &topologyv1.ActorClickPresentation{
12 Mode: "highlight_connections",
13 },
14 },
15 Legend: &topologyv1.PresentationLegend{
16 Actors: []topologyv1.LegendEntry{
17 {Type: "vsphere_datacenter", Label: "Datacenter"},
18 {Type: "vsphere_cluster", Label: "Cluster"},
19 {Type: "vsphere_host", Label: "ESXi Host"},
20 {Type: "vsphere_vm", Label: "VM"},
21 {Type: "vsphere_datastore", Label: "Datastore"},
22 {Type: "vsphere_network", Label: "Network"},
23 {Type: "vsphere_datastore_cluster", Label: "Datastore Cluster"},
24 {Type: "vsphere_resource_pool", Label: "Resource Pool"},
25 },
26 Links: []topologyv1.LegendEntry{
27 {Type: vsphereTopologyOwnershipLink, Label: "Contains"},
28 {Type: vsphereTopologyRunsOnLink, Label: "Runs on"},
29 {Type: vsphereTopologyNetworkLink, Label: "Connected to"},
30 },
31 },
32 }
33 }
34
35 func vsphereActorPresentation(label, icon, colorSlot string) *topologyv1.ActorPresentation {
36 return &topologyv1.ActorPresentation{
37 Label: label,
38 Role: "actor",
39 Icon: icon,
40 ColorSlot: colorSlot,
41 Border: &topologyv1.BorderPresentation{
42 Enabled: new(true),
43 Style: "solid",
44 },
45 LabelPolicy: &topologyv1.LabelPolicy{
46 Columns: []string{"name"},
47 Fallback: "type_label",
48 MaxLength: 80,
49 Array: "reject",
50 },
51 Hover: &topologyv1.HoverPresentation{
52 Fields: []topologyv1.PresentationField{
53 {Key: "name", Label: "Name"},
54 {Key: "object_type", Label: "Type"},
55 {Key: "vsphere_moid", Label: "vSphere MoRef"},
56 {Key: "overall_status", Label: "Status"},
57 {Key: "power_state", Label: "Power"},
58 },
59 },
60 Modal: vsphereActorModal(),
61 }
62 }
63
64 func vsphereLinkPresentation(label, colorSlot, arrow, distance string) *topologyv1.LinkPresentation {
65 return &topologyv1.LinkPresentation{
66 Label: label,
67 ColorSlot: colorSlot,
68 LineStyle: "solid",
69 Width: "normal",
70 Curve: "auto",
71 Arrow: arrow,
72 Hover: &topologyv1.HoverPresentation{
73 Fields: []topologyv1.PresentationField{
74 {Key: "relationship", Label: "Relationship"},
75 {Key: "evidence_count", Label: "Evidence"},
76 },
77 },
78 Layout: &topologyv1.LinkLayoutPresentation{
79 Strength: "normal",
80 Distance: distance,
81 },
82 }
83 }
84
85 func vsphereActorModal() *topologyv1.ModalPresentation {
86 return &topologyv1.ModalPresentation{
87 Enabled: new(true),
88 Labels: &topologyv1.ModalLabelsPresentation{
89 Enabled: new(true),
90 Table: vsphereTopologyLabelsTable,
91 ActorColumn: "actor",
92 KeyColumn: "key",
93 ValueColumn: "value",
94 SourceColumn: "source",
95 KindColumn: "kind",
96 ValueIndexColumn: "value_index",
97 Identification: &topologyv1.ModalLabelIdentificationPresentation{
98 Enabled: new(true),
99 Fields: []topologyv1.ModalLabelIdentificationField{
100 {Key: "object_type", Label: "Type", MaxValues: 1},
101 {Key: "datacenter", Label: "Datacenter", MaxValues: 1},
102 {Key: "cluster", Label: "Cluster", MaxValues: 1},
103 {Key: "host", Label: "Host", MaxValues: 1},
104 {Key: "resource_pool", Label: "Resource Pool", MaxValues: 1},
105 },
106 },
107 },
108 MiniTopology: &topologyv1.ModalMiniTopologyPresentation{
109 Enabled: new(true),
110 Depth: 1,
111 IncludeLinkTypes: []string{
112 vsphereTopologyOwnershipLink,
113 vsphereTopologyRunsOnLink,
114 vsphereTopologyNetworkLink,
115 },
116 },
117 Sections: []topologyv1.ModalSection{
118 {
119 ID: "details",
120 Label: "Details",
121 Order: 10,
122 Source: topologyv1.ModalSource{
123 Kind: "actor_table",
124 Table: vsphereTopologyDetailTable,
125 },
126 OwnerFilter: &topologyv1.ModalOwnerFilter{
127 Mode: "actor_column",
128 ActorColumn: "actor",
129 },
130 Columns: vsphereDetailModalColumns(),
131 EmptyLabel: "No vSphere details",
132 },
133 {
134 ID: "relationships",
135 Label: "Relationships",
136 Order: 20,
137 Source: topologyv1.ModalSource{
138 Kind: "links",
139 },
140 OwnerFilter: &topologyv1.ModalOwnerFilter{
141 Mode: "incident_link",
142 SrcActorColumn: "src_actor",
143 DstActorColumn: "dst_actor",
144 },
145 Columns: vsphereRelationshipModalColumns(),
146 EmptyLabel: "No vSphere relationships",
147 },
148 },
149 }
150 }
151
152 func vsphereDetailModalColumns() []topologyv1.ModalColumn {
153 return []topologyv1.ModalColumn{
154 vsphereModalDirectColumn("object_type", "Type", "object_type", "badge"),
155 vsphereModalDirectColumn("name", "Name", "name", "text"),
156 vsphereModalDirectColumn("vsphere_moid", "vSphere MoRef", "vsphere_moid", "text"),
157 vsphereModalDirectColumn("datacenter", "Datacenter", "datacenter", "text"),
158 vsphereModalDirectColumn("cluster", "Cluster", "cluster", "text"),
159 vsphereModalDirectColumn("host", "Host", "host", "text"),
160 vsphereModalDirectColumn("resource_pool", "Resource Pool", "resource_pool", "text"),
161 vsphereModalDirectColumn("connection_state", "Connection", "connection_state", "badge"),
162 vsphereModalDirectColumn("power_state", "Power", "power_state", "badge"),
163 vsphereModalDirectColumn("overall_status", "Status", "overall_status", "badge"),
164 vsphereModalDirectColumn("accessible", "Accessible", "accessible", "badge"),
165 vsphereModalDirectColumn("in_maintenance_mode", "In Maintenance", "in_maintenance_mode", "badge"),
166 vsphereModalDirectColumn("maintenance_mode", "Maintenance", "maintenance_mode", "badge"),
167 vsphereModalDirectColumn("datastore_type", "Datastore Type", "datastore_type", "badge"),
168 vsphereModalDirectColumn("network_type", "Network Type", "network_type", "badge"),
169 vsphereModalDirectColumnWithVisibility("ip_pool_name", "IP Pool", "ip_pool_name", "text", "expanded"),
170 vsphereModalDirectColumn("snapshot_count", "Snapshots", "snapshot_count", "number"),
171 vsphereModalDirectColumnWithVisibility("snapshot_chain_depth", "Snapshot Chain", "snapshot_chain_depth", "number", "expanded"),
172 vsphereModalDirectColumn("configured_vcpus", "vCPUs", "configured_vcpus", "number"),
173 vsphereModalDirectColumn("configured_memory_mib", "Memory MiB", "configured_memory_mib", "number"),
174 vsphereModalDirectColumn("capacity_bytes", "Capacity", "capacity_bytes", "number"),
175 vsphereModalDirectColumn("free_space_bytes", "Free Space", "free_space_bytes", "number"),
176 vsphereModalDirectColumnWithVisibility("uncommitted_bytes", "Uncommitted", "uncommitted_bytes", "number", "expanded"),
177 vsphereModalDirectColumn("cpu_capacity_mhz", "CPU Capacity MHz", "cpu_capacity_mhz", "number"),
178 vsphereModalDirectColumn("memory_capacity_mib", "Memory Capacity MiB", "memory_capacity_mib", "number"),
179 vsphereModalDirectColumn("cpu_limit_mhz", "CPU Limit MHz", "cpu_limit_mhz", "number"),
180 vsphereModalDirectColumn("memory_limit_mib", "Memory Limit MiB", "memory_limit_mib", "number"),
181 vsphereModalDirectColumnWithVisibility("cpu_reservation_mhz", "CPU Reservation MHz", "cpu_reservation_mhz", "number", "expanded"),
182 vsphereModalDirectColumnWithVisibility("memory_reservation_mib", "Memory Reservation MiB", "memory_reservation_mib", "number", "expanded"),
183 vsphereModalDirectColumn("network_hosts", "Hosts", "network_hosts", "number"),
184 vsphereModalDirectColumn("network_vms", "VMs", "network_vms", "number"),
185 vsphereModalDirectColumn("drs_enabled", "DRS", "drs_enabled", "badge"),
186 vsphereModalDirectColumn("ha_enabled", "HA", "ha_enabled", "badge"),
187 vsphereModalDirectColumn("vsan_enabled", "vSAN", "vsan_enabled", "badge"),
188 vsphereModalDirectColumn("storage_drs_enabled", "Storage DRS", "storage_drs_enabled", "badge"),
189 vsphereModalDirectColumn("multiple_host_access", "Multiple Host Access", "multiple_host_access", "badge"),
190 vsphereModalDirectColumn("consolidation_needed", "Consolidation", "consolidation_needed", "badge"),
191 vsphereModalDirectColumnWithVisibility("tools_running_status", "Tools Running", "tools_running_status", "badge", "expanded"),
192 vsphereModalDirectColumnWithVisibility("tools_version_status", "Tools Version", "tools_version_status", "badge", "expanded"),
193 }
194 }
195
196 func vsphereRelationshipModalColumns() []topologyv1.ModalColumn {
197 return []topologyv1.ModalColumn{
198 vsphereModalDirectColumn("relationship", "Relationship", "relationship", "badge"),
199 {
200 ID: "related_object",
201 Label: "Related Object",
202 Projection: topologyv1.ModalProjection{
203 Kind: "opposite_actor",
204 SrcActorColumn: "src_actor",
205 DstActorColumn: "dst_actor",
206 },
207 Cell: "actor_link",
208 },
209 vsphereModalDirectColumn("evidence_count", "Evidence", "evidence_count", "number"),
210 }
211 }
212
213 func vsphereModalDirectColumn(id, label, sourceColumn, cell string) topologyv1.ModalColumn {
214 return vsphereModalDirectColumnWithVisibility(id, label, sourceColumn, cell, "")
215 }
216
217 func vsphereModalDirectColumnWithVisibility(id, label, sourceColumn, cell, visibility string) topologyv1.ModalColumn {
218 return topologyv1.ModalColumn{
219 ID: id,
220 Label: label,
221 Projection: topologyv1.ModalProjection{
222 Kind: "direct",
223 Column: sourceColumn,
224 },
225 Cell: cell,
226 Visibility: visibility,
227 }
228 }