fix: cleanup codes

This commit is contained in:
Qiu Jian
2021-11-13 18:14:38 +08:00
parent 72f4ce4a5e
commit a5b3345b3d
118 changed files with 69 additions and 6301 deletions
+1 -3
View File
@@ -28,15 +28,13 @@ import (
_ "yunion.io/x/onecloud/cmd/climc/shell/events"
_ "yunion.io/x/onecloud/cmd/climc/shell/identity"
_ "yunion.io/x/onecloud/cmd/climc/shell/image"
_ "yunion.io/x/onecloud/cmd/climc/shell/itsm"
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
_ "yunion.io/x/onecloud/cmd/climc/shell/logger"
_ "yunion.io/x/onecloud/cmd/climc/shell/misc"
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
_ "yunion.io/x/onecloud/cmd/climc/shell/notifyv2"
_ "yunion.io/x/onecloud/cmd/climc/shell/quota"
_ "yunion.io/x/onecloud/cmd/climc/shell/scheduler"
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
_ "yunion.io/x/onecloud/cmd/climc/shell/suggestion"
_ "yunion.io/x/onecloud/cmd/climc/shell/vpcproxy"
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
)
-46
View File
@@ -1,46 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type InstanceListOptions struct {
options.BaseListOptions
}
R(&InstanceListOptions{}, "instance-list", "List instances", func(s *mcclient.ClientSession, suboptions *InstanceListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = suboptions.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Instances.List(s, params)
if err != nil {
return err
}
printList(result, modules.Instances.GetColumns(s))
return nil
})
}
-93
View File
@@ -1,93 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 使用文件创建部署
*/
type DeploymentCreateOptions struct {
FILE string `help:"The local bpmn filename to Upload"`
TenantID string `help:"ID of tenant"`
}
R(&DeploymentCreateOptions{}, "process-deployment-create", "Create deployment by upload BPMN file", func(s *mcclient.ClientSession, args *DeploymentCreateOptions) error {
// TODO
return nil
})
/**
* 删除指定ID的部署
*/
type DeploymentDeleteOptions struct {
ID string `help:"ID of process deployment"`
Cascade bool `help:"Whether to cascade delete process instance, history process instance and jobs" required:"true" choices:"true|false"`
}
R(&DeploymentDeleteOptions{}, "process-deployment-delete", "Delete process deployment by ID", func(s *mcclient.ClientSession, args *DeploymentDeleteOptions) error {
params := jsonutils.NewDict()
if args.Cascade {
params.Add(jsonutils.JSONTrue, "cascade")
} else {
params.Add(jsonutils.JSONFalse, "cascade")
}
result, e := modules.ProcessDeployments.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(result)
return nil
})
/**
* 列出部署
*/
type DeploymentListOptions struct {
options.BaseListOptions
}
R(&DeploymentListOptions{}, "process-deployment-list", "List process deployment", func(s *mcclient.ClientSession, args *DeploymentListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
result, err := modules.ProcessDeployments.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProcessDeployments.GetColumns(s))
return nil
})
/**
* 查看指定ID的部署
*/
type DeploymentShowOptions struct {
ID string `help:"ID of the process deployment"`
}
R(&DeploymentShowOptions{}, "process-deployment-show", "Show deployment", func(s *mcclient.ClientSession, args *DeploymentShowOptions) error {
result, err := modules.ProcessDeployments.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,59 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
)
func init() {
type ExtraProcessInstanceListOptions struct {
ID string `help:"ID of ExtraProcessInstance"`
UserId string `help:"ID of user"`
}
R(&ExtraProcessInstanceListOptions{}, "itsm_extra_process_instance_list", "extra process instance list",
func(s *mcclient.ClientSession, args *ExtraProcessInstanceListOptions) error {
params := jsonutils.NewDict()
if len(args.ID) > 0 {
params.Add(jsonutils.NewString(args.ID), "id")
}
if len(args.UserId) > 0 {
params.Add(jsonutils.NewString(args.UserId), "user_id")
}
ret, err := modules.ExtraProcessInstance.List(s, params)
if err != nil {
return err
}
printList(ret, modules.ExtraProcessInstance.GetColumns(s))
return nil
})
type ExtraProcessInstanceShowOptions struct {
ID string `help:"ID of ExtraProcessInstance" required:"true"`
}
R(&ExtraProcessInstanceShowOptions{}, "itsm_extra_process_instance_list", "extra process instance list",
func(s *mcclient.ClientSession, args *ExtraProcessInstanceShowOptions) error {
ret, err := modules.ExtraProcessInstance.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(ret)
return nil
})
}
-58
View File
@@ -1,58 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
)
func init() {
type ExtraUserCreateOptions struct {
UserName string `help:"user name" required:"true"`
Pwd string `help:"password" required:"true"`
Url string `help:"url" required:"true"`
Type string `help:"extra order type" required:"true"`
}
R(&ExtraUserCreateOptions{}, "itsm_extra_user_create", "extra user create",
func(s *mcclient.ClientSession, args *ExtraUserCreateOptions) error {
params := jsonutils.Marshal(args)
ret, err := modules.ExtraUsers.Create(s, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
type ExtraUserListOptions struct {
ID string `help:"ID of user"`
}
R(&ExtraUserListOptions{}, "itsm_extra_user_list", "extra user list",
func(s *mcclient.ClientSession, args *ExtraUserListOptions) error {
params := jsonutils.NewDict()
if len(args.ID) > 0 {
params.Add(jsonutils.NewString(args.ID), "id")
}
ret, err := modules.ExtraUsers.List(s, params)
if err != nil {
return err
}
printList(ret, modules.ExtraUsers.GetColumns(s))
return nil
})
}
@@ -1,84 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出历史流程实例
*/
type HistoricProcessInstanceListOptions struct {
ProcessDefinitionKey string `help:"Process definition key"`
UserId string `help:"ID of user"`
options.BaseListOptions
}
R(&HistoricProcessInstanceListOptions{}, "historic-process-instance-list", "List historic process definition", func(s *mcclient.ClientSession, args *HistoricProcessInstanceListOptions) error {
params, err := options.StructToParams(args)
if err != nil {
return err
}
if len(args.ProcessDefinitionKey) > 0 {
params.Add(jsonutils.NewString(args.ProcessDefinitionKey), "process_definition_key")
}
if len(args.UserId) > 0 {
params.Add(jsonutils.NewString(args.UserId), "user_id")
}
result, err := modules.HistoricProcessInstance.List(s, params)
if err != nil {
return err
}
printList(result, modules.HistoricProcessInstance.GetColumns(s))
return nil
})
/**
* 查看指定ID的历史流程实例
*/
type HistoricProcessInstanceShowOptions struct {
ID string `help:"ID of the historic process instance"`
}
R(&HistoricProcessInstanceShowOptions{}, "historic-process-instance-show", "Show historic process definition", func(s *mcclient.ClientSession, args *HistoricProcessInstanceShowOptions) error {
result, err := modules.HistoricProcessInstance.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type HistoricProcessInstanceStaticticsOptions struct {
ID string `help:"ID of user"`
}
R(&HistoricProcessInstanceStaticticsOptions{}, "historic-process-instance-statistics", "Show statistics for historic process instance", func(s *mcclient.ClientSession, args *HistoricProcessInstanceStaticticsOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.ID), "user_id")
rst, err := modules.HistoricProcessInstance.GetStatistics(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
}
@@ -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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出历史任务实例
*/
type HistoricProcessInstanceListOptions struct {
ProcessInstanceId string `help:"ID of process instance"`
UserId string `help:"ID of user"`
options.BaseListOptions
}
R(&HistoricProcessInstanceListOptions{}, "historic-task-instance-list", "List historic process instance", func(s *mcclient.ClientSession, args *HistoricProcessInstanceListOptions) error {
params, err := options.StructToParams(args)
if err != nil {
return err
}
if len(args.ProcessInstanceId) > 0 {
params.Add(jsonutils.NewString(args.ProcessInstanceId), "process_instance_id")
}
if len(args.UserId) > 0 {
params.Add(jsonutils.NewString(args.UserId), "user_id")
}
result, err := modules.HistoricTaskInstances.List(s, params)
if err != nil {
return err
}
printList(result, modules.HistoricTaskInstances.GetColumns(s))
return nil
})
/**
* 查看指定ID的历史任务实例
*/
type HistoricProcessInstanceShowOptions struct {
ID string `help:"ID of the historic task instance"`
}
R(&HistoricProcessInstanceShowOptions{}, "historic-task-instance-show", "Show historic task instance", func(s *mcclient.ClientSession, args *HistoricProcessInstanceShowOptions) error {
result, err := modules.HistoricTaskInstances.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,107 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 删除指定ID的流程定义
*/
type ProcessDefinitionDeleteOptions struct {
ID string `help:"ID of process definition, deletes the process definition which belongs to the given process definition id"`
Cascade bool `help:"Whether to cascade delete process instance, if set to true, all process instances (including) history are deleted" required:"true" choices:"true|false"`
}
R(&ProcessDefinitionDeleteOptions{}, "process-definition-delete", "Delete process definition by ID", func(s *mcclient.ClientSession, args *ProcessDefinitionDeleteOptions) error {
params := jsonutils.NewDict()
if args.Cascade {
params.Add(jsonutils.JSONTrue, "cascade")
} else {
params.Add(jsonutils.JSONFalse, "cascade")
}
result, e := modules.ProcessDefinitions.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(result)
return nil
})
/**
* 修改指定的流程定义的激活/挂起状态
*/
type NodealertUpdateOptions struct {
ID string `help:"ID of process definition"`
state string `help:"State of the process definition" choices:"activate|suspend"`
}
R(&NodealertUpdateOptions{}, "process-definition-change-state", "Update the state of the process definition", func(s *mcclient.ClientSession, args *NodealertUpdateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.state), "state")
result, err := modules.ProcessDefinitions.Put(s, args.ID, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 列出流程定义
*/
type ProcessDefinitionListOptions struct {
ProcessDefinitionKey string `help:"Key of process definition"`
UserId string `help:"ID of user who start the process definition"`
options.BaseListOptions
}
R(&ProcessDefinitionListOptions{}, "process-definition-list", "List process definition", func(s *mcclient.ClientSession, args *ProcessDefinitionListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
if len(args.ProcessDefinitionKey) > 0 {
params.Add(jsonutils.NewString(args.ProcessDefinitionKey), "process_definition_key")
}
if len(args.UserId) > 0 {
params.Add(jsonutils.NewString(args.UserId), "user_id")
}
result, err := modules.ProcessDefinitions.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProcessDefinitions.GetColumns(s))
return nil
})
/**
* 查看指定ID的流程定义
*/
type ProcessDefinitionShowOptions struct {
ID string `help:"ID of the process definition"`
}
R(&ProcessDefinitionShowOptions{}, "process-definition-show", "Show process definition", func(s *mcclient.ClientSession, args *ProcessDefinitionShowOptions) error {
result, err := modules.ProcessDefinitions.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,123 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建流程实例(发起流程)
*/
type ProcessInstanceCreateOptions struct {
PROCESS_DEFINITION_KEY string `help:"Key of the process definition"`
INITIATOR string `help:"ID of user who launch the process instance"`
SERVER_CREATE_PARAMTER string `help:"Onecloud server create spec json string"`
UserId string `help:"ID of user"`
RoleId string `help:"ID of role"`
ProjectId string `help:"ID of project"`
Percent string `help:"Great than Percent of nrOfCompletedInstances/nrOfInstances"`
}
R(&ProcessInstanceCreateOptions{}, "process-instance-create", "Create process instance", func(s *mcclient.ClientSession, args *ProcessInstanceCreateOptions) error {
variables_params := jsonutils.NewDict()
variables_params.Add(jsonutils.NewString(args.PROCESS_DEFINITION_KEY), "process_definition_key")
variables_params.Add(jsonutils.NewString(args.INITIATOR), "initiator")
variables_params.Add(jsonutils.NewString(args.SERVER_CREATE_PARAMTER), "server-create-paramter")
if len(args.UserId) > 0 {
variables_params.Add(jsonutils.NewString(args.UserId), "user-id")
} else {
if len(args.RoleId) > 0 {
variables_params.Add(jsonutils.NewString(args.RoleId), "role-id")
}
if len(args.ProjectId) > 0 {
variables_params.Add(jsonutils.NewString(args.ProjectId), "project-id")
}
}
if len(args.Percent) > 0 {
variables_params.Add(jsonutils.NewString(args.Percent), "percent")
}
params := jsonutils.NewDict()
params.Add(variables_params, "variables")
result, err := modules.ProcessInstance.Create(s, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 删除指定ID的流程实例
*/
type ProcessInstanceDeleteOptions struct {
ID string `help:"ID of process process"`
DeleteReason string `help:"Reason why delete the process instance" required:"true" choices:"true|false"`
}
R(&ProcessInstanceDeleteOptions{}, "process-instance-delete", "Delete process instance by ID", func(s *mcclient.ClientSession, args *ProcessInstanceDeleteOptions) error {
params := jsonutils.NewDict()
if len(args.DeleteReason) > 0 {
params.Add(jsonutils.NewString(args.DeleteReason), "delete_reason")
}
result, e := modules.ProcessInstance.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(result)
return nil
})
/**
* 列出流程实例
*/
type ProcessInstanceListOptions struct {
ProcessDefinitionId string `help:"ID of process definition"`
options.BaseListOptions
}
R(&ProcessInstanceListOptions{}, "process-instance-list", "List process instance", func(s *mcclient.ClientSession, args *ProcessInstanceListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
if len(args.ProcessDefinitionId) > 0 {
params.Add(jsonutils.NewString(args.ProcessDefinitionId), "process_definition_id")
}
result, err := modules.ProcessInstance.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProcessInstance.GetColumns(s))
return nil
})
/**
* 查看指定ID的流程实例
*/
type ProcessInstanceShowOptions struct {
ID string `help:"ID of the process instance"`
}
R(&ProcessInstanceShowOptions{}, "process-instance-show", "Show process instance", func(s *mcclient.ClientSession, args *ProcessInstanceShowOptions) error {
result, err := modules.ProcessInstance.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
-95
View File
@@ -1,95 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 处理任务
*/
type TaskOperOperateOptions struct {
ID string `help:"ID of task"`
APPROVAL_DECISION bool `help:"Approval decision"`
ApprovalProposal string `help:"Approval proposal"`
}
R(&TaskOperOperateOptions{}, "process-task-operate", "Operate task", func(s *mcclient.ClientSession, args *TaskOperOperateOptions) error {
variables_params := jsonutils.NewDict()
if args.APPROVAL_DECISION {
variables_params.Add(jsonutils.JSONTrue, "approved")
} else {
variables_params.Add(jsonutils.JSONFalse, "approved")
}
if len(args.ApprovalProposal) > 0 {
variables_params.Add(jsonutils.NewString(args.ApprovalProposal), "comment")
}
params := jsonutils.NewDict()
params.Add(variables_params, "variables")
result, err := modules.ProcessTasks.Put(s, args.ID, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 列出任务
*/
type TaskListOptions struct {
UserId string `help:"Id of user"`
GroupId string `help:"ID of group"`
options.BaseListOptions
}
R(&TaskListOptions{}, "process-task-list", "List task", func(s *mcclient.ClientSession, args *TaskListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
if len(args.UserId) > 0 {
params.Add(jsonutils.NewString(args.UserId), "user_id")
}
if len(args.GroupId) > 0 {
params.Add(jsonutils.NewString(args.GroupId), "group_id")
}
result, err := modules.ProcessTasks.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProcessTasks.GetColumns(s))
return nil
})
/**
* 查看指定ID的任务
*/
type TaskShowOptions struct {
ID string `help:"ID of the task"`
}
R(&TaskShowOptions{}, "process-task-show", "Show task details", func(s *mcclient.ClientSession, args *TaskShowOptions) error {
result, err := modules.ProcessTasks.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
-143
View File
@@ -1,143 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type OperationListOptions struct {
options.BaseListOptions
}
R(&OperationListOptions{}, "operation-list", "List operations", func(s *mcclient.ClientSession, suboptions *OperationListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = suboptions.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Operations.List(s, params)
if err != nil {
return err
}
printList(result, modules.Operations.GetColumns(s))
return nil
})
type OperationUpdateOptions struct {
TASK_ID string `help:"TASK_ID of process" `
Content string `help:"Content of process" default:""`
Result string `help:"Result of process" default:""`
}
R(&OperationUpdateOptions{}, "operation-update", "Update operation", func(s *mcclient.ClientSession, args *OperationUpdateOptions) error {
params := jsonutils.NewDict()
// params.Add(jsonutils.NewString(args.TASK_ID), "task_id")
params.Add(jsonutils.NewString(args.Content), "content")
params.Add(jsonutils.NewString(args.Result), "result")
obj, err := modules.Operations.Put(s, args.TASK_ID, params)
if err != nil {
return err
}
printObject(obj)
return nil
})
type OperationShowOptions struct {
INSTANCE_ID string `help:"INSTANCE_ID of process" `
}
R(&OperationShowOptions{}, "operation-show", "Show operation details", func(s *mcclient.ClientSession, args *OperationShowOptions) error {
result, err := modules.Operations.Get(s, args.INSTANCE_ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
type OperationCreateOptions struct {
DeviceCode string `help:"DeviceCode of process"`
ResourceSum int64 `help:"ResourceSum of process, default: 0" default:"0"`
TemplateId string `help:"TemplateId of process" `
Cpu int64 `help:"Cpu of process, default: 0" default:"0"`
Memery int64 `help:"Memery of process, default: 0" default:"0"`
Disk int64 `help:"Disk of process, default: 0" default:"0"`
ProjectId string `help:"ProjectId of process" `
Remark string `help:"Remark of process" `
OPERATE_TYPE string `help:"OPERATE_TYPE of process" choices:"apply|config|template|delete"`
Schedule string `help:"Schedule of process"`
}
R(&OperationCreateOptions{}, "operation-create", "Create a operation", func(s *mcclient.ClientSession, args *OperationCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.OPERATE_TYPE), "operate_type")
if len(args.DeviceCode) > 0 {
params.Add(jsonutils.NewString(args.DeviceCode), "device_code")
}
if args.ResourceSum > 0 {
params.Add(jsonutils.NewInt(args.ResourceSum), "resource_sum")
}
if len(args.TemplateId) > 0 {
params.Add(jsonutils.NewString(args.TemplateId), "template_id")
}
if args.Cpu > 0 {
params.Add(jsonutils.NewInt(args.Cpu), "cpu")
}
if args.Memery > 0 {
params.Add(jsonutils.NewInt(args.Memery), "memery")
}
if args.Disk > 0 {
params.Add(jsonutils.NewInt(args.Disk), "disk")
}
if len(args.ProjectId) > 0 {
params.Add(jsonutils.NewString(args.ProjectId), "project_id")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
if len(args.Schedule) > 0 {
params.Add(jsonutils.NewString(args.Schedule), "schedule")
}
operation, err := modules.Operations.Create(s, params)
if err != nil {
return err
}
printObject(operation)
return nil
})
}
-58
View File
@@ -1,58 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type TaskListOptions struct {
options.BaseListOptions
}
R(&TaskListOptions{}, "process-list", "List processes", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = suboptions.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Processes.List(s, params)
if err != nil {
return err
}
printList(result, modules.Processes.GetColumns(s))
return nil
})
type ProcessShowOptions struct {
ID string `help:"ID or Name of the process to show"`
}
R(&ProcessShowOptions{}, "process-show", "Show process details", func(s *mcclient.ClientSession, args *ProcessShowOptions) error {
result, err := modules.Processes.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
-46
View File
@@ -1,46 +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 itsm
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type TaskListOptions struct {
options.BaseListOptions
}
R(&TaskListOptions{}, "prosesslog-list", "List processlogs", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = suboptions.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Processlogs.List(s, params)
if err != nil {
return err
}
printList(result, modules.Processlogs.GetColumns(s))
return nil
})
}
-155
View File
@@ -1,155 +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 misc
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
"path/filepath"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/yunionagent"
)
func init() {
type CopyrightUpdateOptions struct {
Copyright string `help:"The copyright"`
Email string `help:"The Email"`
Docs *string `help:"the Docs website address"`
License *string `help:"the license generator website address"`
BrandCn *string `help:"the brand name in Chinese"`
BrandEn *string `help:"the brand name in English"`
}
R(&CopyrightUpdateOptions{}, "copyright-update", "update copyright", func(s *mcclient.ClientSession, args *CopyrightUpdateOptions) error {
if !s.HasSystemAdminPrivilege() {
return fmt.Errorf("require admin privilege")
}
params := jsonutils.NewDict()
if args.Docs != nil {
params.Add(jsonutils.NewString(*args.Docs), "docs")
}
if args.License != nil {
params.Add(jsonutils.NewString(*args.License), "license")
}
if args.BrandCn != nil {
params.Add(jsonutils.NewString(*args.BrandCn), "brand_cn")
}
if args.BrandEn != nil {
params.Add(jsonutils.NewString(*args.BrandEn), "brand_en")
}
if len(args.Copyright) > 0 {
params.Add(jsonutils.NewString(args.Copyright), "copyright")
}
if len(args.Email) > 0 {
params.Add(jsonutils.NewString(args.Email), "email")
}
r, err := yunionagent.Copyright.Update(s, "copyright", params)
if err != nil {
return err
}
printObject(r)
return nil
})
type EnterpriseUpdateOptions struct {
Name string `help:"Enterprise name"`
Copyright string `help:"The Email"`
Logo string `help:"logo file path"`
LoginLogo string `help:"login page logo file path"`
Favicon string `help:"favicon path"`
}
R(&EnterpriseUpdateOptions{}, "infos-update", "update enterprise info", func(s *mcclient.ClientSession, args *EnterpriseUpdateOptions) error {
var b bytes.Buffer
w := multipart.NewWriter(&b)
if len(args.Name) > 0 {
w.WriteField("name", args.Name)
}
if len(args.Copyright) > 0 {
w.WriteField("copyright", args.Copyright)
}
writeFile := func(filedName, filePath string) error {
if len(filePath) == 0 {
return nil
}
c, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
var v string
c64 := base64.StdEncoding.EncodeToString(c)
ext := filepath.Ext(filePath)
switch ext {
case ".png":
v = fmt.Sprintf("data:image/png;base64,%s", c64)
case ".jpg":
v = fmt.Sprintf("data:image/jpg;base64,%s", c64)
default:
return fmt.Errorf("only support png/jpg image")
}
err = w.WriteField(filedName, v)
if err != nil {
return err
}
return nil
}
if err := writeFile("logo", args.Logo); err != nil {
return err
}
if err := writeFile("login_logo", args.LoginLogo); err != nil {
return err
}
if err := writeFile("favicon", args.Favicon); err != nil {
return err
}
header := make(http.Header)
header.Set("content-type", fmt.Sprintf("multipart/form-data; boundary=%s", w.Boundary()))
w.Close()
ret, err := yunionagent.Info.Update(s, header, bufio.NewReader(&b))
if err != nil {
return err
}
printObject(ret)
return nil
})
}
-111
View File
@@ -1,111 +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 misc
import (
"bytes"
"io"
"mime/multipart"
"net/http"
"os"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/yunionagent"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type LicenseListOptions struct {
options.BaseListOptions
}
R(&LicenseListOptions{}, "licenses-list", "show licenses", func(s *mcclient.ClientSession, args *LicenseListOptions) error {
params, err := options.ListStructToParams(args)
if err != nil {
return err
}
lics, err := yunionagent.License.List(s, params)
if err != nil {
return err
}
printList(lics, yunionagent.License.GetColumns(s))
return nil
})
type LicenseUploadOptions struct {
FILE string
}
R(&LicenseUploadOptions{}, "license-upload", "Upload license", func(s *mcclient.ClientSession, args *LicenseUploadOptions) error {
bodyBuf := &bytes.Buffer{}
bodyWriter := multipart.NewWriter(bodyBuf)
fileWriter, err := bodyWriter.CreateFormFile("license", args.FILE)
if err != nil {
return err
}
fh, err := os.Open(args.FILE)
if err != nil {
return err
}
defer fh.Close()
_, err = io.Copy(fileWriter, fh)
if err != nil {
return err
}
contentType := bodyWriter.FormDataContentType()
bodyWriter.Close()
header := http.Header{}
header.Set("Content-Type", contentType)
lic, err := yunionagent.License.Upload(s, header, bodyBuf)
if err != nil {
return err
}
printObject(lic)
return nil
})
type LicenseShowOptions struct {
SERVICE string `help:"service name" choices:"compute|service_tree"`
}
R(&LicenseShowOptions{}, "licenses-show", "show actived license", func(s *mcclient.ClientSession, args *LicenseShowOptions) error {
lic, e := yunionagent.License.Get(s, args.SERVICE, nil)
if e != nil {
return e
}
printObject(lic)
return nil
})
type LicenseStatusOptions struct {
SERVICE string `help:"service name" choices:"compute|service_tree"`
}
R(&LicenseStatusOptions{}, "licenses-usage", "show license usages status", func(s *mcclient.ClientSession, args *LicenseStatusOptions) error {
status, err := yunionagent.License.GetSpecific(s, args.SERVICE, "status", nil)
if err != nil {
return err
}
printObject(status)
return nil
})
}
-29
View File
@@ -1,29 +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 misc
import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/mcclient/modules/yunionagent"
options "yunion.io/x/onecloud/pkg/mcclient/options/yunionagent"
)
func init() {
cmd := shell.NewResourceCmd(&yunionagent.Notice).WithKeyword("notice")
cmd.List(&options.NoticeListOptions{})
cmd.Create(&options.NoticeCreateOptions{})
cmd.Update(&options.NoticesUpdateOptions{})
cmd.Delete(&options.NoticeOptions{})
}
-23
View File
@@ -19,32 +19,9 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type TaskListOptions struct {
options.BaseListOptions
}
R(&TaskListOptions{}, "task-list", "List taskman", func(s *mcclient.ClientSession, suboptions *TaskListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = suboptions.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := itsm.Tasks.List(s, params)
if err != nil {
return err
}
printList(result, itsm.Tasks.GetColumns(s))
return nil
})
type RegionTaskListOptions struct {
ObjName string `help:"object name"`
ObjId string `help:"object id"`
-72
View File
@@ -1,72 +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 misc
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/autoupdate"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type SUpdateListOptions struct {
options.BaseListOptions
Region string `help:"cloud region ID or Name"`
}
R(&SUpdateListOptions{}, "update-list", "List updates", func(s *mcclient.ClientSession, args *SUpdateListOptions) error {
// TODO filer by region
result, err := modules.Updates.List(s, nil)
if err != nil {
return err
}
printList(result, modules.Updates.GetColumns(s))
return nil
})
type SUpdatePerformOptions struct {
Cmp bool `help:"update Controller And all the Compute nodes automatically"`
CmpOnly bool `help:"Updates only computes nodes, excluding controller nodes"`
}
R(&SUpdatePerformOptions{}, "update-perform", "Update the Controler", func(s *mcclient.ClientSession, args *SUpdatePerformOptions) error {
params := jsonutils.NewDict()
if args.Cmp && args.CmpOnly {
return fmt.Errorf("--cmp and --cmp-only can't go together")
}
if args.Cmp {
params.Add(jsonutils.JSONTrue, "cmp")
} else if args.CmpOnly {
params.Add(jsonutils.JSONTrue, "cmp_only")
}
modules.Updates.PerformAction(s, "", "", params)
result, err := modules.Updates.List(s, nil)
if err != nil {
return err
}
printList(result, modules.Updates.GetColumns(s))
return nil
})
}
-32
View File
@@ -25,8 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/modules/identity"
"yunion.io/x/onecloud/pkg/mcclient/modules/yunionagent"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
@@ -44,7 +42,6 @@ func init() {
type VersionListOptions struct {
}
R(&VersionListOptions{}, "version-list", "query all backend service version", func(s *mcclient.ClientSession, args *VersionListOptions) error {
services := []jsonutils.JSONObject{}
params := map[string]interface{}{}
@@ -78,33 +75,4 @@ func init() {
printObject(jsonutils.Marshal(vers))
return nil
})
R(&options.VersionListOptions{}, "yunionagent-version-list", "show versions of backend services", func(s *mcclient.ClientSession, opts *options.VersionListOptions) error {
if len(opts.Region) == 0 {
opts.Region = s.GetRegion()
}
params, err := options.StructToParams(opts)
if err != nil {
return err
}
result, err := yunionagent.Version.List(s, params)
if err != nil {
return err
}
printList(result, []string{})
return nil
})
R(&options.VersionGetOptions{}, "yunionagent-version-show", "Show service version", func(s *mcclient.ClientSession, opts *options.VersionGetOptions) error {
result, err := yunionagent.Version.Get(s, opts.Service, nil)
if err != nil {
return err
}
ver, err := result.GetString()
if err != nil {
return err
}
fmt.Printf("%s\n", ver)
return nil
})
}
-42
View File
@@ -1,42 +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 misc
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/websocket"
)
func init() {
type SWebsocketNotifyOptions struct {
Cmp bool `help:"websocket all the compute nodes automatically"`
}
R(&SWebsocketNotifyOptions{}, "websocket-notify", "post a Websocket msg", func(s *mcclient.ClientSession, args *SWebsocketNotifyOptions) error {
params := jsonutils.NewDict()
if args.Cmp {
params.Add(jsonutils.JSONTrue, "cmp")
}
_, err := websocket.Websockets.Create(s, params)
if err != nil {
return err
}
return nil
})
}
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package itsm
package quota
import (
"yunion.io/x/onecloud/cmd/climc/shell"
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
package quota
import (
"yunion.io/x/jsonutils"
@@ -20,7 +20,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/quota"
)
type ComputeQuotaKeys struct {
@@ -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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出报警事件
*/
R(&options.AlarmEventListOptions{}, "alarmevent-list", "List all alarm's event", func(s *mcclient.ClientSession, opts *options.AlarmEventListOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
}
result, err := modules.AlarmEvents.List(s, params)
if err != nil {
return err
}
printList(result, modules.AlarmEvents.GetColumns(s))
return nil
})
/*
* 修改报警事件ACK确认状态
*/
type AlarmEventUpdateOptions struct {
ID string `help:"ID of the alarm event"`
STATUS int64 `help:"Alarm event ack status" choices:"0|1"`
}
R(&AlarmEventUpdateOptions{}, "alarmevent-ack-update", "Update ack status of alarm event", func(s *mcclient.ClientSession, args *AlarmEventUpdateOptions) error {
arr := jsonutils.NewArray()
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(args.ID), "id")
tmpObj.Add(jsonutils.NewInt(args.STATUS), "ack_status")
arr.Add(tmpObj)
params := jsonutils.NewDict()
params.Add(arr, "alarm_events")
alarmevent, err := modules.AlarmEvents.DoBatchUpdate(s, params)
if err != nil {
return err
}
printObject(alarmevent)
return nil
})
}
-154
View File
@@ -1,154 +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 servicetree
import (
"fmt"
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建报警日志
*/
type AlarmLogDetailOptions struct {
NODE_NAME string `help:"Name of the host"`
Lables string `help:"Labels of the service tree node"`
Metric_Name string `help:"Metric name of the alarm"`
Start_Time string `help:"Alarm start time"`
This_Time string `help:"Alarm this time"`
Alarm_Ways string `help:"Alarm ways"`
Alarm_Level string `help:"Alarm level"`
Alarm_Status string `help:"Alarm status"`
Receive_Person string `help:"Alarm receive person"`
Reason string `help:"Alarm reason, aka alarm rule content"`
Alarm_Id string `help:"Alarm ID"`
Host_Id string `help:"ID of the host"`
}
R(&AlarmLogDetailOptions{}, "alarmlog-create", "Create a alarm log", func(s *mcclient.ClientSession, args *AlarmLogDetailOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NODE_NAME), "node_name")
if len(args.Lables) > 0 {
params.Add(jsonutils.NewString(args.Lables), "labels")
}
if len(args.Metric_Name) > 0 {
params.Add(jsonutils.NewString(args.Metric_Name), "metric_name")
}
if len(args.Start_Time) > 0 {
params.Add(jsonutils.NewString(args.Start_Time), "start_time")
}
if len(args.This_Time) > 0 {
params.Add(jsonutils.NewString(args.This_Time), "this_time")
}
if len(args.Alarm_Ways) > 0 {
params.Add(jsonutils.NewString(args.Alarm_Ways), "alarm_ways")
}
if len(args.Alarm_Level) > 0 {
params.Add(jsonutils.NewString(args.Alarm_Level), "alarm_level")
}
if len(args.Alarm_Status) > 0 {
params.Add(jsonutils.NewString(args.Alarm_Status), "alarm_status")
}
if len(args.Receive_Person) > 0 {
params.Add(jsonutils.NewString(args.Receive_Person), "receive_person")
}
if len(args.Reason) > 0 {
params.Add(jsonutils.NewString(args.Reason), "reason")
}
if len(args.Alarm_Id) > 0 {
params.Add(jsonutils.NewString(args.Alarm_Id), "alarm_id")
}
if len(args.Host_Id) > 0 {
params.Add(jsonutils.NewString(args.Host_Id), "host_id")
}
alarmlog, err := modules.AlarmLogs.Create(s, params)
if err != nil {
return err
}
printObject(alarmlog)
return nil
})
/**
* 列出报警日志
*/
type AlarmLogListOptions struct {
options.BaseListOptions
Host string `help:"Name of the host"`
Id int64 `help:"ID of tree node"`
Label []string `help:"Labels to this tree node"`
Metric string `help:"Metric name"`
StartTimeSince string `help:"Start time since the alarm event"`
StartTimeUntil string `help:"Start time until the alarm event"`
ThisTimeSince string `help:"This time since the alarm event"`
ThisTimeUntil string `help:"This time until the alarm event"`
}
R(&AlarmLogListOptions{}, "alarmlog-list", "List all alarm's event", func(s *mcclient.ClientSession, args *AlarmLogListOptions) error {
params, err := args.BaseListOptions.Params()
if err != nil {
return err
}
if len(args.Host) > 0 {
params.Add(jsonutils.NewString(args.Host), "host")
}
if len(args.Label) > 0 {
names := []string{"corp", "owt", "pdl", "srv", "env"}
segs := make([]string, len(args.Label))
for i := 0; i < len(args.Label); i += 1 {
sublabel := args.Label[:i+1]
pid, _ := modules.TreeNodes.GetNodeIDByLabels(s, sublabel)
if pid < 0 {
return fmt.Errorf("Invalid node data")
}
segs[i] = fmt.Sprintf("%s=%d", names[i], pid)
}
node_labels := strings.Join(segs, ",")
params.Add(jsonutils.NewString(node_labels), "node_labels")
}
if len(args.Metric) > 0 {
params.Add(jsonutils.NewString(args.Metric), "metric")
}
if len(args.StartTimeSince) > 0 {
params.Add(jsonutils.NewString(args.StartTimeSince), "start_time_since")
}
if len(args.StartTimeUntil) > 0 {
params.Add(jsonutils.NewString(args.StartTimeUntil), "start_time_until")
}
if len(args.ThisTimeSince) > 0 {
params.Add(jsonutils.NewString(args.ThisTimeSince), "this_time_since")
}
if len(args.ThisTimeUntil) > 0 {
params.Add(jsonutils.NewString(args.ThisTimeUntil), "this_time_until")
}
result, err := modules.AlarmLogs.List(s, params)
if err != nil {
return err
}
printList(result, modules.AlarmLogs.GetColumns(s))
return nil
})
}
-168
View File
@@ -1,168 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建报警规则
*/
type AlarmDetailOptions struct {
METRICNAME string `help:"Metric name of the alarm"`
ALARMCONDITION string `help:"Alarm condition template of the alarm"`
TEMPLATE string `help:"Alarm condition template of the alarm"`
ALARMLEVEL string `help:"Alarm level of the alarm"`
CONTACT_TYPE string `help:"Alarm contact type"`
EXPIRESECONDS int64 `help:"Expire seconds of the alarm"`
ESCALATESECONDS int64 `help:"Escalate seconds of the alarm"`
ALARMTEMPLATE_ID string `help:"ID of the alarm template"`
Remark string `help:"Remark or description of the new alarm"`
}
R(&AlarmDetailOptions{}, "alarm-create", "Create a alarm", func(s *mcclient.ClientSession, args *AlarmDetailOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.METRICNAME), "metric_name")
params.Add(jsonutils.NewString(args.ALARMCONDITION), "alarm_condition")
params.Add(jsonutils.NewString(args.TEMPLATE), "template")
params.Add(jsonutils.NewString(args.ALARMLEVEL), "alarm_level")
params.Add(jsonutils.NewString(args.CONTACT_TYPE), "contact_type")
params.Add(jsonutils.NewInt(args.EXPIRESECONDS), "expire_seconds")
params.Add(jsonutils.NewInt(args.ESCALATESECONDS), "escalate_seconds")
params.Add(jsonutils.NewString(args.ALARMTEMPLATE_ID), "alarm_template_id")
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
alarm, err := modules.Alarms.Create(s, params)
if err != nil {
return err
}
printObject(alarm)
return nil
})
/**
* 删除指定ID的报警规则
*/
type AlarmDeleteOptions struct {
ID string `help:"ID of alarm"`
}
R(&AlarmDeleteOptions{}, "alarm-delete", "Delete a alarm", func(s *mcclient.ClientSession, args *AlarmDeleteOptions) error {
alarm, e := modules.Alarms.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(alarm)
return nil
})
/**
* 修改指定ID的报警规则
*/
type AlarmUpdateOptions struct {
ID string `help:"ID of the alarm"`
Name string `help:"Name of the new alarm"`
MetricName string `help:"Metric name of the alarm"`
AlarmCondition string `help:"Alarm condition template of the alarm"`
Template string `help:"Alarm condition template of the alarm"`
AlarmLevel string `help:"Alarm level of the alarm"`
ContactType string `help:"Alarm contact type"`
ExpireSeconds int64 `help:"Expire seconds of the alarm"`
EscalateSeconds int64 `help:"Escalate seconds of the alarm"`
Remark string `help:"Remark or description of the new alarm"`
}
R(&AlarmUpdateOptions{}, "alarm-update", "Update a alarm", func(s *mcclient.ClientSession, args *AlarmUpdateOptions) error {
params := jsonutils.NewDict()
if len(args.Name) > 0 {
params.Add(jsonutils.NewString(args.Name), "name")
}
if len(args.MetricName) > 0 {
params.Add(jsonutils.NewString(args.MetricName), "metric_name")
}
if len(args.AlarmCondition) > 0 {
params.Add(jsonutils.NewString(args.AlarmCondition), "alarm_condition")
}
if len(args.Template) > 0 {
params.Add(jsonutils.NewString(args.Template), "template")
}
if len(args.AlarmLevel) > 0 {
params.Add(jsonutils.NewString(args.AlarmLevel), "alarm_level")
}
if len(args.ContactType) > 0 {
params.Add(jsonutils.NewString(args.ContactType), "contact_type")
}
if args.ExpireSeconds > 0 {
params.Add(jsonutils.NewInt(args.ExpireSeconds), "expire_seconds")
}
if args.EscalateSeconds > 0 {
params.Add(jsonutils.NewInt(args.EscalateSeconds), "escalate_seconds")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
alarm, err := modules.Labels.Patch(s, args.ID, params)
if err != nil {
return err
}
printObject(alarm)
return nil
})
/**
* 列出报警规则
*/
type AlarmListOptions struct {
options.BaseListOptions
}
R(&AlarmListOptions{}, "alarm-list", "List all alarms", func(s *mcclient.ClientSession, args *AlarmListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Alarms.List(s, params)
if err != nil {
return err
}
printList(result, modules.Alarms.GetColumns(s))
return nil
})
/**
* 根据ID查询报警规则
*/
type AlarmShowOptions struct {
ID string `help:"ID of the alarm to show"`
}
R(&AlarmShowOptions{}, "alarm-show", "Show alarm details", func(s *mcclient.ClientSession, args *AlarmShowOptions) error {
result, err := modules.Alarms.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,369 +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 servicetree
import (
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建报警模板
*/
type AlarmTemplateOptions struct {
NAME string `help:"Name of the new alarm-template"`
BELONGTO string `help:"Detect the service-tree-node' labels which alarm-template belong to"`
Description string `help:"Description of the alarm-template"`
}
R(&AlarmTemplateOptions{}, "alarmtemplate-create", "Create a alarm-template", func(s *mcclient.ClientSession, args *AlarmTemplateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "alarm_template_name")
params.Add(jsonutils.NewString(args.BELONGTO), "belongto")
if len(args.Description) > 0 {
params.Add(jsonutils.NewString(args.Description), "alarm_template_desc")
}
alarmTemplate, err := modules.AlarmTemplates.Create(s, params)
if err != nil {
return err
}
printObject(alarmTemplate)
return nil
})
/**
* 删除指定ID的报警模板
*/
type AlarmTemplateDeleteOptions struct {
ID string `help:"ID of alarm-template"`
}
R(&AlarmTemplateDeleteOptions{}, "alarmtemplate-delete", "Delete a alarm-template", func(s *mcclient.ClientSession, args *AlarmTemplateDeleteOptions) error {
alarmTemplate, e := modules.AlarmTemplates.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(alarmTemplate)
return nil
})
/**
* 修改指定ID的报警模板
*/
type AlarmTemplateUpdateOptions struct {
ID string `help:"ID of the alarm-template"`
Name string `help:"New name of the new alarm-template"`
Description string `help:"New description of the alarm-template"`
}
R(&AlarmTemplateUpdateOptions{}, "alarmtemplate-update", "Update a alarm-template", func(s *mcclient.ClientSession, args *AlarmTemplateUpdateOptions) error {
params := jsonutils.NewDict()
if len(args.Name) > 0 {
params.Add(jsonutils.NewString(args.Name), "alarm_template_name")
}
if len(args.Description) > 0 {
params.Add(jsonutils.NewString(args.Description), "alarm_template_desc")
}
alarmTemplate, err := modules.AlarmTemplates.Put(s, args.ID, params)
if err != nil {
return err
}
printObject(alarmTemplate)
return nil
})
/**
* 列出报警模板
*/
type AlarmTemplateListOptions struct {
options.BaseListOptions
LIST_TYPE string `help:"Type of list: avaliable|applied|created "`
LABELS string `help:"Labels for node(split by comma)"`
}
R(&AlarmTemplateListOptions{}, "alarmtemplate-list", "List all alarm templates ", func(s *mcclient.ClientSession, args *AlarmTemplateListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
params.Add(jsonutils.NewString(args.LIST_TYPE), "type")
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
result, err := modules.AlarmTemplates.List(s, params)
if err != nil {
return err
}
printList(result, modules.AlarmTemplates.GetColumns(s))
return nil
})
/**
* 根据ID查询报警模板(查看报警模板详情)
*/
type AlarmTemplateShowOptions struct {
ID string `help:"ID of the alarm-template to show"`
}
R(&AlarmTemplateShowOptions{}, "alarmtemplate-show", "Show alarm template details", func(s *mcclient.ClientSession, args *AlarmTemplateShowOptions) error {
result, err := modules.AlarmTemplates.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 查看报警模板下的报警项
*/
type AlarmTemplateBaseOptions struct {
ID string `help:"ID of the alarm template"`
}
R(&AlarmTemplateBaseOptions{}, "alarmtemplate-alarm-list", "List alarms of alarm template", func(s *mcclient.ClientSession, args *AlarmTemplateBaseOptions) error {
result, err := modules.AlarmTemplateAlarms.ListDescendent(s, args.ID, nil)
if err != nil {
return err
}
printList(result, modules.Alarms.GetColumns(s))
return nil
})
/**
* 向指定的报警模板中添加报警项(添加报警项)
*/
type AlarmTemplateAlarmOptions struct {
ALARMTEMPLATE_ID string `help:"ID of alarm-template"`
ALARM_ID string `help:"ID of alarm"`
}
R(&AlarmTemplateAlarmOptions{}, "add-alarm-to-template", "Add alarm to alarm-template", func(s *mcclient.ClientSession, args *AlarmTemplateAlarmOptions) error {
_, err := modules.AlarmTemplateAlarms.Attach(s, args.ALARMTEMPLATE_ID, args.ALARM_ID, nil)
if err != nil {
return err
}
return nil
})
/**
* 从指定的报警模板中删除报警项(删除报警项)
*/
R(&AlarmTemplateAlarmOptions{}, "remove-alarm-from-template", "Remove alarm from alarm-template", func(s *mcclient.ClientSession, args *AlarmTemplateAlarmOptions) error {
_, err := modules.Alarms.DeleteInContext(s, args.ALARM_ID, nil, &modules.AlarmTemplates, args.ALARMTEMPLATE_ID)
if err != nil {
return err
}
return nil
})
/**
* 给服务树节点增加报警模板
*/
type AlarmTemplateNodeAddOptions struct {
ID string `help:"ID of alarm-template"`
Labels []string `help:"Labels for node" nargs:"+"`
Receiver1 string `help:"Primary alarm receiver" nargs:"+"`
Receiver2 string `help:"Secondary alarm receiver"`
}
R(&AlarmTemplateNodeAddOptions{}, "bind-template-to-node", "Bind alarm-template to service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateNodeAddOptions) error {
labels := jsonutils.NewDict()
for _, f := range args.Labels {
parts := strings.Split(f, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(labels, "labels")
params.Add(jsonutils.NewString(args.Receiver1), "tier1_receivers")
params.Add(jsonutils.NewString(args.Receiver2), "tier2_receivers")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "add-labels", params)
if err != nil {
return err
}
return nil
})
/**
* 将报警模板从服务数节点移除
*/
type AlarmTemplateRemoveFromNodeOptions struct {
ID string `help:"ID of the alarm-template"`
Labels []string `help:"Node labels" nargs:"+"`
}
R(&AlarmTemplateRemoveFromNodeOptions{}, "unbind-template-from-node", "Unbind alarm-template from service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateRemoveFromNodeOptions) error {
labels := jsonutils.NewDict()
for _, f := range args.Labels {
parts := strings.Split(f, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(labels, "labels")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "remove-labels", params)
if err != nil {
return err
}
return nil
})
/**
* 给服务树编辑模板详情
*/
type AlarmTemplateNodeUpdateOptions struct {
ID string `help:"ID of alarm-template"`
Labels []string `help:"Labels for node" nargs:"+"`
Receiver1 string `help:"Primary alarm receiver"`
Receiver2 string `help:"Secondary alarm receiver"`
}
R(&AlarmTemplateNodeUpdateOptions{}, "update-template-for-node", "Update alarm-template for service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateNodeUpdateOptions) error {
labels := jsonutils.NewDict()
for _, f := range args.Labels {
parts := strings.Split(f, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(labels, "labels")
params.Add(jsonutils.NewString(args.Receiver1), "tier1_receivers")
params.Add(jsonutils.NewString(args.Receiver2), "tier2_receivers")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "update-labels", params)
if err != nil {
return err
}
return nil
})
/**
* 查看此模板有哪些label正在使用
*/
type AlarmTemplateLabelListOptions struct {
ID string `help:"ID of alarm-template"`
}
R(&AlarmTemplateLabelListOptions{}, "labels-for-alarmtemplate", "List all the labels for the alarm-templates", func(s *mcclient.ClientSession, args *AlarmTemplateLabelListOptions) error {
result, err := modules.AlarmTemplates.GetSpecific(s, args.ID, "labels", nil)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 为树务树节点添加报警模板
*/
type AlarmTemplateAddToNodeOptions struct {
ID string `help:"ID of alarm-template"`
LABELS string `help:"Labels for node"`
Status int64 `help:"Enabled or disabled binding status" choices:"1|0"`
}
R(&AlarmTemplateAddToNodeOptions{}, "add-alarmtemplate-to-treenode", "Bind alarm-template to service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateAddToNodeOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
if args.Status > 0 {
params.Add(jsonutils.NewInt(args.Status), "enabled")
}
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "add-to-treenode", params)
if err != nil {
return err
}
return nil
})
/**
* 从树务树节点删除报警模板
*/
type AlarmTemplateDeleteFromNodeOptions struct {
ID string `help:"ID of alarm-template"`
LABELS string `help:"Labels for node"`
}
R(&AlarmTemplateDeleteFromNodeOptions{}, "delete-alarmtemplate-from-treenode", "UnBind alarm-template from service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateDeleteFromNodeOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "delete-from-treenode", params)
if err != nil {
return err
}
return nil
})
/**
* 克隆报警模板到服务树节点
*/
type AlarmTemplateeCloneToNodeOptions struct {
ID string `help:"ID of alarm-template"`
LABELS string `help:"Labels for node"`
}
R(&AlarmTemplateeCloneToNodeOptions{}, "clone-alarmtemplate-to-treenode", "Bind alarm-template to service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateeCloneToNodeOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "clone-to-treenode", params)
if err != nil {
return err
}
return nil
})
/**
* 修改树务树节点绑定的报警模板状态
*/
type AlarmTemplateDChangeStatusNodeOptions struct {
ID string `help:"ID of alarm-template"`
LABELS string `help:"Labels for node"`
STATUS int64 `help:"Enabled or disabled binding status, choices is 1|0"`
}
R(&AlarmTemplateDChangeStatusNodeOptions{}, "change-status-alarmtemplate-for-treenode", "UnBind alarm-template from service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateDChangeStatusNodeOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
params.Add(jsonutils.NewInt(args.STATUS), "enabled")
_, err := modules.AlarmTemplates.PerformAction(s, args.ID, "change-bind-status", params)
if err != nil {
return err
}
return nil
})
/**
* 修改报警模板下的报警规则的状态
*/
type AlarmTemplateAlarmEnabledOptions struct {
ALARMTEMPLATE_ID string `help:"ID of alarm-template"`
ALARM_ID string `help:"ID of alarm"`
ENABLED int64 `help:"Enabled or disabled binding status, choices is 1|0"`
}
R(&AlarmTemplateAlarmEnabledOptions{}, "change-alarm-enabled", "UnBind alarm-template from service-tree node", func(s *mcclient.ClientSession, args *AlarmTemplateAlarmEnabledOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewInt(args.ENABLED), "enabled")
_, err := modules.AlarmTemplateAlarms.Update(s, args.ALARMTEMPLATE_ID, args.ALARM_ID, nil, params)
if err != nil {
return err
}
return nil
})
}
-30
View File
@@ -1,30 +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 servicetree
import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
)
var (
R = shell.R
printList = printutils.PrintJSONList
printObject = printutils.PrintJSONObject
printBatchResults = printutils.PrintJSONBatchResults
InvalidUpdateError = shell.InvalidUpdateError
printObjectRecursive = printutils.PrintJSONObjectRecursive
)
-121
View File
@@ -1,121 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 新建一个标签
*/
type LabelCreateOptions struct {
NAME string `help:"Name of the new label"`
VALUETYPE string `help:"Label value's type such as int, float, string, bool, choices"`
Remark string `help:"Remark or description of the new label"`
}
R(&LabelCreateOptions{}, "label-create", "Create a label", func(s *mcclient.ClientSession, args *LabelCreateOptions) error {
mod, err := modulebase.GetModule(s, "labels")
if err != nil {
return err
}
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "name")
params.Add(jsonutils.NewString(args.VALUETYPE), "value_type")
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
label, err := mod.Create(s, params)
if err != nil {
return err
}
printObject(label)
return nil
})
/**
* 删除指定name的标签(删除指定name的标签)
*/
type LabelDeleteOptions struct {
NAME string `help:"Name of label"`
}
R(&LabelDeleteOptions{}, "label-delete", "Delete a label", func(s *mcclient.ClientSession, args *LabelDeleteOptions) error {
label, e := modules.Labels.Delete(s, args.NAME, nil)
if e != nil {
return e
}
printObject(label)
return nil
})
/**
* 修改标签(修改指定name的标签)
*/
type LabelUpdateOptions struct {
NAME string `help:"Name of the label"`
ValueType string `help:"Label value's type such as int, float, string, bool, choices"`
Remark string `help:"Remark or description of the new label"`
}
R(&LabelUpdateOptions{}, "label-update", "Update a label", func(s *mcclient.ClientSession, args *LabelUpdateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "name")
if len(args.ValueType) > 0 {
params.Add(jsonutils.NewString(args.ValueType), "value_type")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
label, err := modules.Labels.Patch(s, args.NAME, params)
if err != nil {
return err
}
printObject(label)
return nil
})
/**
* 列出所有的标签
*/
type LabelListOptions struct {
options.BaseListOptions
}
R(&LabelListOptions{}, "label-list", "List labels", func(s *mcclient.ClientSession, args *LabelListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Labels.List(s, params)
if err != nil {
return err
}
printList(result, modules.Labels.GetColumns(s))
return nil
})
}
@@ -1,41 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
)
func init() {
/**
* 列出指定监控类型下的全部指标类型
*/
type MonitorTypesBaseOptions struct {
ID string `help:"ID of the monitor type"`
}
R(&MonitorTypesBaseOptions{}, "monitortype-metrictype-list", "List metric types of the monitor type", func(s *mcclient.ClientSession, args *MonitorTypesBaseOptions) error {
result, err := modules.MetricsTypes.ListInContext(s, nil, &modules.MonitorTypes, args.ID)
if err != nil {
return err
}
printList(result, modules.MetricsTypes.GetColumns(s))
return nil
})
}
-122
View File
@@ -1,122 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出指定指标类型下的全部指标
*/
type MetricTypesBaseOptions struct {
ID string `help:"ID of the metric type"`
}
R(&MetricTypesBaseOptions{}, "metrictype-metric-list", "List metric types of the monitor type", func(s *mcclient.ClientSession, args *MetricTypesBaseOptions) error {
result, err := modules.Metrics.ListInContext(s, nil, &modules.MetricsTypes, args.ID)
if err != nil {
return err
}
printList(result, modules.Metrics.GetColumns(s))
return nil
})
/**
* 列出所有监控指标
*/
type MetricsListOptions struct {
options.BaseListOptions
}
R(&MetricsListOptions{}, "metric-list", "List all metrics", func(s *mcclient.ClientSession, args *MetricsListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Metrics.List(s, params)
if err != nil {
return err
}
printList(result, modules.Metrics.GetColumns(s))
return nil
})
/**
* 查看监控指标详情
*/
type MetricsShowOptions struct {
options.BaseListOptions
ID string `help:"The ID of the metric"`
}
R(&MetricsShowOptions{}, "metric-show", "Show metric details", func(s *mcclient.ClientSession, args *MetricsShowOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Metrics.Get(s, args.ID, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 根据name查看监控指标详情
*/
type MetricsShowByNameOptions struct {
options.BaseListOptions
NAME string `help:"The NAME of the metric"`
}
R(&MetricsShowByNameOptions{}, "metric-details", "Show metric details by name", func(s *mcclient.ClientSession, args *MetricsShowByNameOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Metrics.GetSpecific(s, "", args.NAME, params)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,68 +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 servicetree
import (
"fmt"
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
)
func init() {
/**
* 添加/修改树节点的统计指标(配置服务树某个节点都有什么监控指标)
*/
type MonitorMetricsUpdateOptions struct {
LABEL []string `help:"Labels to this tree node"`
MetricName []string `help:"Metric names to add to" nargs:"+"`
}
R(&MonitorMetricsUpdateOptions{}, "monitor-metrics-set", "Set monitor metric for the tree-node", func(s *mcclient.ClientSession, args *MonitorMetricsUpdateOptions) error {
names := []string{"corp", "owt", "pdl", "srv", "env"}
segs := make([]string, len(args.LABEL))
for i := 0; i < len(args.LABEL); i += 1 {
sublabel := args.LABEL[:i+1]
pid, _ := modules.TreeNodes.GetNodeIDByLabels(s, sublabel)
segs[i] = fmt.Sprintf("%s=%d", names[i], pid)
}
node_labels := strings.Join(segs, ",")
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(node_labels), "node_labels")
arr := jsonutils.NewArray()
if len(args.MetricName) > 0 {
for _, f := range args.MetricName {
arr.Add(jsonutils.NewString(f))
}
}
params.Add(arr, "metrics")
rst, err := modules.MonitorMetrics.Create(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
}
@@ -1,53 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出全部的监控类型
*/
type MonitorTypesOptions struct {
options.BaseListOptions
}
R(&MonitorTypesOptions{}, "monitortype-list", "List all monitor types", func(s *mcclient.ClientSession, args *MonitorTypesOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.MonitorTypes.List(s, params)
if err != nil {
return err
}
printList(result, modules.MonitorTypes.GetColumns(s))
return nil
})
}
@@ -1,80 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出所有监控数据源
*/
type MonitorInputsListOptions struct {
options.BaseListOptions
}
R(&MonitorInputsListOptions{}, "monitorinputs-list", "List all monitor-inputs", func(s *mcclient.ClientSession, args *MonitorInputsListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.MonitorInputs.List(s, params)
if err != nil {
return err
}
printList(result, modules.MonitorInputs.GetColumns(s))
return nil
})
/**
* 查看监控数据源下的监控项
*/
type MonitorInputsShowOptions struct {
options.BaseListOptions
ID string `help:"The ID of the monitor-input"`
}
R(&MonitorInputsShowOptions{}, "monitorinputs-metrics-list", "List all metrics for the monitor-inputs", func(s *mcclient.ClientSession, args *MonitorInputsShowOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.MonitorInputs.GetSpecific(s, args.ID, "metrics", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,218 +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 servicetree
import (
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建监控模板
*/
type MonitorTemplateCreateOptions struct {
NAME string `help:"The name of the monitor-template"`
Desc string `help:"Description of the monitor-template"`
MonitorInputs []string `help:"Monitor-inputs add to the monitor-template"`
}
R(&MonitorTemplateCreateOptions{}, "monitortemplate-create", "Create or update contact for user", func(s *mcclient.ClientSession, args *MonitorTemplateCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "monitor_template_name")
if len(args.Desc) > 0 {
params.Add(jsonutils.NewString(args.Desc), "monitor_template_desc")
}
if len(args.MonitorInputs) > 0 {
monitors := jsonutils.NewDict()
for _, f := range args.MonitorInputs {
parts := strings.Split(f, "=")
monitors.Add(jsonutils.NewString(parts[1]), parts[0])
}
params.Add(monitors, "monitors")
}
monitortemplate, err := modules.MonitorTemplates.Create(s, params)
if err != nil {
return err
}
printObject(monitortemplate)
return nil
})
/**
* 列出监控模板
*/
type MonitorTemplateListOptions struct {
options.BaseListOptions
}
R(&MonitorTemplateListOptions{}, "monitortemplate-list", "List all monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.MonitorTemplates.List(s, params)
if err != nil {
return err
}
printList(result, modules.MonitorTemplates.GetColumns(s))
return nil
})
/**
* 查看监控模板详情
*/
type MonitorTemplateShowOptions struct {
options.BaseListOptions
ID string `help:"The ID of the monitor-template"`
}
R(&MonitorTemplateShowOptions{}, "monitortemplate-show", "Show monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateShowOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.MonitorTemplates.Get(s, args.ID, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 查看模板下的监控项
*/
type MonitorTemplateMonitorInputsListOptions struct {
MONITOR_TEMPLATE_ID string `help:"The ID of the monitor-template"`
}
R(&MonitorTemplateMonitorInputsListOptions{}, "monitortemplate-monitorinput-list", "Get monitor-inputs of a monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateMonitorInputsListOptions) error {
result, err := modules.MonitorTemplateInputs.ListDescendent(s, args.MONITOR_TEMPLATE_ID, nil)
if err != nil {
return err
}
printList(result, modules.MonitorInputs.GetColumns(s))
return nil
})
/**
* 更新监控模板信息
*/
type MonitorTemplateUpdateOptions struct {
ID string `help:"The ID of the monitor-template"`
NAME string `help:"The name of the monitor-template"`
Desc string `help:"Description of the monitor-template"`
MonitorInputs []string `help:"Monitor-inputs attached to the monitor-template"`
}
R(&MonitorTemplateUpdateOptions{}, "monitortemplate-update", "Update a monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateUpdateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "monitor_template_name")
if len(args.Desc) > 0 {
params.Add(jsonutils.NewString(args.Desc), "monitor_template_desc")
}
if len(args.MonitorInputs) > 0 {
monitors := jsonutils.NewDict()
for _, f := range args.MonitorInputs {
parts := strings.Split(f, "=")
monitors.Add(jsonutils.NewString(parts[1]), parts[0])
}
params.Add(monitors, "monitors")
}
monitortemplate, err := modules.MonitorTemplates.Put(s, args.ID, params)
if err != nil {
return err
}
printObject(monitortemplate)
return nil
})
/**
* 向监控模板中添加监控项
*/
type MonitorTemplateMonitorInputsOptions struct {
MONITOR_TEMPLATE_ID string `help:"The ID of the monitor-template"`
MONITOR_INPUT_NAME string `help:"The name of the monitor-input"`
MonitorConfig string `help:"The config of the monitor-input"`
}
R(&MonitorTemplateMonitorInputsOptions{}, "monitortemplate-attach-monitorinput", "Add a monitor-input to a monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateMonitorInputsOptions) error {
params := jsonutils.NewDict()
if len(args.MonitorConfig) > 0 {
params.Add(jsonutils.NewString(args.MonitorConfig), "monitor_conf_value")
}
monitor_template_inputs, err := modules.MonitorTemplateInputs.Update(s, args.MONITOR_TEMPLATE_ID, args.MONITOR_INPUT_NAME, nil, params)
if err != nil {
return err
}
printObject(monitor_template_inputs)
return nil
})
/**
* 从监控模板中删除监控项
*/
R(&MonitorTemplateMonitorInputsOptions{}, "monitortemplate-detach-monitorinput", "Add a monitor-input to a monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateMonitorInputsOptions) error {
_, err := modules.MonitorInputs.DeleteInContext(s, args.MONITOR_INPUT_NAME, nil, &modules.MonitorTemplates, args.MONITOR_TEMPLATE_ID)
if err != nil {
return err
}
return nil
})
/**
* 删除监控模板
*/
type MonitorTemplateDeleteOptions struct {
ID string `help:"The ID of the monitor-template"`
}
R(&MonitorTemplateDeleteOptions{}, "monitortemplate-delete", "Delete a monitor-template", func(s *mcclient.ClientSession, args *MonitorTemplateDeleteOptions) error {
monitortemplate, e := modules.MonitorInputs.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(monitortemplate)
return nil
})
}
-191
View File
@@ -1,191 +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 servicetree
import (
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 查看所有的监控节点 | 列出匹配标签的节点列表
*/
type NodeListOptions struct {
options.BaseListOptions
Labels []string `help:"Node labels"`
}
R(&NodeListOptions{}, "node-list", "List all nodes", func(s *mcclient.ClientSession, args *NodeListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
if len(args.Labels) > 0 {
for _, f := range args.Labels {
parts := strings.Split(f, "=")
params.Add(jsonutils.NewString(parts[1]), parts[0])
}
}
result, err := modules.Nodes.List(s, params)
if err != nil {
return err
}
printList(result, modules.Nodes.GetColumns(s))
return nil
})
/**
* 查看节点的标签
*/
type NodeBaseOptions struct {
ID string `help:"ID of the node"`
}
R(&NodeBaseOptions{}, "list-labels-for-node", "List labels for the node", func(s *mcclient.ClientSession, args *NodeBaseOptions) error {
result, err := modules.Labels.ListInContext(s, nil, &modules.Nodes, args.ID)
if err != nil {
return err
}
printList(result, modules.Labels.GetColumns(s))
return nil
})
/**
* 新增标签
*/
type NodeLabelsAddOptions struct {
ID string `help:"ID of node"`
LABELS []string `help:"Node labels"`
}
R(&NodeLabelsAddOptions{}, "add-labels-to-node", "Add labels to node", func(s *mcclient.ClientSession, args *NodeLabelsAddOptions) error {
labels := jsonutils.NewDict()
for _, f := range args.LABELS {
parts := strings.Split(f, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(labels, "labels")
_, err := modules.Nodes.PerformAction(s, args.ID, "add-labels", params)
if err != nil {
return err
}
return nil
})
/**
* 批量新增标签
*/
type NodeLabelsBatchOptions struct {
NAMES []string `help:"Node names"`
Labels []string `help:"Node labels" nargs:"+"`
}
R(&NodeLabelsBatchOptions{}, "batch-add-labels-to-node", "Batch add labels to nodes", func(s *mcclient.ClientSession, args *NodeLabelsBatchOptions) error {
nodes := jsonutils.NewArray()
labels := jsonutils.NewDict()
for _, n := range args.NAMES {
nodes.Add(jsonutils.NewString(n))
}
for _, l := range args.Labels {
parts := strings.Split(l, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(nodes, "nodes")
params.Add(labels, "labels")
ret := modules.Nodes.BatchPerformActionInContexts(s, args.NAMES, "add-labels", params, nil)
printBatchResults(ret, modules.Nodes.GetColumns(s))
return nil
})
/**
* 移除标签
*/
type NodeLabelRemoveOptions struct {
ID string `help:"ID of node"`
LABELS []string `help:"Node labels"`
}
R(&NodeLabelRemoveOptions{}, "remove-labels-from-node", "Remove labels from node", func(s *mcclient.ClientSession, args *NodeLabelRemoveOptions) error {
labels := jsonutils.NewDict()
for _, f := range args.LABELS {
parts := strings.Split(f, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(labels, "labels")
_, err := modules.Nodes.PerformAction(s, args.ID, "remove-labels", params)
if err != nil {
return err
}
return nil
})
/**
* 批量移除标签
*/
R(&NodeLabelsBatchOptions{}, "batch-remove-labels-from-node", "Batch remove labels from nodes", func(s *mcclient.ClientSession, args *NodeLabelsBatchOptions) error {
nodes := jsonutils.NewArray()
labels := jsonutils.NewDict()
for _, n := range args.NAMES {
nodes.Add(jsonutils.NewString(n))
}
for _, l := range args.Labels {
parts := strings.Split(l, "=")
labels.Add(jsonutils.NewString(parts[1]), parts[0])
}
params := jsonutils.NewDict()
params.Add(nodes, "nodes")
params.Add(labels, "labels")
ret := modules.Nodes.BatchPerformActionInContexts(s, args.NAMES, "remove-labels", params, nil)
printBatchResults(ret, modules.Nodes.GetColumns(s))
return nil
})
type NodeCreateOptions struct {
NAME string `help:"Node name"`
IP string `help:"Node IP"`
ResType string `help:"Resource type" choices:"host|guest"`
}
R(&NodeCreateOptions{}, "node-create", "Create a monitor node record", func(s *mcclient.ClientSession, args *NodeCreateOptions) error {
data, err := modules.Nodes.NewNode(s, args.NAME, args.IP, args.ResType)
if err != nil {
return err
}
printObject(data)
return nil
})
}
@@ -1,39 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
)
func init() {
type Top5Options struct {
NODE_LABELS string `help:"Service tree tree-node labels"`
}
R(&Top5Options{}, "performance-top5", "Show performance top5", func(s *mcclient.ClientSession, args *Top5Options) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NODE_LABELS), "node_labels")
result, err := modules.Performances.GetTop5(s, params)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,53 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出所有监控指标
*/
type ProjectAdminListOptions struct {
options.BaseListOptions
}
R(&ProjectAdminListOptions{}, "projectadmin-list", "List all Project Admins", func(s *mcclient.ClientSession, args *ProjectAdminListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.ProjectAdmin.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProjectAdmin.GetColumns(s))
return nil
})
}
@@ -1,53 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出所有监控指标
*/
type ProjectAdminCandidateListOptions struct {
options.BaseListOptions
}
R(&ProjectAdminCandidateListOptions{}, "projectadmincandidate-list", "List all Project Admin Candidates", func(s *mcclient.ClientSession, args *ProjectAdminCandidateListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.ProjectAdminCandidate.List(s, params)
if err != nil {
return err
}
printList(result, modules.ProjectAdminCandidate.GetColumns(s))
return nil
})
}
@@ -1,55 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
)
func init() {
/**
* move host to one tree-node
*/
type ProjectHostCreateOptions struct {
LABELS string `help:"Labels for tree-node(split by comma)"`
HOST_NAME []string `help:"Host names to move to"`
}
R(&ProjectHostCreateOptions{}, "projecthost-create", "move host to tree-node", func(s *mcclient.ClientSession, args *ProjectHostCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
arr := jsonutils.NewArray()
if len(args.HOST_NAME) > 0 {
for _, f := range args.HOST_NAME {
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(f), "host_name")
arr.Add(tmpObj)
}
}
params.Add(arr, "service_hosts")
rst, err := modules.ProjectHosts.Create(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
}
-119
View File
@@ -1,119 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 向服务树节点添加报警接收人
*/
type TreeNodeRecipientsCreateOptions struct {
NODE_LABELS string `help:"Labels for tree-node(split by comma)"`
USER_TYPE string `help:"User type, user|group "`
RECIPIENT_ID string `help:"User id or group id"`
RECIPIENT_TYPE string `help:"junior(slight) or senior(serious)"`
}
R(&TreeNodeRecipientsCreateOptions{}, "treenode-recipient-create", "Add recipients to tree-node", func(s *mcclient.ClientSession, args *TreeNodeRecipientsCreateOptions) error {
arr := jsonutils.NewArray()
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(args.RECIPIENT_ID), "recipient_id")
tmpObj.Add(jsonutils.NewString(args.USER_TYPE), "type")
arr.Add(tmpObj)
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NODE_LABELS), "node_labels")
params.Add(jsonutils.NewString(args.RECIPIENT_TYPE), "recipient_type")
params.Add(arr, "recipients")
rst, err := modules.Recipients.Create(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
/**
* 从服务树节点移除报警接收人
*/
type TreeNodeRecipientsDeleteOptions struct {
NODE_LABELS string `help:"Labels for tree-node(split by comma)"`
USER_TYPE string `help:"User type, user|group "`
RECIPIENT_ID string `help:"User id or group id"`
RECIPIENT_TYPE string `help:"junior(slight) or senior(serious)"`
}
R(&TreeNodeRecipientsDeleteOptions{}, "treenode-recipient-delete", "Remove recipients from tree-node", func(s *mcclient.ClientSession, args *TreeNodeRecipientsDeleteOptions) error {
arr := jsonutils.NewArray()
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(args.RECIPIENT_ID), "recipient_id")
tmpObj.Add(jsonutils.NewString(args.RECIPIENT_TYPE), "recipient_type")
tmpObj.Add(jsonutils.NewString(args.USER_TYPE), "type")
arr.Add(tmpObj)
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NODE_LABELS), "node_labels")
params.Add(arr, "recipients")
rst, err := modules.Recipients.DoDeleteRecipient(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
/**
* 查询树节点的报警接收人信息
*/
type TreeNodeRecipientsListOptions struct {
options.BaseListOptions
LIST_TYPE string `help:"Type of list: junior|senior"`
LABELS string `help:"Labels for tree-node(split by comma)"`
}
R(&TreeNodeRecipientsListOptions{}, "treenode-recipient-list", "List recipient for the tree-node ", func(s *mcclient.ClientSession, args *TreeNodeRecipientsListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
params.Add(jsonutils.NewString(args.LIST_TYPE), "type")
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
result, err := modules.Recipients.List(s, params)
if err != nil {
return err
}
printList(result, modules.Recipients.GetColumns(s))
return nil
})
}
@@ -1,117 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 向指定的服务树节点添加机器
*/
type ServiceHostCreateOptions struct {
LABELS string `help:"Labels for tree-node(split by comma)"`
HOST_NAME []string `help:"Host names to add to"`
}
R(&ServiceHostCreateOptions{}, "servicehost-create", "Add host to tree-node", func(s *mcclient.ClientSession, args *ServiceHostCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
arr := jsonutils.NewArray()
if len(args.HOST_NAME) > 0 {
for _, f := range args.HOST_NAME {
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(f), "host_name")
arr.Add(tmpObj)
}
}
params.Add(arr, "service_hosts")
rst, err := modules.ServiceHosts.Create(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
/**
* 从服务树节点删除机器
*/
type ServiceHostDeleteOptions struct {
LABELS string `help:"Labels for tree-node(split by comma)"`
HOST_NAME []string `help:"Host names to remove from"`
}
R(&ServiceHostDeleteOptions{}, "servicehost-delete", "Remove host from tree-node", func(s *mcclient.ClientSession, args *ServiceHostDeleteOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.LABELS), "node_labels")
arr := jsonutils.NewArray()
if len(args.HOST_NAME) > 0 {
for _, f := range args.HOST_NAME {
tmpObj := jsonutils.NewDict()
tmpObj.Add(jsonutils.NewString(f), "host_name")
arr.Add(tmpObj)
}
}
params.Add(arr, "service_hosts")
rst, err := modules.ServiceHosts.DoDeleteServiceHost(s, params)
if err != nil {
return err
}
printObject(rst)
return nil
})
/**
* 查看指定服务树节点的机器
*/
type ServiceHostListOptions struct {
options.BaseListOptions
Labels string `help:"Labels for tree-node(split by comma)"`
}
R(&ServiceHostListOptions{}, "servicehost-list", "List all hosts for the tree-node", func(s *mcclient.ClientSession, args *ServiceHostListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
if len(args.Labels) > 0 {
params.Add(jsonutils.NewString(args.Labels), "node_labels")
}
result, err := modules.ServiceHosts.List(s, params)
if err != nil {
return err
}
printList(result, modules.ServiceHosts.GetColumns(s))
return nil
})
}
@@ -1,53 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 列出所有监控指标
*/
type ServiceNameSuggestionListOptions struct {
options.BaseListOptions
}
R(&ServiceNameSuggestionListOptions{}, "servicenamesuggestion-list", "List all serviceNameSuggestion", func(s *mcclient.ClientSession, args *ServiceNameSuggestionListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.ServiceNameSuggestion.List(s, params)
if err != nil {
return err
}
printList(result, modules.ServiceNameSuggestion.GetColumns(s))
return nil
})
}
-133
View File
@@ -1,133 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建新的服务树
*/
type ServiceTreeCreateOptions struct {
NAME string `help:"Name of the new service tree"`
STRUCT string `help:"Struct of the service tree"`
Remark string `help:"Remark or description of the new service tree"`
}
R(&ServiceTreeCreateOptions{}, "servicetree-create", "Create a service tree", func(s *mcclient.ClientSession, args *ServiceTreeCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "service_tree_name")
params.Add(jsonutils.NewString(args.STRUCT), "service_tree_struct")
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
serviceTree, err := modules.ServiceTrees.Create(s, params)
if err != nil {
return err
}
printObject(serviceTree)
return nil
})
/**
* 删除一个服务树
*/
type ServiceTreeDeleteOptions struct {
ID string `help:"ID of alarm template"`
}
R(&ServiceTreeDeleteOptions{}, "servicetree-delete", "Delete a service tree", func(s *mcclient.ClientSession, args *ServiceTreeDeleteOptions) error {
serviceTree, e := modules.ServiceTrees.Delete(s, args.ID, nil)
if e != nil {
return e
}
printObject(serviceTree)
return nil
})
/**
* 修改服务树的配置信息
*/
type ServiceTreeUpdateOptions struct {
ID string `help:"ID of the service tree"`
Name string `help:"Name of the service-tree"`
Struct string `help:"Struct of the service-tree"`
Remark string `help:"Remark or description of the service-tree"`
}
R(&ServiceTreeUpdateOptions{}, "servicetree-update", "Update a service tree", func(s *mcclient.ClientSession, args *ServiceTreeUpdateOptions) error {
params := jsonutils.NewDict()
if len(args.Name) > 0 {
params.Add(jsonutils.NewString(args.Name), "service_tree_name")
}
if len(args.Struct) > 0 {
params.Add(jsonutils.NewString(args.Struct), "service_tree_struct")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
serviceTree, err := modules.ServiceTrees.Patch(s, args.ID, params)
if err != nil {
return err
}
printObject(serviceTree)
return nil
})
/**
* 列出服务树
*/
type ServiceTreeListOptions struct {
options.BaseListOptions
}
R(&ServiceTreeListOptions{}, "servicetree-list", "List all service tree", func(s *mcclient.ClientSession, args *ServiceTreeListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.ServiceTrees.List(s, params)
if err != nil {
return err
}
printList(result, modules.ServiceTrees.GetColumns(s))
return nil
})
/**
* 查看服务树配置详情
*/
type ServiceTreeShowOptions struct {
ID string `help:"ID of the service-tree"`
}
R(&ServiceTreeShowOptions{}, "servicetree-show", "Show service tree details", func(s *mcclient.ClientSession, args *ServiceTreeShowOptions) error {
result, err := modules.ServiceTrees.Get(s, args.ID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
-219
View File
@@ -1,219 +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 servicetree
import (
"fmt"
"strconv"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/identity"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
/**
* 创建新的服务树节点
*/
type ServiceTreeCreateOptions struct {
NAME string `help:"Name of the new service-tree node"`
Pid int64 `help:"PID of the service-tree node" default:"-1"`
Label []string `help:"Labels to this node"`
Project string `help:"Project id of the if create PDL node"`
Remark string `help:"Remark or description of the new service-tree node"`
}
R(&ServiceTreeCreateOptions{}, "servicetree-node-create", "Create a service-tree node", func(s *mcclient.ClientSession, args *ServiceTreeCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "name")
pid := args.Pid
var err error
if pid < 0 {
if len(args.Label) <= 0 {
return fmt.Errorf("Must provide either pid or labels")
}
pid, err = modules.TreeNodes.GetNodeIDByLabels(s, args.Label)
if err != nil {
return err
}
if pid < 0 {
return fmt.Errorf("Invalid labels: %s", args.Label)
}
}
params.Add(jsonutils.NewInt(pid), "pid")
if len(args.Project) > 0 {
projId, err := identity.Projects.GetId(s, args.Project, nil)
if err != nil {
return err
}
params.Add(jsonutils.NewString(projId), "project_id")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
serviceTree, err := modules.TreeNodes.Create(s, params)
if err != nil {
return err
}
printObject(serviceTree)
return nil
})
type ServiceTreeNodeListOptions struct {
options.BaseListOptions
Label string `help:"Label of node"`
Pid int64 `help:"Pid of node" default:"-1"`
}
R(&ServiceTreeNodeListOptions{}, "servicetree-node-list", "List servicetree nodes", func(s *mcclient.ClientSession, args *ServiceTreeNodeListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
if args.Pid >= 0 {
params.Add(jsonutils.NewInt(args.Pid), "pid")
}
if len(args.Label) > 0 {
params.Add(jsonutils.NewString(args.Label), "name")
}
result, err := modules.TreeNodes.List(s, params)
if err != nil {
return err
}
printList(result, modules.TreeNodes.GetColumns(s))
return nil
})
/**
* 查看服务树节点配置详情
*/
type ServiceTreeNodeShowOptions struct {
Id int64 `help:"ID of tree node"`
Label []string `help:"Labels to this tree node"`
}
R(&ServiceTreeNodeShowOptions{}, "servicetree-node-show", "Show details of a servicetree node", func(s *mcclient.ClientSession, args *ServiceTreeNodeShowOptions) error {
pid := args.Id
var err error
if pid <= 0 {
pid, err = modules.TreeNodes.GetNodeIDByLabels(s, args.Label)
if err != nil {
return err
}
if pid <= 0 {
return fmt.Errorf("Invalid tree node ID")
}
}
idstr := strconv.Itoa(int(pid))
result, err := modules.TreeNodes.Get(s, idstr, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 修改服务树节点配置信息
*/
type ServiceTreeNodeUpdateOptions struct {
ServiceTreeNodeShowOptions
Name string `help:"Name of the service-tree"`
Project string `help:"Project associate with this tree node"`
Remark string `help:"Remark or description of the service-tree"`
}
R(&ServiceTreeNodeUpdateOptions{}, "servicetree-node-update", "Update a servicetree node", func(s *mcclient.ClientSession, args *ServiceTreeNodeUpdateOptions) error {
pid := args.Id
var err error
if pid <= 0 {
pid, err = modules.TreeNodes.GetNodeIDByLabels(s, args.Label)
if err != nil {
return err
}
if pid <= 0 {
return fmt.Errorf("Invalid tree node ID")
}
}
idstr := strconv.Itoa(int(pid))
params := jsonutils.NewDict()
if len(args.Name) > 0 {
params.Add(jsonutils.NewString(args.Name), "name")
}
if len(args.Project) > 0 {
projId, err := identity.Projects.GetId(s, args.Project, nil)
if err != nil {
return err
}
params.Add(jsonutils.NewString(projId), "project_id")
}
if len(args.Remark) > 0 {
params.Add(jsonutils.NewString(args.Remark), "remark")
}
result, err := modules.TreeNodes.Update(s, idstr, params)
if err != nil {
return err
}
printObject(result)
return nil
})
/**
* 修改服务树节点的项目类型
*/
type ServiceTreeNodeChangeProjectTypeOptions struct {
PROJECTID string `help:"ID of project"`
PROJECTTYPE string `help:"TYPE of project" choices:"CreateNewProject|RelatedExisting"`
}
R(&ServiceTreeNodeChangeProjectTypeOptions{}, "servicetree-node-change-project-type", "servicetree-node-change-project-type", func(s *mcclient.ClientSession, args *ServiceTreeNodeChangeProjectTypeOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.PROJECTTYPE), "project_type")
_, err := modules.TreeNodes.PerformAction(s, args.PROJECTID, "change-project-type", params)
if err != nil {
return err
}
return nil
})
/**
* 删除一个服务树节点
*/
R(&ServiceTreeNodeShowOptions{}, "servicetree-node-delete", "Delete a servicetree node", func(s *mcclient.ClientSession, args *ServiceTreeNodeShowOptions) error {
pid := args.Id
var err error
if pid <= 0 {
pid, err = modules.TreeNodes.GetNodeIDByLabels(s, args.Label)
if err != nil {
return err
}
if pid <= 0 {
return fmt.Errorf("Invalid tree node ID")
}
}
idstr := strconv.Itoa(int(pid))
result, err := modules.TreeNodes.Delete(s, idstr, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
@@ -1,49 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/cloudwatcher"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type UnderutilizedInstancesListOptions struct {
options.BaseListOptions
}
R(&UnderutilizedInstancesListOptions{}, "underutilized-instances-list", "List underutilized instances", func(s *mcclient.ClientSession, args *UnderutilizedInstancesListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.UnderutilizedInstances.List(s, params)
if err != nil {
return err
}
printList(result, modules.UnderutilizedInstances.GetColumns(s))
return nil
})
}
@@ -1,26 +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 suggestion
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/suggestion"
options "yunion.io/x/onecloud/pkg/mcclient/options/suggestion"
)
func init() {
cmd := shell.NewResourceCmd(modules.AnalysisPredictManager)
cmd.Get("", new(options.AnalysisPredictConfigOptions))
}
@@ -1,31 +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 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))
cmd.BatchDelete(new(options.SuggestAlertBatchDeleteOptions))
cmd_ := shell.NewResourceCmd(monitor.SuggestSysAlertCostManager)
cmd_.Get("", new(options.SuggestAlertCostOptions))
}
@@ -1,33 +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 suggestion
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/suggestion"
options "yunion.io/x/onecloud/pkg/mcclient/options/monitor"
)
func init() {
cmd := shell.NewResourceCmd(modules.SuggestSysRuleManager)
cmd.List(new(options.SuggestRuleListOptions))
cmd.Show(new(options.SuggestRuleShowOptions))
cmd.Perform("enable", new(options.SuggestRuleShowOptions))
cmd.Perform("disable", new(options.SuggestRuleShowOptions))
cmd.BatchDelete(new(options.CommonAlertDeleteOptions))
cmd.Perform("config", new(options.SuggestRuleConfigOptions))
}
-28
View File
@@ -40,7 +40,6 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/modules/identity"
"yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
"yunion.io/x/onecloud/pkg/util/httputils"
)
@@ -95,7 +94,6 @@ func (h *MiscHandler) Bind(app *appsrv.Application) {
uploader := UploadHandlerInfo(POST, prefix+"uploads", FetchAuthToken(h.PostUploads))
app.AddHandler3(uploader)
app.AddHandler(GET, prefix+"downloads/<template_id>", FetchAuthToken(h.getDownloadsHandler))
app.AddHandler(POST, prefix+"piuploads", FetchAuthToken(h.postPIUploads)) // itsm process instances upload api
// download vm image by url (no auth token required). token 有效期24小时
imageDownloadByUrl := uploadHandlerInfo(GET, prefix+"imageutils/image/<image_name>", imageDownloadByUrlHandler)
app.AddHandler3(imageDownloadByUrl)
@@ -498,32 +496,6 @@ func (mh *MiscHandler) getDownloadsHandler(ctx context.Context, w http.ResponseW
return
}
func (mh *MiscHandler) postPIUploads(ctx context.Context, w http.ResponseWriter, req *http.Request) {
// 5 MB
var maxMemory int64 = 5 << 20
if req.ContentLength > maxMemory {
httperrors.InvalidInputError(ctx, w, "request body is too large.")
return
}
if !strings.Contains(req.Header.Get("Content-Type"), "multipart/form-data") {
httperrors.InvalidInputError(ctx, w, "invalid multipart form")
return
}
s := FetchSession(ctx, req, "")
header := http.Header{}
header.Set("Content-Type", req.Header.Get("Content-Type"))
header.Set("Content-Length", req.Header.Get("Content-Length"))
resp, err := itsm.ProcessInstance.Upload(s, header, req.Body)
if err != nil {
httperrors.GeneralServerError(ctx, w, err)
return
}
appsrv.SendJSON(w, resp)
}
func (mh *MiscHandler) postS3UploadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
reader, e := r.MultipartReader()
if e != nil {
+2
View File
@@ -110,6 +110,8 @@ var (
"global_http_proxy",
"global_https_proxy",
"ignore_nonrunning_guests",
"platform_name",
"platform_names",
},
}
+13
View File
@@ -27,6 +27,7 @@ import (
"path/filepath"
"golang.org/x/net/http/httpproxy"
"golang.org/x/text/language"
"yunion.io/x/log"
"yunion.io/x/log/hooks"
@@ -104,6 +105,9 @@ type BaseOptions struct {
GlobalHTTPSProxy string `help:"Global https proxy"`
IgnoreNonrunningGuests bool `default:"true" help:"Count memory for running guests only when do scheduling. Ignore memory allocation for non-running guests"`
PlatformName string `help:"identity name of this platform" default:"Cloudpods"`
PlatformNames map[string]string `help:"identity name of this platform by language"`
}
const (
@@ -335,3 +339,12 @@ func (self *BaseOptions) HttpTransportProxyFunc() httputils.TransportProxyFunc {
return proxyFunc(req.URL)
}
}
func (opt *BaseOptions) GetPlatformName(lang language.Tag) string {
if len(opt.PlatformNames) > 0 {
if name, ok := opt.PlatformNames[lang.String()]; ok {
return name
}
}
return opt.PlatformName
}
+14 -17
View File
@@ -19,7 +19,6 @@ import (
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
@@ -28,8 +27,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modules/websocket"
"yunion.io/x/onecloud/pkg/util/logclient"
)
@@ -198,20 +195,20 @@ func (man *SActionlogManager) GetI18N(ctx context.Context, idstr string, resObj
// }
// }
// }
func StartNotifyToWebsocketWorker() {
go func() {
for {
actionLog := <-logQueue
params := jsonutils.Marshal(actionLog)
s := auth.GetAdminSession(context.Background(), "", "")
_, err := websocket.Websockets.PerformClassAction(s, "action-log", params)
if err != nil {
log.Errorf("Send action log error %s", err)
}
}
}()
}
//
// func StartNotifyToWebsocketWorker() {
// go func() {
// for {
// actionLog := <-logQueue
// params := jsonutils.Marshal(actionLog)
// s := auth.GetAdminSession(context.Background(), "", "")
// _, err := websocket.Websockets.PerformClassAction(s, "action-log", params)
// if err != nil {
// log.Errorf("Send action log error %s", err)
// }
// }
// }()
// }
func (manager *SActionlogManager) InitializeData() error {
fileds, err := db.DistinctFieldManager.GetObjectDistinctFields(manager.Keyword())
+1 -1
View File
@@ -52,7 +52,7 @@ func StartService() {
db.EnsureAppInitSyncDB(app, dbOpts, models.InitDB)
defer cloudcommon.CloseDB()
models.StartNotifyToWebsocketWorker()
// models.StartNotifyToWebsocketWorker()
app_common.ServeForever(app, baseOpts)
}
-1
View File
@@ -1 +0,0 @@
package autoupdate // import "yunion.io/x/onecloud/pkg/mcclient/modules/autoupdate"
@@ -1,48 +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 autoupdate
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type SUpdateManager struct {
modulebase.ResourceManager
}
var (
Updates SUpdateManager
)
func (this *SUpdateManager) DoUpdate(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
ret := jsonutils.NewDict()
this.PerformAction(s, "", "", params)
return ret, nil
}
func init() {
Updates = SUpdateManager{modules.NewAutoUpdateManager("update", "updates",
// user view
[]string{"localVersion", "remoteVersion", "status", "updateAvailable"},
[]string{}, // admin view
)}
modules.Register(&Updates)
}
-1
View File
@@ -1 +0,0 @@
package cloudwatcher // import "yunion.io/x/onecloud/pkg/mcclient/modules/cloudwatcher"
@@ -1,32 +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 cloudwatcher
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
UnderutilizedInstances modulebase.ResourceManager
)
func init() {
UnderutilizedInstances = modules.NewCloudwatcherManager("underutilizedinstance", "underutilizedinstances",
[]string{"id", "vm_id", "vm_name", "datetime_str", "vm_cpu", "vm_disk", "vm_memory", "vm_provider", "cpu_usage_threshold", "netio_rx_bps_threshold", "netio_tx_bps_threshold", "stastics_details"},
[]string{})
modules.Register(&UnderutilizedInstances)
}
-1
View File
@@ -1 +0,0 @@
package itsm // import "yunion.io/x/onecloud/pkg/mcclient/modules/itsm"
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Instances modulebase.ResourceManager
)
func init() {
Instances = modules.NewITSMManager("instance", "instances",
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "apply_date", "instance_id", "business_id", "procdef_key", "busi_type", "apply_unit", "client_info", "emergency", "impact", "title", "content", "start_time", "end_time", "starter", "starter_name", "instance_status", "current_approver", "approver_name", "task_name", "task_type", "task_id", "result", "login_name", "common_start_string"},
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "apply_date", "instance_id", "business_id", "procdef_key", "busi_type", "apply_unit", "client_info", "emergency", "impact", "title", "content", "start_time", "end_time", "starter", "starter_name", "instance_status", "current_approver", "approver_name", "task_name", "task_type", "task_id", "result", "login_name", "common_start_string"},
)
modules.Register(&Instances)
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ProcessDeployments modulebase.ResourceManager
)
func init() {
ProcessDeployments = modules.NewITSMManager("process-deployment", "process-deployments",
[]string{"id", "name", "source", "deployment_time", "tenant_id"},
[]string{},
)
modules.Register(&ProcessDeployments)
}
@@ -1,60 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ExtraUsers modulebase.ResourceManager
ExtraProcessDefinition modulebase.ResourceManager
ExtraProcessInstance modulebase.ResourceManager
ExtraJira modulebase.ResourceManager
)
func init() {
ExtraUsers = modules.NewITSMManager("extra-user", "extra-users",
[]string{},
[]string{},
)
ExtraProcessDefinition = modules.NewITSMManager("extra-process-definition", "extra-process-definitions",
[]string{},
[]string{},
)
ExtraProcessInstance = modules.NewITSMManager("extra-process-instance", "extra-process-instances",
[]string{},
[]string{},
)
ExtraJira = modules.NewITSMManager("extra-jira", "extra-jiras",
[]string{},
[]string{},
)
mods := []modulebase.ResourceManager{
ExtraJira,
ExtraUsers,
ExtraProcessDefinition,
ExtraProcessInstance,
}
for i := range mods {
modules.Register(&mods[i])
modules.RegisterV2(&mods[i])
}
}
@@ -1,84 +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 itsm
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type HiProcInstManager struct {
modulebase.ResourceManager
}
func (this *HiProcInstManager) GetStatistics(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
userId, _ := params.GetString("user_id")
hiProcInstPath := fmt.Sprintf("/historic-process-instances?status=unfinished&user_id=%s", userId)
procTaskPath := fmt.Sprintf("/process-tasks?user_id=%s", userId)
hiProcInstObj, err := modulebase.List(this.ResourceManager, s, hiProcInstPath, "historic-process-instances")
if err != nil {
return nil, err
}
procTaskObj, err := modulebase.List(this.ResourceManager, s, procTaskPath, "process-tasks")
if err != nil {
return nil, err
}
nrHiProcInst := hiProcInstObj.Total
nrProcTask := procTaskObj.Total
hiProcInstCusPath := fmt.Sprintf("%s&process_definition_key=customer-service", hiProcInstPath)
procTaskCusPath := fmt.Sprintf("%s&process_definition_key=customer-service", procTaskPath)
hiProcInstCusObj, err := modulebase.List(this.ResourceManager, s, hiProcInstCusPath, "historic-process-instances")
if err != nil {
return nil, err
}
procTaskCusObj, err := modulebase.List(this.ResourceManager, s, procTaskCusPath, "process-tasks")
if err != nil {
return nil, err
}
hiProcInstCusTotal := hiProcInstCusObj.Total
procTaskCusTotal := procTaskCusObj.Total
rst := jsonutils.NewDict()
rst.Add(jsonutils.NewInt(int64(nrHiProcInst-hiProcInstCusTotal)), "nr-historic-process-instance")
rst.Add(jsonutils.NewInt(int64(nrProcTask-procTaskCusTotal)), "nr-process-task")
rst.Add(jsonutils.NewInt(int64(hiProcInstCusTotal)), "nr-historic-process-instance-cus")
rst.Add(jsonutils.NewInt(int64(procTaskCusTotal)), "nr-process-task-cus")
return rst, nil
}
var (
HistoricProcessInstance HiProcInstManager
)
func init() {
HistoricProcessInstance = HiProcInstManager{modules.NewITSMManager("historic-process-instance", "historic-process-instances",
[]string{"id", "process_definition_key", "start_activity_id", "end_time", "duration_in_millis", "removal_time", "business_key", "end_activity_id", "process_definition_version", "delete_reason", "process_definition_id", "start_time", "start_user_id", "case_instance_id", "root_process_instance_id", "super_case_instance_id", "state", "process_definition_name", "super_process_instance_id", "tenant_id"},
[]string{})}
modules.Register(&HistoricProcessInstance)
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
HistoricTaskInstances modulebase.ResourceManager
)
func init() {
HistoricTaskInstances = modules.NewITSMManager("historic-task-instance", "historic-task-instances",
[]string{"id", "name", "parent_task_id", "duration_in_millis", "description", "case_execution_id", "removal_time", "delete_reason", "follow_up_date", "execution_id", "activity_instance_id", "root_process_instance_id", "owner", "process_definition_key", "end_time", "due_date", "super_case_instance_id", "priority", "process_definition_id", "start_time", "case_definition_key", "case_instance_id", "process_instance_id", "case_definition_id", "assignee", "task_definition_key"},
[]string{},
)
modules.Register(&HistoricTaskInstances)
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ProcessDefinitions modulebase.ResourceManager
)
func init() {
ProcessDefinitions = modules.NewITSMManager("process-definition", "process-definitions",
[]string{"id", "name", "key", "description", "resource_name", "diagram_resource_name", "deployment_id", "startable_in_tasklist", "category", "suspended", "start_form_key", "history_time_to_live", "version", "version_tag", "tenant_id"},
[]string{},
)
modules.Register(&ProcessDefinitions)
}
@@ -1,53 +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 itsm
import (
"fmt"
"io"
"net/http"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type ProcessInstanceManager struct {
modulebase.ResourceManager
}
var (
ProcessInstance ProcessInstanceManager
)
func (self *ProcessInstanceManager) Upload(s *mcclient.ClientSession, header http.Header, body io.Reader) (jsonutils.JSONObject, error) {
path := fmt.Sprintf("/%s", self.URLPath())
resp, err := modulebase.RawRequest(self.ResourceManager, s, "POST", path, header, body)
_, json, err := s.ParseJSONResponse("", resp, err)
if err != nil {
return nil, err
}
return json.Get(self.Keyword)
}
func init() {
ProcessInstance = ProcessInstanceManager{modules.NewITSMManager("process-instance", "process-instances",
[]string{"id", "process_instance_id", "root_process_instance_id", "case_instance_id", "business_key", "ended", "suspended", "tenant_id"},
[]string{},
)}
modules.Register(&ProcessInstance)
}
@@ -1,54 +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 itsm
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type SProcessTasksManager struct {
modulebase.ResourceManager
}
var (
ProcessTasks SProcessTasksManager
)
func init() {
ProcessTasks = SProcessTasksManager{modules.NewITSMManager("process-task", "process-tasks",
[]string{"id", "name", "description", "owner", "priority", "tenant_id"},
[]string{},
)}
modules.Register(&ProcessTasks)
}
func (this *SProcessTasksManager) QuickComplete(s *mcclient.ClientSession, params jsonutils.JSONObject) error {
path := fmt.Sprintf("/%s/quick-complete", this.KeywordPlural)
if params != nil {
qs := params.QueryString()
if len(qs) > 0 {
path = fmt.Sprintf("%s?%s", path, qs)
}
}
_, err := modulebase.Get(this.ResourceManager, s, path, "")
return err
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Operations modulebase.ResourceManager
)
func init() {
Operations = modules.NewITSMManager("operation", "operations",
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "operate_type", "template_id", "device_code", "ip_address", "cpu", "memery", "disk", "resource_sum", "network", "schedule", "login_name", "display_name", "resource_ids", "instance", "task", "log_list", "common_start_string"},
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "operate_type", "template_id", "device_code", "ip_address", "cpu", "memery", "disk", "resource_sum", "network", "schedule", "login_name", "display_name", "resource_ids", "instance", "task", "log_list", "common_start_string"},
)
modules.Register(&Operations)
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Processes modulebase.ResourceManager
)
func init() {
Processes = modules.NewITSMManager("process", "processes",
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "deploy_id", "deploy_category", "deploy_name", "deploy_time", "procdef_id", "procdef_name", "procdef_key", "procdef_version", "resource_name", "diagram_resource_name", "icon_name", "style_text", "shiro_name", "common_form", "start_form", "show_flag", "common_start_string"},
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "deploy_id", "deploy_category", "deploy_name", "deploy_time", "procdef_id", "procdef_name", "procdef_key", "procdef_version", "resource_name", "diagram_resource_name", "icon_name", "style_text", "shiro_name", "common_form", "start_form", "show_flag", "common_start_string"},
)
modules.Register(&Processes)
}
@@ -1,32 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Processlogs modulebase.ResourceManager
)
func init() {
Processlogs = modules.NewITSMManager("processlog", "processlogs",
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "receive_time", "task_receiver", "task_operator", "task_status", "task_name", "task_type", "task_id", "handle_time", "operate_result", "operate_advice", "log_order", "common_start_string"},
[]string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "receive_time", "task_receiver", "task_operator", "task_status", "task_name", "task_type", "task_id", "handle_time", "operate_result", "operate_advice", "log_order", "common_start_string"},
)
modules.Register(&Processlogs)
}
-28
View File
@@ -1,28 +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 itsm
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var Tasks modulebase.ResourceManager
func init() {
cols := []string{"id", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark", "instance_id", "business_id", "task_id", "task_type", "task_name", "task_status", "current_approver", "approver_name", "receive_time", "finish_time", "result", "content", "common_start_string"}
Tasks = modules.NewITSMManager("task", "taskman", cols, cols)
modules.Register(&Tasks)
}
+1
View File
@@ -0,0 +1 @@
package quota // import "yunion.io/x/onecloud/pkg/mcclient/modules/quota"
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
package quota
import (
"fmt"
-1
View File
@@ -1 +0,0 @@
package servicetree // import "yunion.io/x/onecloud/pkg/mcclient/modules/servicetree"
@@ -1,45 +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 servicetree
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type AlarmEventsManager struct {
modulebase.ResourceManager
}
func (this *AlarmEventsManager) DoBatchUpdate(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
path := "/alarm_events"
return modulebase.Put(this.ResourceManager, s, path, params, "alarm_events")
}
var (
AlarmEvents AlarmEventsManager
)
func init() {
AlarmEvents = AlarmEventsManager{modules.NewServiceTreeManager("alarm_event", "alarm_events",
[]string{"ID", "metric_name", "host_name", "host_ip", "alarm_condition", "template", "first_alarm_time", "last_alarm_time", "alarm_status", "alarm_times", "ack_time", "ack_status", "ack_wait_time", "upgrade_time", "upgrade_status", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})}
modules.Register(&AlarmEvents)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
AlarmLogs modulebase.ResourceManager
)
func init() {
AlarmLogs = modules.NewServiceTreeManager("alarm_log", "alarm_logs",
[]string{"ID", "node_name", "metric_name", "labels", "start_time", "this_time", "alarm_ways", "alarm_level", "alarm_status", "receive_person", "alarm_release_time", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&AlarmLogs)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Alarms modulebase.ResourceManager
)
func init() {
Alarms = modules.NewServiceTreeManager("alarm", "alarms",
[]string{"id", "metric_name", "unit", "common_unit", "alarm_condition", "template", "alarm_level", "contact_type", "expire_seconds", "escalate_seconds", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&Alarms)
}
@@ -1,36 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
AlarmTemplateAlarms modulebase.JointResourceManager
)
func init() {
AlarmTemplateAlarms = modules.NewJointServiceTreeManager(
"alarmtemplate_alarm",
"alarmtemplate_alarms",
[]string{"id", "alarm_template_name", "alarm_template_desc", "belongto", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{},
&AlarmTemplates,
&Alarms)
modules.Register(&AlarmTemplateAlarms)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
AlarmTemplates modulebase.ResourceManager
)
func init() {
AlarmTemplates = modules.NewServiceTreeManager("alarm_template", "alarm_templates",
[]string{"id", "alarm_template_name", "alarm_template_desc", "belongto", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&AlarmTemplates)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Labels modulebase.ResourceManager
)
func init() {
Labels = modules.NewServiceTreeManager("label", "labels",
[]string{"ID", "label_name", "label_value", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&Labels)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
Metrics modulebase.ResourceManager
)
func init() {
Metrics = modules.NewServiceTreeManager("metric", "metrics",
[]string{"id", "name", "description", "unit", "common_unit", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&Metrics)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
MetricsTypes modulebase.ResourceManager
)
func init() {
MetricsTypes = modules.NewServiceTreeManager("metric_type", "metric_types",
[]string{"id", "name", "description", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&MetricsTypes)
}
@@ -1,36 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type MonitorMetricManager struct {
modulebase.ResourceManager
}
var (
MonitorMetrics MonitorMetricManager
)
func init() {
MonitorMetrics = MonitorMetricManager{modules.NewServiceTreeManager("monitor_metric", "monitor_metrics",
[]string{"id", "node_labels", "monitor_metrics", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "project_id", "remark"},
[]string{})}
modules.Register(&MonitorMetrics)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
MonitorInputs modulebase.ResourceManager
)
func init() {
MonitorInputs = modules.NewServiceTreeManager("monitor_input", "monitor_inputs",
[]string{"ID", "monitor_name", "monitor_parameters", "sample", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&MonitorInputs)
}
@@ -1,43 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
MonitorTemplates modulebase.ResourceManager
MonitorTemplateInputs modulebase.JointResourceManager
)
func init() {
MonitorTemplates = modules.NewServiceTreeManager("monitor_template", "monitor_templates",
[]string{"ID", "monitor_template_name", "monitor_template_desc", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
MonitorTemplateInputs = modules.NewJointServiceTreeManager(
"monitorInfo",
"monitorInfos",
[]string{"ID", "monitor_template_id", "monitor_name", "monitor_conf_value", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{},
&MonitorTemplates,
&MonitorInputs)
modules.Register(&MonitorTemplates)
modules.Register(&MonitorTemplateInputs)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
MonitorTypes modulebase.ResourceManager
)
func init() {
MonitorTypes = modules.NewServiceTreeManager("monitor_type", "monitor_types",
[]string{"id", "name", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&MonitorTypes)
}
@@ -1,107 +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 servicetree
import (
"fmt"
"net/url"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type NodeManager struct {
modulebase.ResourceManager
}
func _genSubtmitResults(idlist []string, status int, err error) []modulebase.SubmitResult {
results := make([]modulebase.SubmitResult, len(idlist))
var data jsonutils.JSONObject
if err != nil {
data = jsonutils.NewString(err.Error())
} else {
data = jsonutils.JSONNull
}
for i := 0; i < len(results); i++ {
results[i] = modulebase.SubmitResult{Id: idlist[i], Status: status, Data: data}
}
return results
}
func (this *NodeManager) _batchPerformInContexts(s *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []modulebase.ManagerContext) []modulebase.SubmitResult {
labels, err := params.Get("labels")
if err != nil {
return _genSubtmitResults(idlist, 406, fmt.Errorf("Missing labels"))
}
node := jsonutils.NewDict()
node.Add(jsonutils.NewStringArray(idlist), "nodes")
node.Add(labels, "labels")
body := jsonutils.NewDict()
body.Add(node, "node")
path := fmt.Sprintf("/%s/%s", this.ContextPath(ctxs), url.PathEscape(action))
_, err = modulebase.Post(this.ResourceManager, s, path, body, this.KeywordPlural)
if err != nil {
return _genSubtmitResults(idlist, 400, err)
}
return _genSubtmitResults(idlist, 200, nil)
}
func (this *NodeManager) BatchPerformActionInContexts(s *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []modulebase.ManagerContext) []modulebase.SubmitResult {
switch action {
case "remove-labels":
return this._batchPerformInContexts(s, idlist, action, params, ctxs)
case "add-labels":
return this._batchPerformInContexts(s, idlist, action, params, ctxs)
default:
return this.ResourceManager.BatchPerformActionInContexts(s, idlist, action, params, ctxs)
}
}
func (this *NodeManager) NewNode(s *mcclient.ClientSession, name string, ip string, res_type string) (jsonutils.JSONObject, error) {
data := jsonutils.NewDict()
data.Add(jsonutils.NewString(name), "name")
data.Add(jsonutils.NewString(ip), "ip")
if len(res_type) > 0 {
data.Add(jsonutils.NewString(res_type), "res_type")
}
arr := jsonutils.NewArray()
arr.Add(data)
params := jsonutils.NewDict()
params.Add(arr, "nodes")
res, err := modulebase.Post(this.ResourceManager, s, "/nodes", params, "nodes")
if err != nil {
return nil, err
}
fmt.Println(res)
return res, nil
}
var (
Nodes NodeManager
)
func init() {
Nodes = NodeManager{modules.NewServiceTreeManager("node", "nodes",
[]string{"ID", "name", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})}
modules.Register(&Nodes)
}
@@ -1,53 +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 servicetree
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type PerformanceManager struct {
modulebase.ResourceManager
}
var (
Performances PerformanceManager
)
func (this *PerformanceManager) GetTop5(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
node_labels, err := params.GetString("node_labels")
if err != nil {
fmt.Printf("Error: %s\n", err)
}
path := fmt.Sprintf("/%s/top5?node_labels=%s", this.KeywordPlural, node_labels)
return modulebase.Get(this.ResourceManager, s, path, this.Keyword)
}
func init() {
Performances = PerformanceManager{modules.NewServiceTreeManager("performance", "performances",
[]string{"cpu_idle", "memory_usage", "disk_ioread", "disk_iowrite", "traffic_in", "traffic_out"},
[]string{})}
modules.Register(&Performances)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ProjectAdminCandidate modulebase.ResourceManager
)
func init() {
ProjectAdminCandidate = modules.NewServiceTreeManager("project_admin_candidate", "project_admin_candidates",
[]string{"id", "name"},
[]string{},
)
modules.Register(&ProjectAdminCandidate)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ProjectAdmin modulebase.ResourceManager
)
func init() {
ProjectAdmin = modules.NewServiceTreeManager("project_admin", "project_admins",
[]string{"create_by", "gmt_create", "id", "is_deleted", "node_labels", "officer_id", "officer_name", "type", "domain"},
[]string{},
)
modules.Register(&ProjectAdmin)
}
@@ -1,36 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type ProjectNodeManager struct {
modulebase.ResourceManager
}
var (
ProjectHosts ProjectNodeManager
)
func init() {
ProjectHosts = ProjectNodeManager{modules.NewServiceTreeManager("project_host", "project_hosts",
[]string{"id", "host_id", "host_name", "ip", "vcpu_count", "vmem_size", "disk", "project", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "project_id", "remark"},
[]string{})}
modules.Register(&ProjectHosts)
}
@@ -1,53 +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 servicetree
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type RecipientsManager struct {
modulebase.ResourceManager
}
func (this *RecipientsManager) DoDeleteRecipient(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
path := fmt.Sprintf("/%s", this.KeywordPlural)
body := jsonutils.NewDict()
if params != nil {
body.Add(params, this.Keyword)
}
return modulebase.Delete(this.ResourceManager, s, path, body, this.Keyword)
}
var (
Recipients RecipientsManager
)
func init() {
Recipients = RecipientsManager{modules.NewServiceTreeManager("recipient", "recipients",
[]string{"id", "type", "details", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})}
modules.Register(&Recipients)
}
@@ -1,31 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ServiceNameSuggestion modulebase.ResourceManager
)
func init() {
ServiceNameSuggestion = modules.NewServiceTreeManager("service_name_suggestion", "service_name_suggestions",
[]string{"title", "content", "create_by", "gmt_create", "is_deleted"},
[]string{})
modules.Register(&ServiceNameSuggestion)
}
@@ -1,52 +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 servicetree
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type ServiceNodeManager struct {
modulebase.ResourceManager
}
func (this *ServiceNodeManager) DoDeleteServiceHost(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
path := fmt.Sprintf("/%s", this.KeywordPlural)
body := jsonutils.NewDict()
if params != nil {
body.Add(params, this.Keyword)
}
return modulebase.Delete(this.ResourceManager, s, path, body, this.Keyword)
}
var (
ServiceHosts ServiceNodeManager
)
func init() {
ServiceHosts = ServiceNodeManager{modules.NewServiceTreeManager("service_host", "service_hosts",
[]string{"id", "host_id", "host_name", "ip", "vcpu_count", "vmem_size", "disk", "project", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "project_id", "remark"},
[]string{})}
modules.Register(&ServiceHosts)
}
@@ -1,32 +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 servicetree
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
ServiceTrees modulebase.ResourceManager
)
func init() {
ServiceTrees = modules.NewServiceTreeManager("service_tree", "service_trees",
[]string{"id", "service_tree_name", "service_tree_struct", "status", "create_by", "update_by", "delete_by", "gmt_create", "gmt_modified", "gmt_delete", "is_deleted", "project_id", "remark"},
[]string{})
modules.Register(&ServiceTrees)
}
@@ -1,74 +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 servicetree
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type StatisticsManager struct {
modulebase.ResourceManager
}
var (
Statistics StatisticsManager
)
func (this *StatisticsManager) GetByEnv(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
node_labels, err := params.GetString("node_labels")
ret := jsonutils.NewDict()
if err != nil {
return ret, err
}
path := fmt.Sprintf("/%s/env?node_labels=%s", this.KeywordPlural, node_labels)
return modulebase.Get(this.ResourceManager, s, path, this.Keyword)
}
func (this *StatisticsManager) GetByResType(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
node_labels, err := params.GetString("node_labels")
ret := jsonutils.NewDict()
if err != nil {
return ret, err
}
path := fmt.Sprintf("/%s/res_type?node_labels=%s", this.KeywordPlural, node_labels)
return modulebase.Get(this.ResourceManager, s, path, this.Keyword)
}
func (this *StatisticsManager) GetHardware(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
node_labels, err := params.GetString("node_labels")
ret := jsonutils.NewDict()
if err != nil {
return ret, err
}
path := fmt.Sprintf("/%s/hardware?node_labels=%s", this.KeywordPlural, node_labels)
return modulebase.Get(this.ResourceManager, s, path, this.Keyword)
}
func init() {
Statistics = StatisticsManager{modules.NewServiceTreeManager("statistic", "statistics",
[]string{"ID"},
[]string{})}
modules.Register(&Statistics)
}
@@ -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 servicetree
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
type TreenodeManager struct {
modulebase.ResourceManager
}
var (
TreeNodes TreenodeManager
)
func (this *TreenodeManager) GetMap(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
path := fmt.Sprintf("/%s/getMap", this.KeywordPlural)
return modulebase.Get(this.ResourceManager, s, path, this.KeywordPlural)
}
func (this *TreenodeManager) GetNodeIDByLabels(s *mcclient.ClientSession, labels []string) (int64, error) {
var pid int64 = 0
for _, label := range labels {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(label), "name")
params.Add(jsonutils.NewInt(pid), "pid")
nodeList, err := this.List(s, params)
if err != nil {
return -1, err
}
if len(nodeList.Data) != 1 {
return -1, fmt.Errorf("Invalid label %s", label)
}
pid, err = nodeList.Data[0].Int("id")
if err != nil {
return -1, fmt.Errorf("Invalid node data")
}
}
return pid, nil
}
func init() {
TreeNodes = TreenodeManager{modules.NewServiceTreeManager("tree_node", "tree_nodes",
[]string{"id", "name", "pid", "order_no", "level", "group", "status", "project_id", "project_type", "create_way", "remark"},
[]string{})}
modules.Register(&TreeNodes)
}
-1
View File
@@ -1 +0,0 @@
package suggestion // import "yunion.io/x/onecloud/pkg/mcclient/modules/suggestion"
@@ -1,40 +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 suggestion
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
AnalysisPredictManager *SAnalysisPredict
)
func init() {
AnalysisPredictManager = NewAnalysisPredict()
modules.Register(AnalysisPredictManager)
}
type SAnalysisPredict struct {
*modulebase.ResourceManager
}
func NewAnalysisPredict() *SAnalysisPredict {
man := modules.NewSuggestionManager("analysispredict", "analysispredicts", []string{}, []string{})
return &SAnalysisPredict{
ResourceManager: &man,
}
}
@@ -1,78 +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 suggestion
import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
var (
SuggestSysRuleManager *SSuggestSysRuleManager
SuggestSysAlertManager *SSuggestSysAlertManager
InfluxdbShemaManager *SInfluxdbShemaManager
)
func init() {
SuggestSysRuleManager = NewSuggestSysRuleManager()
SuggestSysAlertManager = NewSuggestSysAlertManager()
InfluxdbShemaManager = NewInfluxdbShemaManager()
for _, m := range []modulebase.IBaseManager{
SuggestSysRuleManager,
SuggestSysAlertManager,
InfluxdbShemaManager,
} {
modules.Register(m)
}
}
type SSuggestSysRuleManager struct {
*modulebase.ResourceManager
}
type SSuggestSysAlertManager struct {
*modulebase.ResourceManager
}
type SInfluxdbShemaManager struct {
*modulebase.ResourceManager
}
func NewSuggestSysRuleManager() *SSuggestSysRuleManager {
man := modules.NewSuggestionManager("suggestsysrule", "suggestsysrules",
[]string{"id", "name", "type", "enabled", "period", "time_from", "setting"},
[]string{})
return &SSuggestSysRuleManager{
ResourceManager: &man,
}
}
func NewSuggestSysAlertManager() *SSuggestSysAlertManager {
man := modules.NewSuggestionManager("suggestsysalert", "suggestsysalerts",
[]string{"id", "name", "type", "res_id", "monitor_config"},
[]string{})
return &SSuggestSysAlertManager{
ResourceManager: &man,
}
}
func NewInfluxdbShemaManager() *SInfluxdbShemaManager {
man := modules.NewSuggestionManager("influxdbshema", "influxdbshemas",
[]string{},
[]string{})
return &SInfluxdbShemaManager{
ResourceManager: &man,
}
}
-1
View File
@@ -1 +0,0 @@
package websocket // import "yunion.io/x/onecloud/pkg/mcclient/modules/websocket"

Some files were not shown because too many files have changed in this diff Show More