Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0609c2f

Browse filesBrowse files
committed
[core] Implement GetEnvironmentsShortData for all plugins
1 parent e4ee516 commit 0609c2f
Copy full SHA for 0609c2f

File tree

Expand file treeCollapse file tree

9 files changed

+81
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

9 files changed

+81
-0
lines changed
Open diff view settings
Collapse file

‎core/integration/bookkeeping/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/bookkeeping/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ func (p *Plugin) GetEnvironmentsData(envIds []uid.ID) map[uid.ID]string {
287287
return out
288288
}
289289

290+
func (p *Plugin) GetEnvironmentsShortData(envIds []uid.ID) map[uid.ID]string {
291+
return p.GetEnvironmentsData(envIds)
292+
}
293+
290294
/*************************************/
291295
// Initialize the Bookkeeping client //
292296
/*************************************/
Collapse file

‎core/integration/ccdb/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/ccdb/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ func (p *Plugin) GetEnvironmentsData(_ []uid.ID) map[uid.ID]string {
325325
return nil
326326
}
327327

328+
func (p *Plugin) GetEnvironmentsShortData(_ []uid.ID) map[uid.ID]string {
329+
return nil
330+
}
331+
328332
func (p *Plugin) Init(instanceId string) error {
329333
return nil
330334
}
Collapse file

‎core/integration/dcs/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/dcs/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ func (p *Plugin) GetEnvironmentsData(environmentIds []uid.ID) map[uid.ID]string
129129
return out
130130
}
131131

132+
func (p *Plugin) GetEnvironmentsShortData(environmentIds []uid.ID) map[uid.ID]string {
133+
return p.GetEnvironmentsData(environmentIds)
134+
}
135+
132136
func (p *Plugin) partitionStatesForEnvs(envIds []uid.ID) map[uid.ID]string {
133137
out := make(map[uid.ID]string)
134138
for _, envId := range envIds {
Collapse file

‎core/integration/ddsched/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/ddsched/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ func (p *Plugin) GetEnvironmentsData(envIds []uid.ID) map[uid.ID]string {
150150
return partitionInfosOut
151151
}
152152

153+
func (p *Plugin) GetEnvironmentsShortData(envIds []uid.ID) map[uid.ID]string {
154+
return p.GetEnvironmentsData(envIds)
155+
}
156+
153157
func (p *Plugin) partitionStatesForEnvs(envIds []uid.ID) map[uid.ID]map[string]string {
154158
partitionStates := make(map[uid.ID]map[string]string)
155159

Collapse file

‎core/integration/kafka/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/kafka/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func (p *Plugin) GetEnvironmentsData(_ []uid.ID) map[uid.ID]string {
100100
return nil
101101
}
102102

103+
func (p *Plugin) GetEnvironmentsShortData(_ []uid.ID) map[uid.ID]string {
104+
return nil
105+
}
106+
103107
func (p *Plugin) FSMEnterStateTopic(state string) string {
104108
return "aliecs.env_state." + state
105109
}
Collapse file

‎core/integration/odc/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/odc/plugin.go
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,37 @@ func (p *Plugin) GetEnvironmentsData(envIds []uid.ID) map[uid.ID]string {
332332
return out
333333
}
334334

335+
func (p *Plugin) GetEnvironmentsShortData(envIds []uid.ID) map[uid.ID]string {
336+
if p == nil || p.odcClient == nil {
337+
return nil
338+
}
339+
340+
p.cachedStatusMu.RLock()
341+
defer p.cachedStatusMu.RUnlock()
342+
343+
if p.cachedStatus == nil {
344+
return nil
345+
}
346+
347+
out := make(map[uid.ID]string)
348+
for _, id := range envIds {
349+
partitionInfo, ok := p.cachedStatus.Partitions[id]
350+
if !ok {
351+
continue
352+
}
353+
354+
partitionInfo.Devices = nil // don't return the full devices payload
355+
356+
partitionInfoOut, err := json.Marshal(partitionInfo)
357+
if err != nil {
358+
continue
359+
}
360+
out[id] = string(partitionInfoOut[:])
361+
}
362+
363+
return out
364+
}
365+
335366
func getFlpIdList(varStack map[string]string) (flps []string, err error) {
336367
payload, ok := varStack["hosts"]
337368
if !ok {
Collapse file

‎core/integration/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/plugin.go
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Plugin interface {
5252
GetConnectionState() string
5353
GetData(argv []any) string
5454
GetEnvironmentsData(envIds []uid.ID) map[uid.ID]string
55+
GetEnvironmentsShortData(envIds []uid.ID) map[uid.ID]string
5556

5657
Init(instanceId string) error
5758
CallStack(data interface{}) map[string]interface{} // used in hook call context
@@ -161,6 +162,27 @@ func (p Plugins) GetEnvironmentsData(envIds []uid.ID) (data map[uid.ID]map[strin
161162
return
162163
}
163164

165+
func (p Plugins) GetEnvironmentsShortData(envIds []uid.ID) (data map[uid.ID]map[string]string) {
166+
data = make(map[uid.ID]map[string]string)
167+
168+
// First we query each plugin for environment data of all envIds at once
169+
pluginEnvData := make(map[ /*plugin*/ string]map[uid.ID]string)
170+
for _, plugin := range p {
171+
pluginEnvData[plugin.GetName()] = plugin.GetEnvironmentsShortData(envIds)
172+
}
173+
174+
// Then we invert the nested map to get a map of envId -> plugin -> data
175+
for _, plugin := range p {
176+
for envId, pluginData := range pluginEnvData[plugin.GetName()] {
177+
if _, ok := data[envId]; !ok {
178+
data[envId] = make(map[string]string)
179+
}
180+
data[envId][plugin.GetName()] = pluginData
181+
}
182+
}
183+
return
184+
}
185+
164186
func PluginsInstance() Plugins {
165187
once.Do(func() {
166188
instance = Plugins{}
Collapse file

‎core/integration/testplugin/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/testplugin/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func (p *Plugin) GetEnvironmentsData(_ []uid.ID) map[uid.ID]string {
7777
return nil
7878
}
7979

80+
func (p *Plugin) GetEnvironmentsShortData(_ []uid.ID) map[uid.ID]string {
81+
return nil
82+
}
83+
8084
func (p *Plugin) Init(_ string) error {
8185
log.Debug("Test plugin initialized")
8286
return nil
Collapse file

‎core/integration/trg/plugin.go‎

Copy file name to clipboardExpand all lines: core/integration/trg/plugin.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ func (p *Plugin) GetEnvironmentsData(envIds []uid.ID) map[uid.ID]string {
236236
return out
237237
}
238238

239+
func (p *Plugin) GetEnvironmentsShortData(envIds []uid.ID) map[uid.ID]string {
240+
return p.GetEnvironmentsData(envIds)
241+
}
242+
239243
func (p *Plugin) Init(instanceId string) error {
240244
if p.trgClient == nil {
241245
callTimeout := TRG_DIAL_TIMEOUT

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.