mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #2794 from tb365/feature/tb-mcclient-modules-update
mcclient module base
This commit is contained in:
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -41,7 +42,7 @@ func init() {
|
||||
if len(args.Network) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Network), "network_id")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Host) > 0 {
|
||||
result, err = modules.Baremetalnetworks.ListDescendent(s, args.Host, params)
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -37,7 +38,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Host) > 0 {
|
||||
result, err = modules.Baremetalstorages.ListDescendent(s, args.Host, params)
|
||||
|
||||
@@ -22,6 +22,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -119,7 +120,7 @@ func init() {
|
||||
}
|
||||
|
||||
arrays, _ := result.GetArray("objects")
|
||||
listResult := modules.ListResult{Data: arrays}
|
||||
listResult := modulebase.ListResult{Data: arrays}
|
||||
printList(&listResult, []string{})
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -37,7 +38,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Manager) > 0 {
|
||||
result, err = modules.CloudproviderregionManager.ListDescendent(s, args.Manager, params)
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -68,7 +69,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := modules.ListResult{}
|
||||
listResult := modulebase.ListResult{}
|
||||
listResult.Data, err = results.GetArray()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -86,7 +87,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := modules.ListResult{}
|
||||
listResult := modulebase.ListResult{}
|
||||
listResult.Data, err = results.GetArray()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -145,7 +146,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(&modules.ListResult{Data: contacts}, nil)
|
||||
printList(&modulebase.ListResult{Data: contacts}, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@ package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"time"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
@@ -204,7 +205,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := modules.ListResult{}
|
||||
result := modulebase.ListResult{}
|
||||
result.Data = make([]jsonutils.JSONObject, len(secrets))
|
||||
for i := range secrets {
|
||||
result.Data[i] = jsonutils.Marshal(secrets[i])
|
||||
|
||||
@@ -16,6 +16,7 @@ package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -50,7 +51,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.DBInstance) > 0 {
|
||||
result, err = modules.DBInstanceNetworks.ListDescendent(s, opts.DBInstance, params)
|
||||
} else if len(opts.Network) > 0 {
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
)
|
||||
@@ -66,7 +67,7 @@ func doIdentityEventList(s *mcclient.ClientSession, args *EventListOptions) erro
|
||||
return doEventList(modules.IdentityLogs, s, args)
|
||||
}
|
||||
|
||||
func doEventList(man modules.ResourceManager, s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
func doEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args *EventListOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Type) > 0 {
|
||||
params.Add(jsonutils.NewStringArray(args.Type), "obj_type")
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -38,7 +39,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Host) > 0 {
|
||||
result, err = modules.Hostcachedimages.ListDescendent(s, args.Host, params)
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -38,7 +39,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
// if len(args.Storage) > 0 {
|
||||
// params.Add(jsonutils.NewString(args.Storage), "storage")
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -38,7 +39,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Host) > 0 {
|
||||
result, err = modules.Hostwires.ListDescendent(s, args.Host, params)
|
||||
|
||||
@@ -23,6 +23,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -445,7 +446,7 @@ func init() {
|
||||
continue
|
||||
}
|
||||
arrays, _ := result.(*jsonutils.JSONArray).GetArray()
|
||||
listResult := modules.ListResult{Data: arrays}
|
||||
listResult := modulebase.ListResult{Data: arrays}
|
||||
printList(&listResult, []string{})
|
||||
}
|
||||
return nil
|
||||
|
||||
+11
-11
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
o "yunion.io/x/onecloud/pkg/mcclient/options/k8s"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
@@ -77,8 +77,8 @@ func kubeResourceCmdN(prefix, suffix string) string {
|
||||
return fmt.Sprintf("kube-%s-%s", prefix, suffix)
|
||||
}
|
||||
|
||||
func clusterContext(clusterId string) modules.ManagerContext {
|
||||
return modules.ManagerContext{
|
||||
func clusterContext(clusterId string) modulebase.ManagerContext {
|
||||
return modulebase.ManagerContext{
|
||||
InstanceManager: k8s.Clusters,
|
||||
InstanceId: clusterId,
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (c *ShellCommands) AddR(rs ...*Cmd) *ShellCommands {
|
||||
return c
|
||||
}
|
||||
|
||||
func initK8sClusterResource(kind string, manager modules.Manager) *ShellCommands {
|
||||
func initK8sClusterResource(kind string, manager modulebase.Manager) *ShellCommands {
|
||||
cmdN := NewCmdNameFactory(kind)
|
||||
return NewShellCommands(cmdN.Do).AddR(
|
||||
NewK8sResourceListCmd(cmdN, manager),
|
||||
@@ -138,7 +138,7 @@ func initK8sClusterResource(kind string, manager modules.Manager) *ShellCommands
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceListCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sResourceListCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceListOptions{},
|
||||
cmdN.Do("list"),
|
||||
@@ -168,7 +168,7 @@ func NewCmdNameFactory(kind string) CmdNameFactory {
|
||||
}
|
||||
}
|
||||
|
||||
func NewK8sNsResourceListCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sNsResourceListCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceListOptions{},
|
||||
cmdN.Do("list"),
|
||||
@@ -184,7 +184,7 @@ func NewK8sNsResourceListCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceGetCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sResourceGetCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceGetOptions{},
|
||||
cmdN.Do("show"),
|
||||
@@ -200,7 +200,7 @@ func NewK8sResourceGetCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sNsResourceGetCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sNsResourceGetCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.NamespaceResourceGetOptions{},
|
||||
cmdN.Do("show"),
|
||||
@@ -216,7 +216,7 @@ func NewK8sNsResourceGetCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sResourceDeleteCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
return NewCommand(
|
||||
&o.ResourceDeleteOptions{},
|
||||
cmdN.Do("delete"),
|
||||
@@ -229,7 +229,7 @@ func NewK8sResourceDeleteCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd
|
||||
)
|
||||
}
|
||||
|
||||
func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modules.Manager) *Cmd {
|
||||
func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modulebase.Manager) *Cmd {
|
||||
deleteCmd := NewCommand(
|
||||
&o.NamespaceResourceDeleteOptions{},
|
||||
cmdN.Do("delete"),
|
||||
@@ -243,7 +243,7 @@ func NewK8sNsResourceDeleteCmd(cmdN CmdNameFactory, manager modules.Manager) *Cm
|
||||
return deleteCmd
|
||||
}
|
||||
|
||||
func initK8sNamespaceResource(kind string, manager modules.Manager) *ShellCommands {
|
||||
func initK8sNamespaceResource(kind string, manager modulebase.Manager) *ShellCommands {
|
||||
cmdN := NewCmdNameFactory(kind)
|
||||
return NewShellCommands(cmdN.Do).AddR(
|
||||
NewK8sNsResourceListCmd(cmdN, manager),
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ func getPrinterRowValues(printer k8s.ListPrinter, obj jsonutils.JSONObject, cols
|
||||
return ret
|
||||
}
|
||||
|
||||
func ListerTable(res *modules.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) *uitable.Table {
|
||||
func ListerTable(res *modulebase.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) *uitable.Table {
|
||||
min := func(x, y int) int {
|
||||
if x < y {
|
||||
return x
|
||||
@@ -78,7 +78,7 @@ func ListerTable(res *modules.ListResult, printer k8s.ListPrinter, s *mcclient.C
|
||||
return table
|
||||
}
|
||||
|
||||
func PrintListResultTable(res *modules.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) {
|
||||
func PrintListResultTable(res *modulebase.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) {
|
||||
fmt.Println(ListerTable(res, printer, s))
|
||||
|
||||
table := uitable.New()
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -33,7 +34,7 @@ func init() {
|
||||
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 := modules.GetModule(s, "labels")
|
||||
mod, err := modulebase.GetModule(s, "labels")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -51,7 +52,7 @@ func init() {
|
||||
}
|
||||
printObject(jd)
|
||||
}
|
||||
printLbAclList := func(list *modules.ListResult, columns []string) {
|
||||
printLbAclList := func(list *modulebase.ListResult, columns []string) {
|
||||
data := list.Data
|
||||
for _, jsonObj := range data {
|
||||
jd := jsonObj.(*jsonutils.JSONDict)
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -51,7 +52,7 @@ func init() {
|
||||
}
|
||||
printObject(jd)
|
||||
}
|
||||
printLbAclList := func(list *modules.ListResult, columns []string) {
|
||||
printLbAclList := func(list *modulebase.ListResult, columns []string) {
|
||||
data := list.Data
|
||||
for _, jsonObj := range data {
|
||||
jd := jsonObj.(*jsonutils.JSONDict)
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -42,7 +43,7 @@ func init() {
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip_addr")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Loadbalancer) > 0 {
|
||||
result, err = modules.Loadbalancernetworks.ListDescendent(s, args.Loadbalancer, params)
|
||||
|
||||
@@ -20,14 +20,14 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ModuleListOptions struct {
|
||||
}
|
||||
R(&ModuleListOptions{}, "module-list", "List all modules", func(s *mcclient.ClientSession, args *ModuleListOptions) error {
|
||||
modules, jointModules := modules.GetRegisterdModules()
|
||||
modules, jointModules := modulebase.GetRegisterdModules()
|
||||
json := jsonutils.Marshal(modules)
|
||||
fmt.Println("Modules")
|
||||
fmt.Println(json.PrettyString())
|
||||
|
||||
@@ -17,6 +17,7 @@ package shell
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,7 @@ func init() {
|
||||
}
|
||||
R(&NetworkinterfaceNetworkListOptions{}, "networkinterface-network-list", "List server network pairs", func(s *mcclient.ClientSession, args *NetworkinterfaceNetworkListOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Networkinterface) > 0 {
|
||||
result, err = modules.Networkinterfacenetworks.ListDescendent(s, args.Networkinterface, params)
|
||||
|
||||
@@ -20,6 +20,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -43,7 +44,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.Wire) > 0 {
|
||||
result, err = modules.Networks.ListInContext(s, params, &modules.Wires, opts.Wire)
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -41,7 +42,7 @@ func init() {
|
||||
params.Add(jsonutils.NewString(args.Name), "name")
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(args.NamespaceId) > 0 {
|
||||
params.Add(jsonutils.NewString(args.NamespaceId), "namespace_id")
|
||||
params.Add(jsonutils.NewString("system"), "scope")
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -175,7 +176,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = modules.RolesV3.PutInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
_, err = modules.RolesV3.PutInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -195,7 +196,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = modules.RolesV3.HeadInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
_, err = modules.RolesV3.HeadInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -214,7 +215,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = modules.RolesV3.DeleteInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
_, err = modules.RolesV3.DeleteInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -236,7 +237,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.RolesV3.ListInContexts(s, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
result, err := modules.RolesV3.ListInContexts(s, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.UsersV3, InstanceId: uid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -265,7 +266,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = modules.RolesV3.PutInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
_, err = modules.RolesV3.PutInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -284,7 +285,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = modules.RolesV3.HeadInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
_, err = modules.RolesV3.HeadInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -303,7 +304,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = modules.RolesV3.DeleteInContexts(s, rid, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
_, err = modules.RolesV3.DeleteInContexts(s, rid, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -324,7 +325,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.RolesV3.ListInContexts(s, nil, []modules.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
result, err := modules.RolesV3.ListInContexts(s, nil, []modulebase.ManagerContext{{InstanceManager: &modules.Projects, InstanceId: pid}, {InstanceManager: &modules.Groups, InstanceId: gid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
)
|
||||
|
||||
@@ -89,7 +90,7 @@ func init() {
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), nil)
|
||||
printList(modulebase.JSON2ListResult(result), nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
@@ -21,12 +21,13 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
printRouteTableList := func(list *modules.ListResult, columns []string) {
|
||||
printRouteTableList := func(list *modulebase.ListResult, columns []string) {
|
||||
data := list.Data
|
||||
for _, jsonObj := range data {
|
||||
jd := jsonObj.(*jsonutils.JSONDict)
|
||||
|
||||
@@ -18,15 +18,16 @@ import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type schedtagModelHelper struct {
|
||||
managers []modules.JointResourceManager
|
||||
managers []modulebase.JointResourceManager
|
||||
}
|
||||
|
||||
func newSchedtagModelHelper(mans ...modules.JointResourceManager) *schedtagModelHelper {
|
||||
func newSchedtagModelHelper(mans ...modulebase.JointResourceManager) *schedtagModelHelper {
|
||||
return &schedtagModelHelper{managers: mans}
|
||||
}
|
||||
|
||||
@@ -39,13 +40,13 @@ func (h *schedtagModelHelper) register() {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *schedtagModelHelper) list(slave modules.Manager, kw string) {
|
||||
func (h *schedtagModelHelper) list(slave modulebase.Manager, kw string) {
|
||||
R(
|
||||
&options.SchedtagModelListOptions{},
|
||||
fmt.Sprintf("schedtag-%s-list", kw),
|
||||
fmt.Sprintf("List all scheduler tag and %s pairs", kw),
|
||||
func(s *mcclient.ClientSession, args *options.SchedtagModelListOptions) error {
|
||||
mod, err := modules.GetJointModule2(s, &modules.Schedtags, slave)
|
||||
mod, err := modulebase.GetJointModule2(s, &modules.Schedtags, slave)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,7 +54,7 @@ func (h *schedtagModelHelper) list(slave modules.Manager, kw string) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(args.Schedtag) > 0 {
|
||||
result, err = mod.ListDescendent(s, args.Schedtag, params)
|
||||
} else {
|
||||
@@ -68,7 +69,7 @@ func (h *schedtagModelHelper) list(slave modules.Manager, kw string) {
|
||||
)
|
||||
}
|
||||
|
||||
func (h *schedtagModelHelper) add(man modules.JointResourceManager, kw string) {
|
||||
func (h *schedtagModelHelper) add(man modulebase.JointResourceManager, kw string) {
|
||||
R(
|
||||
&options.SchedtagModelPairOptions{},
|
||||
fmt.Sprintf("schedtag-%s-add", kw),
|
||||
@@ -83,7 +84,7 @@ func (h *schedtagModelHelper) add(man modules.JointResourceManager, kw string) {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *schedtagModelHelper) remove(man modules.JointResourceManager, kw string) {
|
||||
func (h *schedtagModelHelper) remove(man modulebase.JointResourceManager, kw string) {
|
||||
R(
|
||||
&options.SchedtagModelPairOptions{},
|
||||
fmt.Sprintf("schedtag-%s-remove", kw),
|
||||
@@ -98,7 +99,7 @@ func (h *schedtagModelHelper) remove(man modules.JointResourceManager, kw string
|
||||
})
|
||||
}
|
||||
|
||||
func (h *schedtagModelHelper) setTags(man modules.JointResourceManager, kw string) {
|
||||
func (h *schedtagModelHelper) setTags(man modulebase.JointResourceManager, kw string) {
|
||||
R(
|
||||
&options.SchedtagSetOptions{},
|
||||
fmt.Sprintf("%s-set-schedtag", kw),
|
||||
|
||||
@@ -20,6 +20,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -39,7 +40,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), listFields)
|
||||
printList(modulebase.JSON2ListResult(result), listFields)
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -86,7 +87,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), []string{
|
||||
printList(modulebase.JSON2ListResult(result), []string{
|
||||
"id", "name", "host_type", "cpu(free/reserverd/total)",
|
||||
"mem(free/reserverd/total)", "storage(free/reserverd/total)",
|
||||
"status", "host_status", "enable_status"})
|
||||
@@ -145,7 +146,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), []string{
|
||||
printList(modulebase.JSON2ListResult(result), []string{
|
||||
"session_id", "time", "status", "consuming",
|
||||
})
|
||||
return nil
|
||||
|
||||
@@ -20,6 +20,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -44,7 +45,7 @@ func init() {
|
||||
if args.Index >= 0 {
|
||||
params.Add(jsonutils.NewInt(args.Index), "index")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Server) > 0 {
|
||||
result, err = modules.Serverdisks.ListDescendent(s, args.Server, params)
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/cmdline"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -51,7 +52,7 @@ func init() {
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip_addr")
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Server) > 0 {
|
||||
result, err = modules.Servernetworks.ListDescendent(s, args.Server, params)
|
||||
|
||||
@@ -22,13 +22,14 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v2"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/cmdline"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -88,7 +89,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := modules.ListResult{}
|
||||
listResult := modulebase.ListResult{}
|
||||
listResult.Data = tasks
|
||||
printList(&listResult, nil)
|
||||
return nil
|
||||
@@ -174,7 +175,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), listFields)
|
||||
printList(modulebase.JSON2ListResult(result), listFields)
|
||||
} else {
|
||||
taskNotify := options.BoolV(opts.TaskNotify)
|
||||
if taskNotify {
|
||||
@@ -982,7 +983,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := modules.ListResult{}
|
||||
listResult := modulebase.ListResult{}
|
||||
listResult.Data, _ = result.GetArray()
|
||||
printList(&listResult, nil)
|
||||
return nil
|
||||
|
||||
@@ -20,6 +20,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -121,7 +122,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := &modules.ListResult{Data: hosts, Total: len(hosts)}
|
||||
data := &modulebase.ListResult{Data: hosts, Total: len(hosts)}
|
||||
printList(data, []string{"ID", "Name", "Mem", "CPU", "Storage_Info"})
|
||||
return nil
|
||||
})
|
||||
@@ -159,7 +160,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := &modules.ListResult{Data: devs, Total: len(devs)}
|
||||
data := &modulebase.ListResult{Data: devs, Total: len(devs)}
|
||||
printList(data, []string{"ID", "Addr", "Dev_Type", "Model", "Vendor_Device_Id"})
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -38,7 +39,7 @@ func init() {
|
||||
|
||||
}
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
var err error
|
||||
if len(args.Storagecache) > 0 {
|
||||
result, err = modules.Storagecachedimages.ListDescendent(s, args.Storagecache, params)
|
||||
|
||||
@@ -20,6 +20,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -39,7 +40,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.Zone) > 0 {
|
||||
result, err = modules.Storages.ListInContext(s, params, &modules.Zones, opts.Zone)
|
||||
} else {
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -143,7 +144,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modules.JSON2ListResult(result), nil)
|
||||
printList(modulebase.JSON2ListResult(result), nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/util/excelutils"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ func OutputFormat(s string) {
|
||||
outputFormat = s
|
||||
}
|
||||
|
||||
func printList(list *modules.ListResult, columns []string) {
|
||||
func printList(list *modulebase.ListResult, columns []string) {
|
||||
printutils.PrintJSONList(list, columns)
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ func printObjectRecursiveEx(obj jsonutils.JSONObject, cb printutils.PrintJSONObj
|
||||
printutils.PrintJSONObjectRecursiveEx(obj, cb)
|
||||
}
|
||||
|
||||
func printBatchResults(results []modules.SubmitResult, columns []string) {
|
||||
func printBatchResults(results []modulebase.SubmitResult, columns []string) {
|
||||
printutils.PrintJSONBatchResults(results, columns)
|
||||
}
|
||||
|
||||
func exportList(list *modules.ListResult, file string, exportKeys string, exportTexts string, columns []string) {
|
||||
func exportList(list *modulebase.ListResult, file string, exportKeys string, exportTexts string, columns []string) {
|
||||
var keys []string
|
||||
var texts []string
|
||||
if len(exportKeys) > 0 {
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -34,7 +35,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.Region) > 0 {
|
||||
result, err = modules.Vpcs.ListInContext(s, params, &modules.Cloudregions, opts.Region)
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -36,7 +37,7 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(opts.Zone) > 0 {
|
||||
result, err = modules.Wires.ListInContext(s, params, &modules.Zones, opts.Zone)
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ 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"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
@@ -35,7 +36,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var result *modules.ListResult
|
||||
var result *modulebase.ListResult
|
||||
if len(args.Region) > 0 {
|
||||
result, err = modules.Zones.ListInContext(s, params, &modules.Cloudregions, args.Region)
|
||||
} else {
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apigateway/clientman"
|
||||
"yunion.io/x/onecloud/pkg/apigateway/constants"
|
||||
@@ -880,17 +881,17 @@ func (h *AuthHandlers) doDeletePolicies(ctx context.Context, w http.ResponseWrit
|
||||
return
|
||||
}
|
||||
idStrList := jsonutils.JSONArray2StringArray(idlist)
|
||||
ret := make([]modules.SubmitResult, len(idStrList))
|
||||
ret := make([]modulebase.SubmitResult, len(idStrList))
|
||||
for i := range idStrList {
|
||||
err := policytool.PolicyDelete(s, idStrList[i])
|
||||
if err != nil {
|
||||
ret[i] = modules.SubmitResult{
|
||||
ret[i] = modulebase.SubmitResult{
|
||||
Status: 400,
|
||||
Id: idStrList[i],
|
||||
Data: jsonutils.NewString(err.Error()),
|
||||
}
|
||||
} else {
|
||||
ret[i] = modules.SubmitResult{
|
||||
ret[i] = modulebase.SubmitResult{
|
||||
Status: 200,
|
||||
Id: idStrList[i],
|
||||
Data: jsonutils.NewDict(),
|
||||
@@ -898,7 +899,7 @@ func (h *AuthHandlers) doDeletePolicies(ctx context.Context, w http.ResponseWrit
|
||||
}
|
||||
}
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
type CSRFResourceHandler struct {
|
||||
@@ -64,12 +64,12 @@ func getAdminSession(ctx context.Context, apiVer string, region string, w http.R
|
||||
return s
|
||||
}
|
||||
|
||||
func fetchEnv3Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modules.Manager, modules.Manager, modules.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
func fetchEnv3Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modulebase.Manager, modulebase.Manager, modulebase.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
module, module2, session, params, query, body := fetchEnv2Csrf(ctx, w, r)
|
||||
if module == nil || module2 == nil {
|
||||
return nil, nil, nil, nil, nil, nil, nil
|
||||
}
|
||||
module3, e := modules.GetModule(session, params[ResName3])
|
||||
module3, e := modulebase.GetModule(session, params[ResName3])
|
||||
if e != nil || module == nil {
|
||||
httperrors.NotFoundError(w, fmt.Sprintf("resource %s not found", params[ResName3]))
|
||||
return nil, nil, nil, nil, nil, nil, nil
|
||||
@@ -77,12 +77,12 @@ func fetchEnv3Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request)
|
||||
return module, module2, module3, session, params, query, body
|
||||
}
|
||||
|
||||
func fetchEnv2Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modules.Manager, modules.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
func fetchEnv2Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modulebase.Manager, modulebase.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
module, session, params, query, body := fetchEnvCsrf(ctx, w, r)
|
||||
if module == nil {
|
||||
return nil, nil, nil, nil, nil, nil
|
||||
}
|
||||
module2, e := modules.GetModule(session, params[ResName2])
|
||||
module2, e := modulebase.GetModule(session, params[ResName2])
|
||||
if e != nil || module == nil {
|
||||
httperrors.NotFoundError(w, fmt.Sprintf("resource %s not found", params[ResName2]))
|
||||
return nil, nil, nil, nil, nil, nil
|
||||
@@ -90,9 +90,9 @@ func fetchEnv2Csrf(ctx context.Context, w http.ResponseWriter, r *http.Request)
|
||||
return module, module2, session, params, query, body
|
||||
}
|
||||
|
||||
func fetchEnvCsrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modules.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
func fetchEnvCsrf(ctx context.Context, w http.ResponseWriter, r *http.Request) (modulebase.Manager, *mcclient.ClientSession, map[string]string, jsonutils.JSONObject, jsonutils.JSONObject) {
|
||||
session, params, query, body := fetchEnvCsrf0(ctx, w, r)
|
||||
module, e := modules.GetModule(session, params[ResName])
|
||||
module, e := modulebase.GetModule(session, params[ResName])
|
||||
if e != nil || module == nil {
|
||||
httperrors.NotFoundError(w, fmt.Sprintf("resource %s not found", params[ResName]))
|
||||
return nil, nil, nil, nil, nil
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
@@ -41,9 +41,9 @@ type Request struct {
|
||||
params map[string]string
|
||||
query jsonutils.JSONObject
|
||||
body jsonutils.JSONObject
|
||||
mod1 modules.Manager
|
||||
mod2 modules.Manager
|
||||
mod3 modules.Manager
|
||||
mod1 modulebase.Manager
|
||||
mod2 modulebase.Manager
|
||||
mod3 modulebase.Manager
|
||||
}
|
||||
|
||||
func newRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) *Request {
|
||||
@@ -127,21 +127,21 @@ func (req *Request) Spec() string {
|
||||
return req.params[Spec]
|
||||
}
|
||||
|
||||
func (req *Request) Mod1() modules.Manager {
|
||||
func (req *Request) Mod1() modulebase.Manager {
|
||||
return req.mod1
|
||||
}
|
||||
|
||||
func (req *Request) Mod2() modules.Manager {
|
||||
func (req *Request) Mod2() modulebase.Manager {
|
||||
return req.mod2
|
||||
}
|
||||
|
||||
func (req *Request) Mod3() modules.Manager {
|
||||
func (req *Request) Mod3() modulebase.Manager {
|
||||
return req.mod3
|
||||
}
|
||||
|
||||
func (req Request) findMod(resKey string) (modules.Manager, error) {
|
||||
func (req Request) findMod(resKey string) (modulebase.Manager, error) {
|
||||
resName := req.params[resKey]
|
||||
module, err := modules.GetModule(req.session, resName)
|
||||
module, err := modulebase.GetModule(req.session, resName)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("found module by %s: %v", resName, err)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/excelutils"
|
||||
)
|
||||
|
||||
@@ -160,7 +160,7 @@ func (f *ResourceHandlers) listHandler(ctx context.Context, w http.ResponseWrite
|
||||
httperrors.GeneralServerError(w, req.Error())
|
||||
return
|
||||
}
|
||||
jmod, _ := modules.GetJointModule(req.Session(), req.ResName())
|
||||
jmod, _ := modulebase.GetJointModule(req.Session(), req.ResName())
|
||||
if jmod != nil {
|
||||
f.doList(req.Session(), jmod, req.Query(), w, r)
|
||||
} else {
|
||||
@@ -180,14 +180,14 @@ func (f *ResourceHandlers) listHandler(ctx context.Context, w http.ResponseWrite
|
||||
querydict.Remove("id")
|
||||
}
|
||||
ret := req.Mod1().BatchGet(req.Session(), idlist, req.Query())
|
||||
appsrv.SendJSON(w, modules.ListResult2JSON(modules.SubmitResults2ListResult(ret)))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSON(modulebase.SubmitResults2ListResult(ret)))
|
||||
} else {
|
||||
f.doList(req.Session(), req.Mod1(), req.Query(), w, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ResourceHandlers) doList(session *mcclient.ClientSession, module modules.BaseManagerInterface, query jsonutils.JSONObject, w http.ResponseWriter, r *http.Request) {
|
||||
func (f *ResourceHandlers) doList(session *mcclient.ClientSession, module modulebase.BaseManagerInterface, query jsonutils.JSONObject, w http.ResponseWriter, r *http.Request) {
|
||||
var exportKeys []string
|
||||
var exportTexts []string
|
||||
exportFormat, _ := query.GetString("export")
|
||||
@@ -227,7 +227,7 @@ func (f *ResourceHandlers) doList(session *mcclient.ClientSession, module module
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"export-%s.xlsx\"", module.KeyString()))
|
||||
excelutils.Export(ret.Data, exportKeys, exportTexts, w)
|
||||
} else {
|
||||
appsrv.SendJSON(w, modules.ListResult2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSON(ret))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ func (f *ResourceHandlers) getSpecHandler(ctx context.Context, w http.ResponseWr
|
||||
module := req.Mod1()
|
||||
query := req.Query()
|
||||
|
||||
module2, e := modules.GetModule(session, req.Spec())
|
||||
module2, e := modulebase.GetModule(session, req.Spec())
|
||||
if e == nil { // list in 1 context
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
var ret *modules.ListResult
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
var ret *modulebase.ListResult
|
||||
if e == nil { // joint module
|
||||
ret, e = jmod.ListDescendent(session, req.ResID(), query)
|
||||
} else {
|
||||
@@ -274,7 +274,7 @@ func (f *ResourceHandlers) getSpecHandler(ctx context.Context, w http.ResponseWr
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
} else {
|
||||
appsrv.SendJSON(w, modules.ListResult2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSON(ret))
|
||||
}
|
||||
} else {
|
||||
obj, e := module.GetSpecific(session, req.ResID(), req.Spec(), query)
|
||||
@@ -299,7 +299,7 @@ func (f *ResourceHandlers) getJointHandler(ctx context.Context, w http.ResponseW
|
||||
module2 := req.Mod2()
|
||||
session := req.Session()
|
||||
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
if e != nil {
|
||||
httperrors.NotFoundError(w, fmt.Sprintf("resource %s-%s not exist", req.ResName(), req.ResName2()))
|
||||
return
|
||||
@@ -325,11 +325,11 @@ func (f *ResourceHandlers) listInContextsHandler(ctx context.Context, w http.Res
|
||||
module3 := req.Mod3()
|
||||
session := req.Session()
|
||||
query := req.Query()
|
||||
obj, e := module3.ListInContexts(session, query, []modules.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
obj, e := module3.ListInContexts(session, query, []modulebase.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
} else {
|
||||
appsrv.SendJSON(w, modules.ListResult2JSON(obj))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSON(obj))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ func (f *ResourceHandlers) createHandler(ctx context.Context, w http.ResponseWri
|
||||
nbody := bodyDict.Copy("__count__")
|
||||
ret := module.BatchCreate(session, nbody, int(count))
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
} else {
|
||||
obj, e := module.Create(session, body)
|
||||
@@ -389,7 +389,7 @@ func (f *ResourceHandlers) batchPerformActionHandler(ctx context.Context, w http
|
||||
} else {
|
||||
ret := module.BatchPerformAction(session, jsonutils.JSONArray2StringArray(idlist), req.Action(), body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,21 +410,21 @@ func (f *ResourceHandlers) performActionHandler(ctx context.Context, w http.Resp
|
||||
|
||||
var obj jsonutils.JSONObject
|
||||
var idlist []string
|
||||
if module2, e := modules.GetModule(session, req.Action()); e == nil {
|
||||
if jmod, e := modules.GetJointModule2(session, module, module2); e == nil {
|
||||
if module2, e := modulebase.GetModule(session, req.Action()); e == nil {
|
||||
if jmod, e := modulebase.GetJointModule2(session, module, module2); e == nil {
|
||||
if idlist = fetchIdList(query, w); idlist == nil {
|
||||
return
|
||||
}
|
||||
ret := jmod.BatchAttach(session, req.ResID(), idlist, body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
} else if jmod, e := modules.GetJointModule2(session, module2, module); e == nil {
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
} else if jmod, e := modulebase.GetJointModule2(session, module2, module); e == nil {
|
||||
if idlist = fetchIdList(query, w); idlist == nil {
|
||||
return
|
||||
}
|
||||
ret := jmod.BatchAttach2(session, req.ResID(), idlist, body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
} else {
|
||||
if obj, e = module2.CreateInContext(session, body, module, req.ResID()); e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
@@ -454,7 +454,7 @@ func (f *ResourceHandlers) attachHandler(ctx context.Context, w http.ResponseWri
|
||||
session := req.Session()
|
||||
body := req.Body()
|
||||
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
if e != nil {
|
||||
httperrors.NotFoundError(w, fmt.Sprintf("resource %s-%s not exists", req.ResName(), req.ResName2()))
|
||||
return
|
||||
@@ -487,7 +487,7 @@ func (f *ResourceHandlers) batchUpdateHandler(ctx context.Context, w http.Respon
|
||||
|
||||
ret := module.BatchUpdate(req.Session(), idlist, body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
// batchPatch
|
||||
@@ -510,7 +510,7 @@ func (f *ResourceHandlers) batchPatchHandler(ctx context.Context, w http.Respons
|
||||
|
||||
ret := module.BatchPatch(req.Session(), idlist, body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
// put single
|
||||
@@ -567,7 +567,7 @@ func (f *ResourceHandlers) updateJointHandler(ctx context.Context, w http.Respon
|
||||
module2 := req.Mod2()
|
||||
body := req.Body()
|
||||
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
var obj jsonutils.JSONObject
|
||||
if e == nil { // update joint
|
||||
obj, e = jmod.Update(session, req.ResID(), req.ResID2(), nil, body)
|
||||
@@ -592,7 +592,7 @@ func (f *ResourceHandlers) patchJointHandler(ctx context.Context, w http.Respons
|
||||
module2 := req.Mod2()
|
||||
body := req.Body()
|
||||
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
var obj jsonutils.JSONObject
|
||||
if e == nil { // update joint
|
||||
obj, e = jmod.Patch(session, req.ResID(), req.ResID2(), nil, body)
|
||||
@@ -623,14 +623,14 @@ func (f *ResourceHandlers) batchUpdateJointHandler(ctx context.Context, w http.R
|
||||
if idlist == nil {
|
||||
return
|
||||
}
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
if e != nil { // update joint
|
||||
httperrors.GeneralServerError(w, e)
|
||||
return
|
||||
}
|
||||
ret := jmod.BatchUpdate(session, req.ResID(), idlist, query, body)
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
// update in contexts
|
||||
@@ -642,7 +642,7 @@ func (f *ResourceHandlers) updateInContextsHandler(ctx context.Context, w http.R
|
||||
return
|
||||
}
|
||||
|
||||
obj, e := req.Mod3().PutInContexts(req.Session(), req.ResID3(), req.Body(), []modules.ManagerContext{{req.Mod1(), req.ResID()}, {req.Mod2(), req.ResID2()}})
|
||||
obj, e := req.Mod3().PutInContexts(req.Session(), req.ResID3(), req.Body(), []modulebase.ManagerContext{{req.Mod1(), req.ResID()}, {req.Mod2(), req.ResID2()}})
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
} else {
|
||||
@@ -662,7 +662,7 @@ func (f *ResourceHandlers) patchInContextsHandler(ctx context.Context, w http.Re
|
||||
session := req.Session()
|
||||
body := req.Body()
|
||||
|
||||
obj, e := module3.PatchInContexts(session, req.ResID3(), body, []modules.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
obj, e := module3.PatchInContexts(session, req.ResID3(), body, []modulebase.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
} else {
|
||||
@@ -685,7 +685,7 @@ func (f *ResourceHandlers) batchDeleteHandler(ctx context.Context, w http.Respon
|
||||
}
|
||||
ret := req.Mod1().BatchDeleteWithParam(req.Session(), idlist, req.Query(), req.Body())
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
// delete single
|
||||
@@ -719,12 +719,12 @@ func (f *ResourceHandlers) batchDetachHandler(ctx context.Context, w http.Respon
|
||||
session := req.Session()
|
||||
module := req.Mod1()
|
||||
module2 := req.Mod2()
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
var ret []modules.SubmitResult
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
var ret []modulebase.SubmitResult
|
||||
if e == nil {
|
||||
ret = jmod.BatchDetach(session, req.ResID(), idlist)
|
||||
} else {
|
||||
jmod, e := modules.GetJointModule2(session, module2, module)
|
||||
jmod, e := modulebase.GetJointModule2(session, module2, module)
|
||||
if e == nil {
|
||||
ret = jmod.BatchDetach2(session, req.ResID(), idlist)
|
||||
} else {
|
||||
@@ -732,7 +732,7 @@ func (f *ResourceHandlers) batchDetachHandler(ctx context.Context, w http.Respon
|
||||
}
|
||||
}
|
||||
w.WriteHeader(207)
|
||||
appsrv.SendJSON(w, modules.SubmitResults2JSON(ret))
|
||||
appsrv.SendJSON(w, modulebase.SubmitResults2JSON(ret))
|
||||
}
|
||||
|
||||
// detach joint
|
||||
@@ -748,7 +748,7 @@ func (f *ResourceHandlers) detachHandle(ctx context.Context, w http.ResponseWrit
|
||||
module := req.Mod1()
|
||||
module2 := req.Mod2()
|
||||
|
||||
jmod, e := modules.GetJointModule2(session, module, module2)
|
||||
jmod, e := modulebase.GetJointModule2(session, module, module2)
|
||||
var obj jsonutils.JSONObject
|
||||
if e == nil { // joint detach
|
||||
obj, e = jmod.Detach(session, req.ResID(), req.ResID2(), nil)
|
||||
@@ -777,7 +777,7 @@ func (f *ResourceHandlers) deleteInContextsHandler(ctx context.Context, w http.R
|
||||
query := req.Query()
|
||||
body := req.Body()
|
||||
|
||||
obj, e := module3.DeleteInContextsWithParam(session, req.ResID3(), query, body, []modules.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
obj, e := module3.DeleteInContextsWithParam(session, req.ResID3(), query, body, []modulebase.ManagerContext{{module, req.ResID()}, {module2, req.ResID2()}})
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(w, e)
|
||||
} else {
|
||||
|
||||
@@ -22,13 +22,13 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
)
|
||||
|
||||
@@ -86,7 +86,7 @@ func rpcHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
pathParams := appctx.AppContextParams(ctx)
|
||||
s := auth.GetSession(ctx, token, FetchRegion(req), pathParams["<apiver>"])
|
||||
funcname := verb + utils.Kebab2Camel(callName, "-")
|
||||
mod, e := modules.GetModule(s, resType)
|
||||
mod, e := modulebase.GetModule(s, resType)
|
||||
if e != nil || mod == nil {
|
||||
if e != nil {
|
||||
log.Debugf("module %s not found %s", resType, e)
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apigateway/app"
|
||||
"yunion.io/x/onecloud/pkg/apigateway/clientman"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
app_common "yunion.io/x/onecloud/pkg/cloudcommon/app"
|
||||
common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func StartService() {
|
||||
@@ -51,7 +51,7 @@ func StartService() {
|
||||
serviceApp := app.NewApp(app_common.InitApp(baseOpts, false))
|
||||
serviceApp.InitHandlers().Bind()
|
||||
|
||||
mods, jmods := modules.GetRegisterdModules()
|
||||
mods, jmods := modulebase.GetRegisterdModules()
|
||||
log.Infof("Modules: %s", jsonutils.Marshal(mods).PrettyString())
|
||||
log.Infof("Modules: %s", jsonutils.Marshal(jmods).PrettyString())
|
||||
|
||||
|
||||
@@ -18,16 +18,16 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"strings"
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
func AddModelDispatcher(prefix string, app *appsrv.Application, manager IModelDispatchHandler) {
|
||||
@@ -206,7 +206,7 @@ func handleList(ctx context.Context, w http.ResponseWriter, manager IModelDispat
|
||||
httperrors.GeneralServerError(w, err)
|
||||
return
|
||||
}
|
||||
appsrv.SendJSON(w, modules.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
}
|
||||
|
||||
func fetchContextIds(segs []string, params map[string]string) ([]SResourceContext, []string) {
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
type IMiddlewareFilter interface {
|
||||
@@ -40,12 +40,12 @@ type IModelDispatchHandler interface {
|
||||
KeywordPlural() string
|
||||
ContextKeywordPlurals() [][]string
|
||||
|
||||
List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modules.ListResult, error)
|
||||
List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modulebase.ListResult, error)
|
||||
Get(ctx context.Context, idstr string, query jsonutils.JSONObject, isHead bool) (jsonutils.JSONObject, error)
|
||||
GetSpecific(ctx context.Context, idstr string, spec string, query jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
|
||||
Create(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, ctxIds []SResourceContext) (jsonutils.JSONObject, error)
|
||||
BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []SResourceContext) ([]modules.SubmitResult, error)
|
||||
BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []SResourceContext) ([]modulebase.SubmitResult, error)
|
||||
|
||||
PerformClassAction(ctx context.Context, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
PerformAction(ctx context.Context, idstr string, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
@@ -71,9 +71,9 @@ type IJointModelDispatchHandler interface {
|
||||
MasterKeywordPlural() string
|
||||
SlaveKeywordPlural() string
|
||||
|
||||
List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modules.ListResult, error)
|
||||
ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modules.ListResult, error)
|
||||
ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modules.ListResult, error)
|
||||
List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modulebase.ListResult, error)
|
||||
ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error)
|
||||
ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error)
|
||||
Get(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
Attach(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
Update(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
|
||||
@@ -18,13 +18,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
func AddJointModelDispatcher(prefix string, app *appsrv.Application, manager IJointModelDispatchHandler) {
|
||||
@@ -120,12 +121,12 @@ func jointListHandler(ctx context.Context, w http.ResponseWriter, r *http.Reques
|
||||
httperrors.GeneralServerError(w, err)
|
||||
return
|
||||
}
|
||||
appsrv.SendJSON(w, modules.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
}
|
||||
|
||||
func jointListDescendentHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
manager, params, query, _ := fetchJointEnv(ctx, w, r)
|
||||
var listResult *modules.ListResult
|
||||
var listResult *modulebase.ListResult
|
||||
var err error
|
||||
if _, ok := params["<master_id>"]; ok {
|
||||
listResult, err = manager.ListMasterDescendent(ctx, params["<master_id>"], mergeQueryParams(params, query, "<master_id>"))
|
||||
@@ -136,7 +137,7 @@ func jointListDescendentHandler(ctx context.Context, w http.ResponseWriter, r *h
|
||||
httperrors.GeneralServerError(w, err)
|
||||
return
|
||||
}
|
||||
appsrv.SendJSON(w, modules.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
appsrv.SendJSON(w, modulebase.ListResult2JSONWithKey(listResult, manager.KeywordPlural()))
|
||||
}
|
||||
|
||||
func jointGetHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
o "yunion.io/x/onecloud/pkg/baremetal/options"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/dhcp"
|
||||
)
|
||||
@@ -236,7 +237,7 @@ func (req *dhcpRequest) findNetworkConf(session *mcclient.ClientSession, filterU
|
||||
return &network, err
|
||||
}
|
||||
|
||||
func (req *dhcpRequest) findBaremetalsOfAnyMac(session *mcclient.ClientSession, isBaremetal bool) (*modules.ListResult, error) {
|
||||
func (req *dhcpRequest) findBaremetalsOfAnyMac(session *mcclient.ClientSession, isBaremetal bool) (*modulebase.ListResult, error) {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString(req.ClientMac.String()), "any_mac")
|
||||
if isBaremetal {
|
||||
|
||||
@@ -37,7 +37,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
@@ -440,7 +440,7 @@ func fetchContextObject(manager IModelManager, ctx context.Context, userCred mcc
|
||||
return nil, httperrors.NewInternalServerError("No such context %s(%s)", ctxId.Type, ctxId.Id)
|
||||
}
|
||||
|
||||
func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modules.ListResult, error) {
|
||||
func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) {
|
||||
var err error
|
||||
var maxLimit int64 = 2048
|
||||
limit, _ := query.Int("limit")
|
||||
@@ -479,7 +479,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
}
|
||||
// log.Debugf("total count %d", totalCnt)
|
||||
if totalCnt == 0 {
|
||||
emptyList := modules.ListResult{Data: []jsonutils.JSONObject{}}
|
||||
emptyList := modulebase.ListResult{Data: []jsonutils.JSONObject{}}
|
||||
return &emptyList, nil
|
||||
}
|
||||
} else {
|
||||
@@ -578,7 +578,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
}
|
||||
retList = retList[:limit]
|
||||
}
|
||||
retResult := modules.ListResult{
|
||||
retResult := modulebase.ListResult{
|
||||
Data: retList, Limit: int(limit),
|
||||
NextMarker: nextMarker,
|
||||
MarkerField: pagingConf.MarkerField,
|
||||
@@ -627,7 +627,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
return calculateListResult(retList, int64(totalCnt), limit, offset, paginate), nil
|
||||
}
|
||||
|
||||
func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64, paginate bool) *modules.ListResult {
|
||||
func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64, paginate bool) *modulebase.ListResult {
|
||||
if paginate {
|
||||
// do offset first
|
||||
if offset > 0 {
|
||||
@@ -643,12 +643,12 @@ func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64
|
||||
}
|
||||
}
|
||||
|
||||
retResult := modules.ListResult{Data: data, Total: int(total), Limit: int(limit), Offset: int(offset)}
|
||||
retResult := modulebase.ListResult{Data: data, Total: int(total), Limit: int(limit), Offset: int(offset)}
|
||||
|
||||
return &retResult
|
||||
}
|
||||
|
||||
func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modules.ListResult, error) {
|
||||
func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) {
|
||||
userCred := fetchUserCredential(ctx)
|
||||
|
||||
items, err := ListItems(dispatcher.modelManager, ctx, userCred, query, ctxIds)
|
||||
@@ -1106,7 +1106,7 @@ func expandMultiCreateParams(data jsonutils.JSONObject, count int) ([]jsonutils.
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modules.SubmitResult, error) {
|
||||
func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modulebase.SubmitResult, error) {
|
||||
userCred := fetchUserCredential(ctx)
|
||||
|
||||
manager := dispatcher.modelManager
|
||||
@@ -1163,10 +1163,10 @@ func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query json
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
results := make([]modules.SubmitResult, count)
|
||||
results := make([]modulebase.SubmitResult, count)
|
||||
models := make([]IModel, 0)
|
||||
for i, res := range createResults {
|
||||
result := modules.SubmitResult{}
|
||||
result := modulebase.SubmitResult{}
|
||||
if res.err != nil {
|
||||
jsonErr, ok := res.err.(*httputils.JSONClientError)
|
||||
if ok {
|
||||
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
type DBJointModelDispatcher struct {
|
||||
@@ -59,7 +59,7 @@ func (dispatcher *DBJointModelDispatcher) SlaveKeywordPlural() string {
|
||||
return jointManager.GetSlaveManager().KeywordPlural()
|
||||
}
|
||||
|
||||
func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modules.ListResult, error) {
|
||||
func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) {
|
||||
//log.Debugf("ListMasterDescendent %s %s", dispatcher.JointModelManager().GetMasterManager().Keyword(), idStr)
|
||||
userCred := fetchUserCredential(ctx)
|
||||
|
||||
@@ -85,7 +85,7 @@ func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Conte
|
||||
return dispatcher._listJoint(ctx, userCred, model.(IStandaloneModel), queryDict)
|
||||
}
|
||||
|
||||
func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modules.ListResult, error) {
|
||||
func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) {
|
||||
//log.Debugf("ListSlaveDescendent %s %s", dispatcher.JointModelManager().GetMasterManager().Keyword(), idStr)
|
||||
userCred := fetchUserCredential(ctx)
|
||||
|
||||
@@ -111,7 +111,7 @@ func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Contex
|
||||
return dispatcher._listJoint(ctx, userCred, model.(IStandaloneModel), queryDict)
|
||||
}
|
||||
|
||||
func (dispatcher *DBJointModelDispatcher) _listJoint(ctx context.Context, userCred mcclient.TokenCredential, ctxModel IStandaloneModel, queryDict jsonutils.JSONObject) (*modules.ListResult, error) {
|
||||
func (dispatcher *DBJointModelDispatcher) _listJoint(ctx context.Context, userCred mcclient.TokenCredential, ctxModel IStandaloneModel, queryDict jsonutils.JSONObject) (*modulebase.ListResult, error) {
|
||||
items, err := ListItems(dispatcher.JointModelManager(), ctx, userCred, queryDict, nil)
|
||||
if err != nil {
|
||||
log.Errorf("Fail to list items: %s", err)
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
@@ -32,7 +33,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func NewEtcdModelHandler(manger base.IEtcdModelManager) *SEtcdModelHandler {
|
||||
@@ -73,12 +73,12 @@ func (disp *SEtcdModelHandler) FetchUpdateHeaderData(ctx context.Context, header
|
||||
return disp.manager.FetchUpdateHeaderData(ctx, header)
|
||||
}
|
||||
|
||||
func (disp *SEtcdModelHandler) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modules.ListResult, error) {
|
||||
func (disp *SEtcdModelHandler) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) {
|
||||
objs, err := disp.manager.AllJson(ctx)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
return &modules.ListResult{
|
||||
return &modulebase.ListResult{
|
||||
Data: objs,
|
||||
Total: len(objs),
|
||||
Limit: 0,
|
||||
@@ -171,7 +171,7 @@ func (disp *SEtcdModelHandler) Create(ctx context.Context, query jsonutils.JSONO
|
||||
return nil, httperrors.NewNotImplementedError("not implemented")
|
||||
}
|
||||
|
||||
func (disp *SEtcdModelHandler) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modules.SubmitResult, error) {
|
||||
func (disp *SEtcdModelHandler) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modulebase.SubmitResult, error) {
|
||||
return nil, httperrors.NewNotImplementedError("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
@@ -230,7 +231,7 @@ var (
|
||||
domainCache = make(map[string]string)
|
||||
)
|
||||
|
||||
func getIdentityId(s *mcclient.ClientSession, idName string, manager modules.Manager) (string, error) {
|
||||
func getIdentityId(s *mcclient.ClientSession, idName string, manager modulebase.Manager) (string, error) {
|
||||
domain, idName := parseIdName(idName)
|
||||
|
||||
query := jsonutils.NewDict()
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-go/pkg/s3utils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
@@ -41,7 +42,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
@@ -742,7 +742,7 @@ func (bucket *SBucket) PerformDelete(
|
||||
return nil, httperrors.NewInternalServerError("fail to find external bucket: %s", err)
|
||||
}
|
||||
ok := jsonutils.NewDict()
|
||||
results := modules.BatchDo(keyStrs, func(key string) (jsonutils.JSONObject, error) {
|
||||
results := modulebase.BatchDo(keyStrs, func(key string) (jsonutils.JSONObject, error) {
|
||||
if strings.HasSuffix(key, "/") {
|
||||
err = cloudprovider.DeletePrefix(ctx, iBucket, key)
|
||||
} else {
|
||||
@@ -760,7 +760,7 @@ func (bucket *SBucket) PerformDelete(
|
||||
|
||||
bucket.syncWithCloudBucket(ctx, userCred, iBucket, nil, true)
|
||||
|
||||
return modules.SubmitResults2JSON(results), nil
|
||||
return modulebase.SubmitResults2JSON(results), nil
|
||||
}
|
||||
|
||||
func (bucket *SBucket) AllowPerformUpload(ctx context.Context,
|
||||
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/image/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/fileutils2"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
@@ -175,7 +176,7 @@ func (manager *SImageManager) GetPropertyDetail(ctx context.Context, userCred mc
|
||||
log.Errorf("Fail to list items: %s", err)
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
return modules.ListResult2JSONWithKey(items, manager.KeywordPlural()), nil
|
||||
return modulebase.ListResult2JSONWithKey(items, manager.KeywordPlural()), nil
|
||||
}
|
||||
|
||||
func (manager *SImageManager) IsCustomizedGetDetailsBody() bool {
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"sort"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
@@ -25,7 +26,7 @@ import (
|
||||
|
||||
type IModelSet interface {
|
||||
//InitializeFromJSON([]jsonutils.JSONObject) error
|
||||
ModelManager() modules.Manager
|
||||
ModelManager() modulebase.Manager
|
||||
NewModel() models.IVirtualResource
|
||||
//GetModel(id string) models.IVirtualResource
|
||||
addModelCallback(models.IVirtualResource) error
|
||||
@@ -39,7 +40,7 @@ type LoadbalancerBackends map[string]*LoadbalancerBackend
|
||||
type LoadbalancerAcls map[string]*LoadbalancerAcl
|
||||
type LoadbalancerCertificates map[string]*LoadbalancerCertificate
|
||||
|
||||
func (set Loadbalancers) ModelManager() modules.Manager {
|
||||
func (set Loadbalancers) ModelManager() modulebase.Manager {
|
||||
return &modules.Loadbalancers
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@ func (ms Loadbalancers) JoinBackendGroups(subEntries LoadbalancerBackendGroups)
|
||||
return correct
|
||||
}
|
||||
|
||||
func (set LoadbalancerListeners) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerListeners) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerListeners
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@ func (ms LoadbalancerListeners) JoinCertificates(subEntries LoadbalancerCertific
|
||||
return correct
|
||||
}
|
||||
|
||||
func (set LoadbalancerListenerRules) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerListenerRules) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerListenerRules
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ func (set LoadbalancerListenerRules) OrderedEnabledList() OrderedLoadbalancerLis
|
||||
return rules
|
||||
}
|
||||
|
||||
func (set LoadbalancerBackendGroups) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerBackendGroups) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerBackendGroups
|
||||
}
|
||||
|
||||
@@ -253,7 +254,7 @@ func (ms LoadbalancerBackendGroups) JoinBackends(subEntries LoadbalancerBackends
|
||||
return correct
|
||||
}
|
||||
|
||||
func (set LoadbalancerBackends) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerBackends) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerBackends
|
||||
}
|
||||
|
||||
@@ -269,7 +270,7 @@ func (set LoadbalancerBackends) addModelCallback(i models.IVirtualResource) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (set LoadbalancerAcls) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerAcls) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerAcls
|
||||
}
|
||||
|
||||
@@ -285,7 +286,7 @@ func (set LoadbalancerAcls) addModelCallback(i models.IVirtualResource) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (set LoadbalancerCertificates) ModelManager() modules.Manager {
|
||||
func (set LoadbalancerCertificates) ModelManager() modulebase.Manager {
|
||||
return &modules.LoadbalancerCertificates
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/pkg/util/timeutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ var PseudoZeroTime = time.Time{}.Add(time.Nanosecond)
|
||||
|
||||
type GetModelsOptions struct {
|
||||
ClientSession *mcclient.ClientSession
|
||||
ModelManager modules.Manager
|
||||
ModelManager modulebase.Manager
|
||||
ModelSet IModelSet
|
||||
|
||||
BatchListSize int
|
||||
@@ -54,7 +54,7 @@ func GetModels(opts *GetModelsOptions) error {
|
||||
tstr := timeutils.MysqlTime(time)
|
||||
return fmt.Sprintf("updated_at.ge('%s')", tstr)
|
||||
}
|
||||
setNextListParams := func(params *jsonutils.JSONDict, lastUpdatedAt time.Time, lastResult *modules.ListResult) (time.Time, error) {
|
||||
setNextListParams := func(params *jsonutils.JSONDict, lastUpdatedAt time.Time, lastResult *modulebase.ListResult) (time.Time, error) {
|
||||
// NOTE: the updated_at field has second-level resolution.
|
||||
// If they all have the same date...
|
||||
var max time.Time
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -0,0 +1 @@
|
||||
package modulebase // import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
@@ -12,12 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -182,7 +182,7 @@ func ensureModuleNotRegistered(mod, newMod BaseManagerInterface) {
|
||||
}
|
||||
}
|
||||
|
||||
func _register(version string, mod BaseManagerInterface) {
|
||||
func Register(version string, mod BaseManagerInterface) {
|
||||
if modules == nil {
|
||||
modules = make(map[string]map[string][]BaseManagerInterface)
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func _register(version string, mod BaseManagerInterface) {
|
||||
// modtable[mod.KeyString()] = append(mods, mod)
|
||||
}
|
||||
|
||||
func _registerJointModule(version string, mod BaseManagerInterface) {
|
||||
func RegisterJointModule(version string, mod BaseManagerInterface) {
|
||||
jointMod, ok := mod.(JointManager)
|
||||
if ok { // also a joint manager
|
||||
jointKey := _getJointKey(jointMod.MasterManager(), jointMod.SlaveManager())
|
||||
@@ -233,7 +233,7 @@ func registerAllJointModules() {
|
||||
for version := range modules {
|
||||
for modname := range modules[version] {
|
||||
for i := range modules[version][modname] {
|
||||
_registerJointModule(version, modules[version][modname][i])
|
||||
RegisterJointModule(version, modules[version][modname][i])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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 modulebase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func GetPProfByType(s *mcclient.ClientSession, serviceType string, profileType string, seconds int) (io.Reader, error) {
|
||||
man := &BaseManager{serviceType: serviceType}
|
||||
if seconds <= 0 {
|
||||
seconds = 15
|
||||
}
|
||||
resp, err := man.rawBaseUrlRequest(s, "GET", fmt.Sprintf("/debug/pprof/%s?seconds=%d", profileType, seconds), nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.Body, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// 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 modulebase
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func GetProjectResources(s *mcclient.ClientSession, serviceType string) (jsonutils.JSONObject, error) {
|
||||
man := &BaseManager{serviceType: serviceType}
|
||||
resp, err := man.rawRequest(s, "GET", "/project-resources", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonutils.Parse(body)
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
@@ -0,0 +1,54 @@
|
||||
package modulebase
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
)
|
||||
|
||||
func Get(manager ResourceManager, session *mcclient.ClientSession, path string, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._get(session, path, respKey)
|
||||
}
|
||||
|
||||
func List(manager ResourceManager, session *mcclient.ClientSession, path, respKey string) (*ListResult, error) {
|
||||
return manager._list(session, path, respKey)
|
||||
}
|
||||
|
||||
func Head(manager ResourceManager, session *mcclient.ClientSession, path string, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._head(session, path, respKey)
|
||||
}
|
||||
|
||||
func Post(manager ResourceManager, session *mcclient.ClientSession, path string, body jsonutils.JSONObject, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._post(session, path, body, respKey)
|
||||
}
|
||||
|
||||
func Put(manager ResourceManager, session *mcclient.ClientSession, path string, body jsonutils.JSONObject, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._put(session, path, body, respKey)
|
||||
}
|
||||
|
||||
func Patch(manager ResourceManager, session *mcclient.ClientSession, path string, body jsonutils.JSONObject, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._patch(session, path, body, respKey)
|
||||
}
|
||||
|
||||
func Delete(manager ResourceManager, session *mcclient.ClientSession, path string, body jsonutils.JSONObject, respKey string) (jsonutils.JSONObject, error) {
|
||||
return manager._delete(session, path, body, respKey)
|
||||
}
|
||||
|
||||
func RawRequest(manager ResourceManager, session *mcclient.ClientSession,
|
||||
method httputils.THttpMethod, path string,
|
||||
header http.Header, body io.Reader) (*http.Response, error) {
|
||||
return session.RawVersionRequest(manager.serviceType, manager.endpointType,
|
||||
method, manager.versionedURL(path),
|
||||
header, body, manager.GetApiVersion())
|
||||
}
|
||||
|
||||
func JsonRequest(manager ResourceManager, session *mcclient.ClientSession,
|
||||
method httputils.THttpMethod, path string,
|
||||
header http.Header, body jsonutils.JSONObject) (http.Header, jsonutils.JSONObject, error) {
|
||||
return session.JSONVersionRequest(manager.serviceType, manager.endpointType,
|
||||
method, manager.versionedURL(path),
|
||||
header, body, manager.GetApiVersion())
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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 modulebase
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func GetVersion(s *mcclient.ClientSession, serviceType string) (string, error) {
|
||||
man := NewBaseManager(serviceType, "", "", nil, nil)
|
||||
resp, err := man.rawBaseUrlRequest(s, "GET", "/version", nil, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
@@ -58,7 +59,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func cacheKey(manager Manager, idstr string) string {
|
||||
func cacheKey(manager modulebase.Manager, idstr string) string {
|
||||
return fmt.Sprintf("%s-%s", manager.KeyString(), idstr)
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ func (cm *sCachedResourceManager) getUnlocked(key string, alloc bool) *sCachedRe
|
||||
return &obj
|
||||
}
|
||||
|
||||
func (cm *sCachedResourceManager) getById(manager Manager, session *mcclient.ClientSession, idstr string) (jsonutils.JSONObject, error) {
|
||||
func (cm *sCachedResourceManager) getById(manager modulebase.Manager, session *mcclient.ClientSession, idstr string) (jsonutils.JSONObject, error) {
|
||||
key := cacheKey(manager, idstr)
|
||||
cacheObj := cm.getLocked(key)
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
package etcd
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
func NewCloudirManager(keyword, keywordPlural string, columns, adminColumns []string) modules.ResourceManager {
|
||||
func NewCloudirManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modules.NewResourceManager(
|
||||
"cloudir",
|
||||
keyword,
|
||||
|
||||
@@ -14,10 +14,13 @@
|
||||
|
||||
package etcd
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
)
|
||||
|
||||
type SServiceRegistryManager struct {
|
||||
modules.ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var ServiceRegistryManager SServiceRegistryManager
|
||||
|
||||
@@ -19,16 +19,16 @@ import (
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ResourceManager struct {
|
||||
*modules.ResourceManager
|
||||
*modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func NewResourceManager(keyword, keywordPlural string, columns, adminColumns *Columns) *ResourceManager {
|
||||
man := &modules.ResourceManager{
|
||||
BaseManager: *modules.NewBaseManager("k8s", "", "", columns.Array(), adminColumns.Array()),
|
||||
man := &modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("k8s", "", "", columns.Array(), adminColumns.Array()),
|
||||
Keyword: keyword,
|
||||
KeywordPlural: keywordPlural,
|
||||
}
|
||||
|
||||
@@ -14,189 +14,143 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
/*
|
||||
添加新manager注意事项:
|
||||
1. version字段 -- 在endpoint中注册的url如果携带版本。例如http://x.x.x.x/api/v1,那么必须标注对应version字段。否者可能导致yunionapi报资源not found的错误。
|
||||
*/
|
||||
|
||||
func NewResourceManager(serviceType string, keyword, keywordPlural string,
|
||||
columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: serviceType},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager(serviceType, "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewComputeManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "compute"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewComputeManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("compute", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewActionManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "log"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewActionManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("log", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewMonitorManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
version: "v1",
|
||||
serviceType: "servicetree"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewMonitorManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("servicetree", "", "v1", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewCloudwatcherManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
version: "v1",
|
||||
serviceType: "cloudwatcher"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewCloudwatcherManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("cloudwatcher", "", "v1", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewNotifyManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
version: "v1",
|
||||
serviceType: "notify"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewNotifyManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("notify", "", "v1", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewJointComputeManager(keyword, keywordPlural string, columns, adminColumns []string, master, slave Manager) JointResourceManager {
|
||||
return JointResourceManager{
|
||||
func NewJointComputeManager(keyword, keywordPlural string, columns, adminColumns []string, master, slave modulebase.Manager) modulebase.JointResourceManager {
|
||||
return modulebase.JointResourceManager{
|
||||
ResourceManager: NewComputeManager(keyword, keywordPlural, columns, adminColumns),
|
||||
Master: master,
|
||||
Slave: slave}
|
||||
}
|
||||
|
||||
func NewJointMonitorManager(keyword, keywordPlural string, columns, adminColumns []string, master, slave Manager) JointResourceManager {
|
||||
return JointResourceManager{
|
||||
func NewJointMonitorManager(keyword, keywordPlural string, columns, adminColumns []string, master, slave modulebase.Manager) modulebase.JointResourceManager {
|
||||
return modulebase.JointResourceManager{
|
||||
ResourceManager: NewMonitorManager(keyword, keywordPlural, columns, adminColumns),
|
||||
Master: master,
|
||||
Slave: slave}
|
||||
}
|
||||
|
||||
func NewIdentityManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
endpointType: "adminURL",
|
||||
version: "v2.0",
|
||||
serviceType: "identity"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewIdentityManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("identity", "adminURL", "v2.0", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewIdentityV3Manager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
endpointType: "adminURL",
|
||||
version: "v3",
|
||||
serviceType: "identity"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewIdentityV3Manager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("identity", "adminURL", "v3", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewImageManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
endpointType: "",
|
||||
version: "v1",
|
||||
serviceType: "image"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewImageManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("image", "", "v1", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewVNCProxyManager() ResourceManager {
|
||||
return ResourceManager{BaseManager: BaseManager{serviceType: "vncproxy"},
|
||||
func NewVNCProxyManager() modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{BaseManager: *modulebase.NewBaseManager("vncproxy", "", "", nil, nil),
|
||||
Keyword: "vncproxy", KeywordPlural: "vncproxy"}
|
||||
}
|
||||
|
||||
func NewITSMManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "itsm"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewITSMManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("itsm", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewSchedulerManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "scheduler"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewSchedulerManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("scheduler", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewMeterManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
version: "v1",
|
||||
serviceType: "meter"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewMeterManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("meter", "", "v1", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewMeterAlertManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "meteralert"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewMeterAlertManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("meteralert", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewYunionAgentManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "yunionagent"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewYunionAgentManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("yunionagent", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewYunionConfManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "yunionconf"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewYunionConfManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("yunionconf", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewAutoUpdateManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "autoupdate"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewAutoUpdateManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("autoupdate", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewWebsocketManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "websocket"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewWebsocketManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("websocket", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewCloudmetaManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "cloudmeta"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewCloudmetaManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("cloudmeta", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
func NewAnsibleManager(keyword, keywordPlural string, columns, adminColumns []string) ResourceManager {
|
||||
return ResourceManager{
|
||||
BaseManager: BaseManager{columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
serviceType: "ansible"},
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
func NewAnsibleManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("ansible", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
AccountBalances ResourceManager
|
||||
AccountBalances modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Actions ResourceManager
|
||||
Actions modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -18,16 +18,17 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type AlarmEventsManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func (this *AlarmEventsManager) DoBatchUpdate(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
path := "/alarm_events"
|
||||
|
||||
return this._put(s, path, params, "alarm_events")
|
||||
return modulebase.Put(this.ResourceManager, s, path, params, "alarm_events")
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
AlarmLogs ResourceManager
|
||||
AlarmLogs modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Alarms ResourceManager
|
||||
Alarms modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
AlarmTemplateAlarms JointResourceManager
|
||||
AlarmTemplateAlarms modulebase.JointResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
AlarmTemplates ResourceManager
|
||||
AlarmTemplates modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
type AnsiblePlaybookManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Baremetalagents ResourceManager
|
||||
Baremetalagents modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Baremetalnetworks JointResourceManager
|
||||
Baremetalnetworks modulebase.JointResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Baremetalstorages JointResourceManager
|
||||
Baremetalstorages modulebase.JointResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillAnalysises ResourceManager
|
||||
BillAnalysises modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillBalances ResourceManager
|
||||
BillBalances modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillCloudChecks ResourceManager
|
||||
BillCloudChecks modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillConditions ResourceManager
|
||||
BillConditions modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillDetails ResourceManager
|
||||
BillDetails modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
BillResources ResourceManager
|
||||
BillResources modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -23,11 +23,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
)
|
||||
|
||||
type SBucketManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func (manager *SBucketManager) Upload(s *mcclient.ClientSession, bucketId string, key string, body io.Reader, contLength int64, contType string, storageClass string, acl string) error {
|
||||
@@ -51,7 +52,7 @@ func (manager *SBucketManager) Upload(s *mcclient.ClientSession, bucketId string
|
||||
headers.Set(api.BUCKET_UPLOAD_OBJECT_ACL_HEADER, acl)
|
||||
}
|
||||
|
||||
resp, err := manager.rawRequest(s, method, path, headers, body)
|
||||
resp, err := modulebase.RawRequest(manager.ResourceManager, s, method, path, headers, body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "rawRequest")
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Cachedimages ResourceManager
|
||||
Cachedimages modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -18,13 +18,14 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type SCapabilityManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*ListResult, error) {
|
||||
func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) {
|
||||
url := "/capabilities"
|
||||
if params != nil {
|
||||
qs := params.QueryString()
|
||||
@@ -32,11 +33,11 @@ func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils
|
||||
url += "?" + qs
|
||||
}
|
||||
}
|
||||
body, err := this._get(s, url, "")
|
||||
body, err := modulebase.Get(this.ResourceManager, s, url, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := ListResult{Data: []jsonutils.JSONObject{body}}
|
||||
result := modulebase.ListResult{Data: []jsonutils.JSONObject{body}}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
CloudSkuRates ResourceManager
|
||||
CloudSkuRates modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Cloudaccounts ResourceManager
|
||||
Cloudaccounts modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
CloudproviderregionManager JointResourceManager
|
||||
CloudproviderregionManager modulebase.JointResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
Cloudproviders ResourceManager
|
||||
Cloudproviders modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -20,10 +20,11 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type SCloudregionManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
var (
|
||||
ContactGroups ResourceManager
|
||||
ContactGroups modulebase.ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -20,10 +20,11 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ContactsManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
func (this *ContactsManager) PerformActionWithArrayParams(s *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
@@ -34,13 +35,13 @@ func (this *ContactsManager) PerformActionWithArrayParams(s *mcclient.ClientSess
|
||||
body.Add(params, this.KeywordPlural)
|
||||
}
|
||||
|
||||
return this._post(s, path, body, this.Keyword)
|
||||
return modulebase.Post(this.ResourceManager, s, path, body, this.Keyword)
|
||||
}
|
||||
|
||||
func (this *ContactsManager) DoBatchDeleteContacts(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
path := "/contacts/delete-contact"
|
||||
|
||||
return this._post(s, path, params, this.Keyword)
|
||||
return modulebase.Post(this.ResourceManager, s, path, params, this.Keyword)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
|
||||
package modules
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
|
||||
type CopyrightManager struct {
|
||||
ResourceManager
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user