diff --git a/pkg/apis/logger/input.go b/pkg/apis/logger/input.go index 0b8c702cd1..6e3118c5a5 100644 --- a/pkg/apis/logger/input.go +++ b/pkg/apis/logger/input.go @@ -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 { diff --git a/pkg/logger/models/baremetalevents.go b/pkg/logger/models/baremetalevents.go index d6d18320b0..cbbefc8707 100644 --- a/pkg/logger/models/baremetalevents.go +++ b/pkg/logger/models/baremetalevents.go @@ -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 }