climc: server-deploy password

This commit is contained in:
Zexi Li
2018-08-16 18:47:10 +08:00
parent ecfd32480b
commit cf39f5ed44
+8
View File
@@ -139,6 +139,7 @@ func init() {
Net []string `help:"Network descriptions" metavar:"NETWORK"`
IsolatedDevice []string `help:"Isolated device model or ID" metavar:"ISOLATED_DEVICE"`
Keypair string `help:"SSH Keypair"`
Password string `help:"Default user password"`
Iso string `help:"ISO image ID" metavar:"IMAGE_ID"`
Ncpu int64 `help:"#CPU cores of VM server, default 1" default:"1" metavar:"<SERVER_CPU_COUNT>"`
Vga string `help:"VGA driver" choices:"std|vmware|cirrus|qxl"`
@@ -192,6 +193,9 @@ func init() {
if args.NoAccountInit {
params.Add(jsonutils.JSONFalse, "reset_password")
}
if args.Password != "" {
params.Add(jsonutils.NewString(args.Password), "password")
}
if len(args.Vdi) > 0 {
params.Add(jsonutils.NewString(args.Vdi), "vdi")
}
@@ -484,6 +488,7 @@ func init() {
DeleteKeypair bool `help:"Remove ssh Keypairs"`
Deploy []string `help:"Specify deploy files in virtual server file system"`
ResetPassword bool `help:"Force reset password"`
Password string `help:"Default user password"`
}
R(&ServerDeployOptions{}, "server-deploy", "Deploy hostname and keypair to a stopped virtual server", func(s *mcclient.ClientSession, args *ServerDeployOptions) error {
params := jsonutils.NewDict()
@@ -501,6 +506,9 @@ func init() {
if args.ResetPassword {
params.Add(jsonutils.JSONTrue, "reset_password")
}
if args.Password != "" {
params.Add(jsonutils.NewString(args.Password), "password")
}
srv, e := modules.Servers.PerformAction(s, args.ID, "deploy", params)
if e != nil {
return e