mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: implements details and list for monitor service
This commit is contained in:
@@ -208,7 +208,10 @@ type DBInstanceAccountListInput struct {
|
||||
|
||||
type DBInstanceDetails struct {
|
||||
apis.VirtualResourceDetails
|
||||
VpcResourceInfo
|
||||
CloudregionResourceInfo
|
||||
ManagedResourceInfo
|
||||
|
||||
VpcResourceInfoBase
|
||||
|
||||
SDBInstance
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ type ElasticcacheFilterListInput struct {
|
||||
// 以弹性缓存实例过滤
|
||||
Elasticcache string `json:"elasticcache"`
|
||||
|
||||
// swagger:ignore
|
||||
// Deprecated
|
||||
ElasticcacheId string `json:"elasticcache_id" deprecated-by:"elasticcache"`
|
||||
|
||||
// 以弹性缓存实例名称排序
|
||||
OrderByElasticcache string `json:"order_by_elasticcache"`
|
||||
|
||||
|
||||
@@ -38,12 +38,16 @@ type VpcDetails struct {
|
||||
NatgatewayCount int `json:"natgateway_count"`
|
||||
}
|
||||
|
||||
type VpcResourceInfo struct {
|
||||
type VpcResourceInfoBase struct {
|
||||
// Vpc Name
|
||||
Vpc string `json:"vpc"`
|
||||
|
||||
// VPC外部Id
|
||||
VpcExtId string `json:"vpc_ext_id"`
|
||||
}
|
||||
|
||||
type VpcResourceInfo struct {
|
||||
VpcResourceInfoBase
|
||||
|
||||
// VPC归属区域ID
|
||||
CloudregionId string `json:"cloudregion_id"`
|
||||
|
||||
@@ -133,3 +133,7 @@ type AlertListInput struct {
|
||||
// 以报警是否启用/禁用过滤列表
|
||||
// Enabled *bool `json:"enabled"`
|
||||
}
|
||||
|
||||
type AlertDetails struct {
|
||||
apis.VirtualResourceDetails
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
package monitor
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
const (
|
||||
MeterAlertTypeBalance = "balance"
|
||||
MeterAlertTypeDailyResFee = "resFee"
|
||||
@@ -38,7 +34,7 @@ type MeterAlertCreateInput struct {
|
||||
}
|
||||
|
||||
type MeterAlertListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
V1AlertListInput
|
||||
|
||||
// 监控资源类型, 比如: balance, resFree, monthFee
|
||||
Type string `json:"type"`
|
||||
|
||||
@@ -16,8 +16,6 @@ package monitor
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -137,8 +135,12 @@ func GetNodeAlertEvaluator(comparator string, threshold float64) Condition {
|
||||
}
|
||||
}
|
||||
|
||||
type V1AlertListInput struct {
|
||||
AlertListInput
|
||||
}
|
||||
|
||||
type NodeAlertListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
V1AlertListInput
|
||||
|
||||
// 监控指标名称
|
||||
Metric string `json:"metric"`
|
||||
@@ -150,14 +152,8 @@ type NodeAlertListInput struct {
|
||||
NodeId string `json:"node_id"`
|
||||
}
|
||||
|
||||
func (input NodeAlertListInput) ToAlertListInput() AlertListInput {
|
||||
return AlertListInput{
|
||||
VirtualResourceListInput: input.VirtualResourceListInput,
|
||||
}
|
||||
}
|
||||
|
||||
type AlertV1Details struct {
|
||||
apis.VirtualResourceDetails
|
||||
AlertDetails
|
||||
|
||||
Name string `json:"name"`
|
||||
Period string `json:"period"`
|
||||
|
||||
@@ -429,16 +429,33 @@ func (manager *SDBInstanceManager) FetchCustomizeColumns(
|
||||
virtRows := manager.SVirtualResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
manRows := manager.SManagedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
regRows := manager.SCloudregionResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
vpcRows := manager.SVpcResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
vpcIds := make([]string, len(rows))
|
||||
for i := range rows {
|
||||
rows[i] = api.DBInstanceDetails{
|
||||
VirtualResourceDetails: virtRows[i],
|
||||
VpcResourceInfo: vpcRows[i],
|
||||
VirtualResourceDetails: virtRows[i],
|
||||
ManagedResourceInfo: manRows[i],
|
||||
CloudregionResourceInfo: regRows[i],
|
||||
}
|
||||
rows[i].ManagedResourceInfo = manRows[i]
|
||||
rows[i].CloudregionResourceInfo = regRows[i]
|
||||
rows[i] = objs[i].(*SDBInstance).getMoreDetails(rows[i])
|
||||
vpcIds[i] = objs[i].(*SDBInstance).VpcId
|
||||
}
|
||||
|
||||
vpcs := make(map[string]SVpc)
|
||||
|
||||
err := db.FetchStandaloneObjectsByIds(VpcManager, vpcIds, &vpcs)
|
||||
if err != nil {
|
||||
log.Errorf("db.FetchStandaloneObjectsByIds fail %s", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
for i := range rows {
|
||||
if vpc, ok := vpcs[vpcIds[i]]; ok {
|
||||
rows[i].Vpc = vpc.Name
|
||||
rows[i].VpcExtId = vpc.ExternalId
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/monitor/validators"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -199,7 +200,12 @@ func (man *SAlertManager) ValidateCreateData(ctx context.Context, userCred mccli
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (man *SAlertManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, input monitor.AlertListInput) (*sqlchemy.SQuery, error) {
|
||||
func (man *SAlertManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
input monitor.AlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := man.SVirtualResourceBaseManager.ListItemFilter(ctx, q, userCred, input.VirtualResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
@@ -212,6 +218,60 @@ func (man *SAlertManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SAlertManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
input monitor.AlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SVirtualResourceBaseManager.OrderByExtraFields(ctx, q, userCred, input.VirtualResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SAlertManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SVirtualResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (a *SAlert) GetExtraDetails(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
isList bool,
|
||||
) (monitor.AlertDetails, error) {
|
||||
return monitor.AlertDetails{}, nil
|
||||
}
|
||||
|
||||
func (man *SAlertManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []monitor.AlertDetails {
|
||||
rows := make([]monitor.AlertDetails, len(objs))
|
||||
virtRows := man.SVirtualResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i] = monitor.AlertDetails{
|
||||
VirtualResourceDetails: virtRows[i],
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func (man *SAlertManager) GetAlert(id string) (*SAlert, error) {
|
||||
obj, err := man.FetchById(id)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/monitor/options"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -354,17 +355,44 @@ func (man *SMeterAlertManager) GetAlert(id string) (*SMeterAlert, error) {
|
||||
}
|
||||
|
||||
func (man *SMeterAlertManager) ListItemFilter(
|
||||
ctx context.Context, q *sqlchemy.SQuery,
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.MeterAlertListInput) (*sqlchemy.SQuery, error) {
|
||||
q, err := AlertManager.ListItemFilter(ctx, q, userCred, monitor.AlertListInput{})
|
||||
query monitor.MeterAlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := man.SV1AlertManager.ListItemFilter(ctx, q, userCred, query.V1AlertListInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "SV1AlertManager.ListItemFilter")
|
||||
}
|
||||
q.Equals("used_by", AlertNotificationUsedByMeterAlert)
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SMeterAlertManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.MeterAlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SV1AlertManager.OrderByExtraFields(ctx, q, userCred, query.V1AlertListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SV1AlertManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SMeterAlertManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
q, err = man.SV1AlertManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (man *SMeterAlertManager) CustomizeFilterList(
|
||||
ctx context.Context, q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential, query jsonutils.JSONObject) (
|
||||
@@ -496,14 +524,42 @@ func (alert *SMeterAlert) PostCreate(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
func (alert *SMeterAlert) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (monitor.MeterAlertDetails, error) {
|
||||
func (man *SMeterAlertManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []monitor.MeterAlertDetails {
|
||||
rows := make([]monitor.MeterAlertDetails, len(objs))
|
||||
|
||||
v1Rows := man.SV1AlertManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
for i := range rows {
|
||||
rows[i] = monitor.MeterAlertDetails{
|
||||
AlertV1Details: v1Rows[i],
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
func (alert *SMeterAlert) GetExtraDetails(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
isList bool,
|
||||
) (monitor.MeterAlertDetails, error) {
|
||||
return monitor.MeterAlertDetails{}, nil
|
||||
}
|
||||
|
||||
func (alert *SMeterAlert) getMoreDetails(out monitor.MeterAlertDetails) (monitor.MeterAlertDetails, error) {
|
||||
var err error
|
||||
out := monitor.MeterAlertDetails{}
|
||||
commonDetails, err := alert.SV1Alert.GetExtraDetails(ctx, userCred, query, isList, AlertNotificationUsedByMeterAlert)
|
||||
out.AlertV1Details, err = alert.SV1Alert.getMoreDetails(out.AlertV1Details, AlertNotificationUsedByMeterAlert)
|
||||
if err != nil {
|
||||
return out, err
|
||||
return out, errors.Wrap(err, "SV1Alert.getMoreDetails")
|
||||
}
|
||||
out.AlertV1Details = commonDetails
|
||||
|
||||
out.Type = alert.getType()
|
||||
out.ProjectId = alert.getProjectId()
|
||||
|
||||
+149
-18
@@ -33,6 +33,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/monitor/options"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -183,18 +184,99 @@ func (man *SNodeAlertManager) ValidateListConditions(ctx context.Context, userCr
|
||||
return query, nil
|
||||
}
|
||||
|
||||
func (man *SV1AlertManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.V1AlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
q, err = man.SAlertManager.ListItemFilter(ctx, q, userCred, query.AlertListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SAlertManager.ListItemFilter")
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SV1AlertManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.V1AlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SAlertManager.OrderByExtraFields(ctx, q, userCred, query.AlertListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SAlertManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SV1AlertManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SAlertManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (man *SNodeAlertManager) ListItemFilter(
|
||||
ctx context.Context, q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.NodeAlertListInput) (*sqlchemy.SQuery, error) {
|
||||
q, err := AlertManager.ListItemFilter(ctx, q, userCred, query.ToAlertListInput())
|
||||
query monitor.NodeAlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := man.SV1AlertManager.ListItemFilter(ctx, q, userCred, query.V1AlertListInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
q.Equals("used_by", AlertNotificationUsedByNodeAlert)
|
||||
if len(query.Metric) > 0 {
|
||||
|
||||
}
|
||||
if len(query.Type) > 0 {
|
||||
|
||||
}
|
||||
if len(query.NodeId) > 0 {
|
||||
|
||||
}
|
||||
if len(query.NodeName) > 0 {
|
||||
|
||||
}
|
||||
q = q.Equals("used_by", AlertNotificationUsedByNodeAlert)
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SNodeAlertManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query monitor.NodeAlertListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SV1AlertManager.OrderByExtraFields(ctx, q, userCred, query.V1AlertListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SV1AlertManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (man *SNodeAlertManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = man.SV1AlertManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (man *SNodeAlertManager) GetAlert(id string) (*SNodeAlert, error) {
|
||||
obj, err := man.FetchById(id)
|
||||
if err != nil {
|
||||
@@ -292,10 +374,12 @@ func (alert *SV1Alert) CustomizeCreate(
|
||||
return err
|
||||
}
|
||||
|
||||
func (alert *SNodeAlert) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
if err := alert.SVirtualResourceBase.CustomizeCreate(ctx, userCred, ownerId, query, data); err != nil {
|
||||
return err
|
||||
}
|
||||
func (alert *SNodeAlert) CustomizeCreate(
|
||||
ctx context.Context, userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
query jsonutils.JSONObject,
|
||||
data jsonutils.JSONObject,
|
||||
) error {
|
||||
if err := alert.SVirtualResourceBase.CustomizeCreate(ctx, userCred, ownerId, query, data); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -353,6 +437,26 @@ func (alert *SNodeAlert) PostCreate(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
func (man *SV1AlertManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []monitor.AlertV1Details {
|
||||
rows := make([]monitor.AlertV1Details, len(objs))
|
||||
|
||||
alertRows := man.SAlertManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i] = monitor.AlertV1Details{
|
||||
AlertDetails: alertRows[i],
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
func (alert *SV1Alert) GetExtraDetails(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
@@ -360,12 +464,10 @@ func (alert *SV1Alert) GetExtraDetails(
|
||||
isList bool,
|
||||
usedBy string,
|
||||
) (monitor.AlertV1Details, error) {
|
||||
var err error
|
||||
out := monitor.AlertV1Details{}
|
||||
out.VirtualResourceDetails, err = alert.SVirtualResourceBase.GetExtraDetails(ctx, userCred, query, isList)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
return monitor.AlertV1Details{}, nil
|
||||
}
|
||||
|
||||
func (alert *SV1Alert) getMoreDetails(out monitor.AlertV1Details, usedBy string) (monitor.AlertV1Details, error) {
|
||||
out.Name = alert.GetName()
|
||||
if alert.Frequency < 60 {
|
||||
out.Window = fmt.Sprintf("%ds", alert.Frequency)
|
||||
@@ -417,14 +519,43 @@ func (alert *SV1Alert) GetExtraDetails(
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (alert *SNodeAlert) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (monitor.NodeAlertDetails, error) {
|
||||
func (man *SNodeAlertManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []monitor.NodeAlertDetails {
|
||||
rows := make([]monitor.NodeAlertDetails, len(objs))
|
||||
|
||||
v1Rows := man.SV1AlertManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
for i := range rows {
|
||||
rows[i] = monitor.NodeAlertDetails{
|
||||
AlertV1Details: v1Rows[i],
|
||||
}
|
||||
rows[i], _ = objs[i].(*SNodeAlert).getMoreDetails(rows[i])
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
func (alert *SNodeAlert) GetExtraDetails(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
isList bool,
|
||||
) (monitor.NodeAlertDetails, error) {
|
||||
return monitor.NodeAlertDetails{}, nil
|
||||
}
|
||||
|
||||
func (alert *SNodeAlert) getMoreDetails(out monitor.NodeAlertDetails) (monitor.NodeAlertDetails, error) {
|
||||
var err error
|
||||
out := monitor.NodeAlertDetails{}
|
||||
commonDetails, err := alert.SV1Alert.GetExtraDetails(ctx, userCred, query, isList, AlertNotificationUsedByNodeAlert)
|
||||
out.AlertV1Details, err = alert.SV1Alert.getMoreDetails(out.AlertV1Details, AlertNotificationUsedByNodeAlert)
|
||||
if err != nil {
|
||||
return out, err
|
||||
return out, errors.Wrap(err, "SV1Alert.getMoreDetails")
|
||||
}
|
||||
out.AlertV1Details = commonDetails
|
||||
|
||||
out.Type = alert.getType()
|
||||
out.NodeId = alert.getNodeId()
|
||||
|
||||
Reference in New Issue
Block a user