mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
climc: 添加lblistener{,rule}-backend-status命令
This commit is contained in:
@@ -89,4 +89,11 @@ func init() {
|
||||
printObject(lblistenerrule)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerListenerRuleGetBackendStatusOptions{}, "lblistenerrule-backend-status", "Get lblistenerrule backend status", func(s *mcclient.ClientSession, opts *options.LoadbalancerListenerRuleGetBackendStatusOptions) error {
|
||||
backendStatus, err := modules.LoadbalancerListenerRules.GetSpecific(s, opts.ID, "backend-status", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return printLbBackendStatus(backendStatus)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,13 +15,44 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func printLbBackendStatus(backendStatus jsonutils.JSONObject) error {
|
||||
arr, ok := backendStatus.(*jsonutils.JSONArray)
|
||||
if !ok {
|
||||
return fmt.Errorf("want json array, got %s", backendStatus.String())
|
||||
}
|
||||
objList, err := arr.GetArray()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listResult := &modulebase.ListResult{
|
||||
Data: objList,
|
||||
}
|
||||
columns := []string{
|
||||
"id",
|
||||
"name",
|
||||
"backend_type",
|
||||
"backend_id",
|
||||
"address",
|
||||
"port",
|
||||
"weight",
|
||||
"check_time",
|
||||
"check_status",
|
||||
"check_code",
|
||||
}
|
||||
printList(listResult, columns)
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
R(&options.LoadbalancerListenerCreateOptions{}, "lblistener-create", "Create lblistener", func(s *mcclient.ClientSession, opts *options.LoadbalancerListenerCreateOptions) error {
|
||||
@@ -99,4 +130,11 @@ func init() {
|
||||
printObject(lblistener)
|
||||
return nil
|
||||
})
|
||||
R(&options.LoadbalancerListenerGetBackendStatusOptions{}, "lblistener-backend-status", "Get lblistene backend status", func(s *mcclient.ClientSession, opts *options.LoadbalancerListenerGetBackendStatusOptions) error {
|
||||
backendStatus, err := modules.LoadbalancerListeners.GetSpecific(s, opts.ID, "backend-status", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return printLbBackendStatus(backendStatus)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ type LoadbalancerListenerRuleDeleteOptions struct {
|
||||
ID string `json:"-"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleGetBackendStatusOptions struct {
|
||||
ID string `json:"-"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleActionStatusOptions struct {
|
||||
ID string `json:"-"`
|
||||
Status string `choices:"enabled|disabled"`
|
||||
|
||||
@@ -184,6 +184,10 @@ type LoadbalancerListenerActionStatusOptions struct {
|
||||
Status string `choices:"enabled|disabled"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerGetBackendStatusOptions struct {
|
||||
ID string `json:"-"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerActionSyncStatusOptions struct {
|
||||
ID string `json:"-"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user