feat(monitor): VMs of host loadbalance

This commit is contained in:
Zexi Li
2022-06-23 00:25:03 +08:00
parent 8b2a5d13ee
commit e5f01ad535
43 changed files with 2461 additions and 71 deletions
+9
View File
@@ -70,6 +70,10 @@ func doIdentityEventList(s *mcclient.ClientSession, args *EventListOptions) erro
return DoEventList(modules.IdentityLogs, s, args)
}
func doMonitorEventList(s *mcclient.ClientSession, args *EventListOptions) error {
return DoEventList(modules.MonitorLogs, s, args)
}
func DoEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args *EventListOptions) error {
params := jsonutils.NewDict()
if len(args.Type) > 0 {
@@ -253,4 +257,9 @@ func init() {
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"credential"}}
return doIdentityEventList(s, &nargs)
})
R(&TypeEventListOptions{}, "monitor-migrationalert-event", "Show operation event logs of monitor auto migrations", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"migrationalert"}}
return doMonitorEventList(s, &nargs)
})
}
+10 -4
View File
@@ -15,9 +15,11 @@
package monitor
import (
"encoding/json"
"fmt"
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/pkg/errors"
monitorapi "yunion.io/x/onecloud/pkg/apis/monitor"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
@@ -25,7 +27,7 @@ import (
)
func init() {
cmd := shell.NewResourceCmd(monitor.Alerts)
cmd := NewResourceCmd(monitor.Alerts)
cmd.List(new(options.AlertListOptions))
cmd.Create(new(options.AlertCreateOptions))
cmd.Show(new(options.AlertShowOptions))
@@ -42,9 +44,13 @@ func init() {
}
ret, err := monitor.Alerts.DoTestRun(s, args.ID, data)
if err != nil {
return err
return errors.Wrap(err, "DoTestRun")
}
fmt.Println(ret.JSON(ret).YAMLString())
jsonBytes, err := json.MarshalIndent(ret, "", " ")
if err != nil {
return errors.Wrap(err, "MarshalIndent")
}
fmt.Printf("%s\n", jsonBytes)
return nil
})
}
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.AlertDashBoardManager)
cmd := NewResourceCmd(modules.AlertDashBoardManager)
cmd.Create(new(options.AlertDashBoardCreateOptions))
cmd.List(new(options.AlertDashBoardListOptions))
cmd.Show(new(options.AlertDashBoardShowOptions))
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.AlertPanelManager)
cmd := NewResourceCmd(modules.AlertPanelManager)
cmd.Create(new(options.AlertPanelCreateOptions))
cmd.List(new(options.AlertPanelListOptions))
cmd.Show(new(options.AlertPanelShowOptions))
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.AlertRecordManager)
cmd := NewResourceCmd(modules.AlertRecordManager)
cmd.List(new(options.AlertRecordListOptions))
cmd.Show(new(options.AlertRecordShowOptions))
cmd.Get("", new(options.AlertRecordTotalOptions))
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.AlertRecordShieldManager)
cmd := NewResourceCmd(modules.AlertRecordShieldManager)
cmd.Create(new(options.AlertRecordShieldCreateOptions))
cmd.List(new(options.AlertRecordShieldListOptions))
cmd.Show(new(options.AlertRecordShieldShowOptions))
+1 -1
View File
@@ -21,7 +21,7 @@ import (
)
func init() {
cmd := shell.NewResourceCmd(monitor.AlertResources)
cmd := NewResourceCmd(monitor.AlertResources)
cmd.List(new(options.AlertResourceListOptions))
cmd.Show(new(options.AlertResourceShowOptions))
cmd.BatchDelete(new(options.AlertResourceDeleteOptions))
+7
View File
@@ -16,6 +16,7 @@ package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/util/printutils"
)
@@ -25,3 +26,9 @@ var (
printObject = printutils.PrintJSONObject
printBatchResults = printutils.PrintJSONBatchResults
)
func NewResourceCmd(manager modulebase.IBaseManager) *shell.ResourceCmd {
cmd := shell.NewResourceCmd(manager)
cmd.SetPrefix("monitor")
return cmd
}
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.CommonAlertManager)
cmd := NewResourceCmd(modules.CommonAlertManager)
cmd.List(new(options.CommonAlertListOptions))
cmd.Show(new(options.CommonAlertShowOptions))
cmd.Perform("enable", &options.CommonAlertShowOptions{})
+1 -2
View File
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.MetricManager)
cmd := NewResourceCmd(modules.MetricManager)
cmd.List(new(options.MonitorMetricListOptions))
cmd.Update(new(options.MetricUpdateOptions))
cmd.Show(new(options.MetricShowOptions))
@@ -15,13 +15,12 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.MetricFieldManager)
cmd := NewResourceCmd(modules.MetricFieldManager)
cmd.List(new(options.MonitorMetricFieldListOptions))
cmd.Update(new(options.MetricFieldUpdateOptions))
cmd.Show(new(options.MetricFieldShowOptions))
@@ -0,0 +1,28 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitor
import (
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := NewResourceCmd(modules.MigrationAlertManager)
cmd.List(new(options.MigrationAlertListOptions))
cmd.Show(new(options.MigrationAlertShowOptions))
cmd.Create(new(options.MigrationAlertCreateOptions))
cmd.Delete(new(options.MigrationAlertShowOptions))
}
+1 -2
View File
@@ -15,12 +15,11 @@
package monitor
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.MonitorResourceManager)
cmd := NewResourceCmd(modules.MonitorResourceManager)
cmd.Get("", new(options.MonitorResourceJointAlertOptions))
}
@@ -21,6 +21,6 @@ import (
)
func init() {
cmd := shell.NewJointCmd(modules.MonitorResourceAlertManager)
cmd := shell.NewJointCmd(modules.MonitorResourceAlertManager).SetPrefix("monitor")
cmd.List(new(options.MonitorResourceAlertListOptions))
}