mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #10469 from swordqiu/automated-cherry-pick-of-#10468-upstream-release-3.7
Automated cherry pick of #10468: fix(log): add filters to baremetal event logs
This commit is contained in:
@@ -27,6 +27,16 @@ type BaremetalEventListInput struct {
|
||||
Since time.Time `json:"since"`
|
||||
// until
|
||||
Until time.Time `json:"until"`
|
||||
// host_id
|
||||
HostId []string `json:"host_id"`
|
||||
// id
|
||||
Id []int64 `json:"id"`
|
||||
// EventId
|
||||
EventId []string `json:"event_id"`
|
||||
// Type
|
||||
Type []string `json:"type"`
|
||||
// ipmi_ip
|
||||
IpmiIp []string `json:"ipmi_ip"`
|
||||
}
|
||||
|
||||
type ActionLogListInput struct {
|
||||
|
||||
@@ -108,5 +108,30 @@ func (manager *SBaremetalEventManager) ListItemFilter(
|
||||
if !query.Until.IsZero() {
|
||||
q = q.LE("created", query.Until)
|
||||
}
|
||||
if len(query.HostId) == 1 {
|
||||
q = q.Equals("host_id", query.HostId[0])
|
||||
} else if len(query.HostId) > 1 {
|
||||
q = q.In("host_id", query.HostId)
|
||||
}
|
||||
if len(query.Id) == 1 {
|
||||
q = q.Equals("id", query.Id[0])
|
||||
} else if len(query.Id) > 1 {
|
||||
q = q.In("id", query.Id)
|
||||
}
|
||||
if len(query.EventId) == 1 {
|
||||
q = q.Equals("event_id", query.EventId[0])
|
||||
} else if len(query.EventId) > 1 {
|
||||
q = q.In("event_id", query.EventId)
|
||||
}
|
||||
if len(query.Type) == 1 {
|
||||
q = q.Equals("type", query.Type[0])
|
||||
} else if len(query.Type) > 1 {
|
||||
q = q.In("type", query.Type)
|
||||
}
|
||||
if len(query.IpmiIp) == 1 {
|
||||
q = q.Equals("ipmi_ip", query.IpmiIp[0])
|
||||
} else if len(query.IpmiIp) > 1 {
|
||||
q = q.In("ipmi_ip", query.IpmiIp)
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user