datacenter search filter for datacenter live
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/models"
|
||||
"cloud.o-forge.io/core/oc-lib/models/compute_units"
|
||||
"cloud.o-forge.io/core/oc-lib/models/live"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ func (p *PrometheusService) Call(book *booking.Booking, user string, peerID stri
|
||||
metrics := map[string]models.MetricsSnapshot{}
|
||||
// get all booking... from executions_id == namespace typed datacenter.
|
||||
|
||||
cUAccess := oclib.NewRequest(oclib.LibDataEnum(oclib.COMPUTE_UNITS), user, peerID, groups, nil)
|
||||
cUAccess := oclib.NewRequest(oclib.LibDataEnum(oclib.LIVE_DATACENTER), user, peerID, groups, nil)
|
||||
cRAccess := oclib.NewRequest(oclib.LibDataEnum(oclib.COMPUTE_RESOURCE), user, peerID, groups, nil)
|
||||
|
||||
rr := cRAccess.LoadOne(book.ResourceID)
|
||||
@@ -100,7 +100,8 @@ func (p *PrometheusService) Call(book *booking.Booking, user string, peerID stri
|
||||
for _, instance := range computeRes.Instances {
|
||||
res := cUAccess.Search(&dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"source": {{Operator: dbs.EQUAL.String(), Value: instance.Source}},
|
||||
"source": {{Operator: dbs.EQUAL.String(), Value: instance.Source}},
|
||||
"abstractlive.resources_id": {{Operator: dbs.EQUAL.String(), Value: computeRes.GetID()}},
|
||||
},
|
||||
}, "", false)
|
||||
if res.Err != "" {
|
||||
@@ -108,7 +109,7 @@ func (p *PrometheusService) Call(book *booking.Booking, user string, peerID stri
|
||||
}
|
||||
for _, r := range res.Data {
|
||||
// TODO watch out ... to not exec on an absent datacenter...
|
||||
if r.(*compute_units.ComputeUnits).MonitorPath == "" {
|
||||
if r.(*live.LiveDatacenter).MonitorPath == "" {
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
@@ -117,13 +118,12 @@ func (p *PrometheusService) Call(book *booking.Booking, user string, peerID stri
|
||||
defer wg.Done()
|
||||
for _, expr := range queriesMetrics {
|
||||
snapshot.Metrics = append(snapshot.Metrics,
|
||||
p.queryPrometheus(r.(*compute_units.ComputeUnits).MonitorPath, expr, book.ExecutionsID))
|
||||
p.queryPrometheus(r.(*live.LiveDatacenter).MonitorPath, expr, book.ExecutionsID))
|
||||
}
|
||||
metrics[instance.Name] = snapshot
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
return book, metrics
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user