diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f716619cc7..2b9039e9d8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -14,5 +14,5 @@ assignees: '' - OS (e.g. `cat /etc/os-release`): - Kernel (e.g. `uname -a`): diff --git a/cmd/climc/shell/misc/version.go b/cmd/climc/shell/misc/version.go index 6a47bafcf7..b4079de5a1 100644 --- a/cmd/climc/shell/misc/version.go +++ b/cmd/climc/shell/misc/version.go @@ -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()