mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix(climc): add version list command
This commit is contained in:
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -14,5 +14,5 @@ assignees: ''
|
||||
- OS (e.g. `cat /etc/os-release`):
|
||||
- Kernel (e.g. `uname -a`):
|
||||
<!--
|
||||
- Version (e.g. `kubectl get oc -n onecloud -o yaml | grep -C 3 version`):
|
||||
- Version (e.g. `climc version-list`):
|
||||
-->
|
||||
|
||||
@@ -17,6 +17,11 @@ package misc
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
@@ -35,6 +40,43 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type VersionListOptions struct {
|
||||
}
|
||||
|
||||
R(&VersionListOptions{}, "version-list", "query all backend service version", func(s *mcclient.ClientSession, args *VersionListOptions) error {
|
||||
services := []jsonutils.JSONObject{}
|
||||
params := map[string]interface{}{}
|
||||
for {
|
||||
params["offset"] = len(services)
|
||||
resp, err := modules.ServicesV3.List(s, jsonutils.Marshal(params))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
services = append(services, resp.Data...)
|
||||
if len(services) >= resp.Total {
|
||||
break
|
||||
}
|
||||
}
|
||||
vers := map[string]string{}
|
||||
for _, service := range services {
|
||||
serviceType, _ := service.GetString("type")
|
||||
if utils.IsInStringArray(serviceType, []string{"offlinecloudmeta"}) {
|
||||
continue
|
||||
}
|
||||
ver, err := modules.GetVersion(s, serviceType)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound || errors.Cause(err) == errors.ErrConnectRefused {
|
||||
continue
|
||||
}
|
||||
vers[serviceType] = err.Error()
|
||||
} else {
|
||||
vers[serviceType] = ver
|
||||
}
|
||||
}
|
||||
printObject(jsonutils.Marshal(vers))
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.VersionListOptions{}, "yunionagent-version-list", "show versions of backend services", func(s *mcclient.ClientSession, opts *options.VersionListOptions) error {
|
||||
if len(opts.Region) == 0 {
|
||||
opts.Region = s.GetRegion()
|
||||
|
||||
Reference in New Issue
Block a user