climc: add commands server-make-sshable, server-make-sshable-cmd

This commit is contained in:
Yousong Zhou
2021-04-15 17:51:16 +08:00
parent 554e03fde8
commit 51cd8bd2f6
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -85,6 +85,7 @@ func init() {
cmd.Perform("save-template", new(options.ServerSaveImageOptions))
cmd.Perform("remote-update", new(options.ServerRemoteUpdateOptions))
cmd.Perform("create-eip", &options.ServerCreateEipOptions{})
cmd.Perform("make-sshable", &options.ServerMakeSshableOptions{})
cmd.Get("vnc", new(options.ServerIdOptions))
cmd.Get("desc", new(options.ServerIdOptions))
@@ -92,6 +93,7 @@ func init() {
cmd.Get("iso", new(options.ServerIdOptions))
cmd.Get("create-params", new(options.ServerIdOptions))
cmd.Get("sshable", new(options.ServerIdOptions))
cmd.Get("make-sshable-cmd", new(options.ServerIdOptions))
cmd.Get("change-owner-candidate-domains", new(options.ServerChangeOwnerCandidateDomainsOptions))
type ServerTaskShowOptions struct {
+18
View File
@@ -1089,3 +1089,21 @@ type ServerCreateEipOptions struct {
func (opts *ServerCreateEipOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type ServerMakeSshableOptions struct {
BaseIdOptions
User string `help:"ssh username for ssh connection" default:"root"`
PrivateKey string `help:"ssh privatekey for ssh connection"`
Password string `help:"ssh password for ssh connection"`
}
func (opts *ServerMakeSshableOptions) Params() (jsonutils.JSONObject, error) {
if opts.User == "" {
return nil, fmt.Errorf("ssh username must be set")
}
if opts.PrivateKey == "" && opts.Password == "" {
return nil, fmt.Errorf("either --private-key or --password must be set")
}
return jsonutils.Marshal(opts), nil
}