mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.0.0 -> release/2.1.0
* commit '6b4261b7345367a5df59e523e24be18a4d36bca0': climc: server-rebuild-root support keypair and passwd
This commit is contained in:
@@ -113,9 +113,9 @@ func init() {
|
||||
if len(args.PublicKey) > 0 {
|
||||
content, e := ioutil.ReadFile(args.PublicKey)
|
||||
if e != nil {
|
||||
params.Add(jsonutils.NewString(args.PublicKey), "public_Key")
|
||||
params.Add(jsonutils.NewString(args.PublicKey), "public_key")
|
||||
} else {
|
||||
params.Add(jsonutils.NewString(string(content)), "public_Key")
|
||||
params.Add(jsonutils.NewString(string(content)), "public_key")
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("no public key provided")
|
||||
|
||||
@@ -652,14 +652,26 @@ func init() {
|
||||
})
|
||||
|
||||
type ServerRebuildRootOptions struct {
|
||||
SERVER string `help:"Server to rebuild root"`
|
||||
Image string `help:"New root Image template ID"`
|
||||
SERVER string `help:"Server to rebuild root"`
|
||||
AutoStart bool `help:"Auto start server after it is created"`
|
||||
Image string `help:"New root Image template ID"`
|
||||
Keypair string `help:"ssh Keypair used for login"`
|
||||
Password string `help:"Default user password"`
|
||||
}
|
||||
R(&ServerRebuildRootOptions{}, "server-rebuild-root", "Rebuild VM root image with new template", func(s *mcclient.ClientSession, args *ServerRebuildRootOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
if len(args.Image) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Image), "image_id")
|
||||
}
|
||||
if args.AutoStart {
|
||||
params.Add(jsonutils.JSONTrue, "auto_start")
|
||||
}
|
||||
if args.Keypair != "" {
|
||||
params.Add(jsonutils.NewString(args.Keypair), "keypair")
|
||||
}
|
||||
if args.Password != "" {
|
||||
params.Add(jsonutils.NewString(args.Password), "password")
|
||||
}
|
||||
srv, err := modules.Servers.PerformAction(s, args.SERVER, "rebuild-root", params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user