mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #9724 from zhaoxiangchun/feature/zxc-analysis-predict-master
feat(suggestion,apigateway): add analysispredict climc
This commit is contained in:
@@ -34,6 +34,7 @@ import (
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/notifyv2"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/suggestion"
|
||||
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
// 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 (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
|
||||
)
|
||||
|
||||
func init() {
|
||||
aN := cmdN("suggestsysalert")
|
||||
R(&options.SuggestSysAlertListOptions{}, aN("list"), "List all suggestsysrules",
|
||||
func(s *mcclient.ClientSession, args *options.SuggestSysAlertListOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(args.Type) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Type), "type")
|
||||
}
|
||||
ret, err := monitor.SuggestSysAlertManager.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(ret, monitor.SuggestSysAlertManager.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SSuggestAlertShowOptions{}, aN("show"), "Show details of a alert rule",
|
||||
func(s *mcclient.ClientSession, args *options.SSuggestAlertShowOptions) error {
|
||||
ret, err := monitor.SuggestSysAlertManager.Get(s, args.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SuggestAlertIgnoreOptions{}, aN("ignore"), "Ignore alert result",
|
||||
func(s *mcclient.ClientSession, args *options.SuggestAlertIgnoreOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := monitor.SuggestSysAlertManager.PerformAction(s, args.ID, "ignore", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package suggestion
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/suggestion"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(modules.AnalysisPredictManager)
|
||||
cmd.Get("", new(options.AnalysisPredictConfigOptions))
|
||||
}
|
||||
@@ -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 suggestion
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/monitor"
|
||||
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(monitor.SuggestSysAlertManager)
|
||||
cmd.List(new(options.SuggestSysAlertListOptions))
|
||||
cmd.Show(new(options.SSuggestAlertShowOptions))
|
||||
cmd.Perform("ignore", new(options.SuggestAlertIgnoreOptions))
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package monitor
|
||||
package suggestion
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
@@ -0,0 +1,23 @@
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
AnalysisPredictManager *SAnalysisPredict
|
||||
)
|
||||
|
||||
func init() {
|
||||
AnalysisPredictManager = NewAnalysisPredict()
|
||||
Register(AnalysisPredictManager)
|
||||
}
|
||||
|
||||
type SAnalysisPredict struct {
|
||||
*modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func NewAnalysisPredict() *SAnalysisPredict {
|
||||
man := NewSuggestionManager("analysispredict", "analysispredicts", []string{}, []string{})
|
||||
return &SAnalysisPredict{
|
||||
ResourceManager: &man,
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,22 @@ type SuggestSysAlertListOptions struct {
|
||||
Type string `help:"Type of suggest rule" choices:"EIP_UNUSED|"`
|
||||
}
|
||||
|
||||
func (o *SuggestSysAlertListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(o)
|
||||
}
|
||||
|
||||
type SSuggestAlertShowOptions struct {
|
||||
ID string `help:"ID or name of the alert" json:"-"`
|
||||
}
|
||||
|
||||
func (o *SSuggestAlertShowOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
func (o *SSuggestAlertShowOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
type SuggestAlertIgnoreOptions struct {
|
||||
ID string `help:"ID or name of the alert" json:"-"`
|
||||
Scope string `help:"Resource scope" choices:"system|domain|project" default:"project"`
|
||||
@@ -36,6 +48,10 @@ type SuggestAlertIgnoreOptions struct {
|
||||
Project string `help:"'Owner project ID or Name" json:"project"`
|
||||
}
|
||||
|
||||
func (opt *SuggestAlertIgnoreOptions) Params() (*jsonutils.JSONDict, error) {
|
||||
func (opt *SuggestAlertIgnoreOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(opt)
|
||||
}
|
||||
|
||||
func (o *SuggestAlertIgnoreOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package suggestion
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type AnalysisPredictConfigOptions struct {
|
||||
ID string `help:"ID or name of the alert" json:"-"`
|
||||
options.BaseListOptions
|
||||
QueryType string `help:"query_type of the analysis" choices:"expense_trend" json:"query_type"`
|
||||
StartDate string `help:"start_date of the analysis" json:"start_date"`
|
||||
EndDate string `help:"end_date of the analysis" json:"end_date"`
|
||||
DataType string `help:"data_type of the analysis" choices:"day|month" json:"data_type"`
|
||||
}
|
||||
|
||||
func (o *AnalysisPredictConfigOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(o)
|
||||
}
|
||||
|
||||
func (o *AnalysisPredictConfigOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package suggestion // import "yunion.io/x/onecloud/pkg/mcclient/options/suggestion"
|
||||
Reference in New Issue
Block a user