autoupdate support for onecloud

This commit is contained in:
Zhang Dongliang
2018-09-28 11:24:51 +08:00
parent 5f6033fcae
commit 1bf9478693
128 changed files with 3267 additions and 725 deletions
+47
View File
@@ -0,0 +1,47 @@
package shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type SUpdateListOptions struct {
options.BaseListOptions
Region string `help:"cloud region ID or Name"`
}
R(&SUpdateListOptions{}, "update-list", "List updates", func(s *mcclient.ClientSession, args *SUpdateListOptions) error {
// TODO filer by region
result, err := modules.Updates.List(s, nil)
if err != nil {
return err
}
printList(result, modules.Updates.GetColumns(s))
return nil
})
type SUpdatePerformOptions struct {
Cmp bool `help:"update all the compute nodes automatically"`
}
R(&SUpdatePerformOptions{}, "update-perform", "Update the Controler", func(s *mcclient.ClientSession, args *SUpdatePerformOptions) error {
params := jsonutils.NewDict()
if args.Cmp {
params.Add(jsonutils.JSONTrue, "cmp")
}
result, err := modules.Updates.List(s, nil)
if err != nil {
return err
}
modules.Updates.DoUpdate(s, params)
printList(result, modules.Updates.GetColumns(s))
return nil
})
}