diff --git a/cmd/climc/shell/servers.go b/cmd/climc/shell/servers.go index 27cbae80de..be6db6bec8 100644 --- a/cmd/climc/shell/servers.go +++ b/cmd/climc/shell/servers.go @@ -167,7 +167,11 @@ func init() { }) R(&options.ServerDeleteBackupOptions{}, "server-delete-backup", "Guest delete backup", func(s *mcclient.ClientSession, opts *options.ServerDeleteBackupOptions) error { - ret, err := modules.Servers.PerformAction(s, opts.ID, "delete-backup", nil) + params, err := options.StructToParams(opts) + if err != nil { + return err + } + ret, err := modules.Servers.PerformAction(s, opts.ID, "delete-backup", params) if err != nil { return err } diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index e15a3da332..77c896bef4 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -2383,7 +2383,7 @@ func (self *SGuest) PerformDeleteBackup(ctx context.Context, userCred mcclient.T } taskData := jsonutils.NewDict() - taskData.Set("pruge", jsonutils.NewBool(jsonutils.QueryBoolean(data, "purge", false))) + taskData.Set("purge", jsonutils.NewBool(jsonutils.QueryBoolean(data, "purge", false))) taskData.Set("host_id", jsonutils.NewString(self.BackupHostId)) taskData.Set("failed_status", jsonutils.NewString(VM_BACKUP_DELETE_FAILED)) diff --git a/pkg/mcclient/mcclient.go b/pkg/mcclient/mcclient.go index eeec2ccb1a..cc8fdc4e87 100644 --- a/pkg/mcclient/mcclient.go +++ b/pkg/mcclient/mcclient.go @@ -5,8 +5,10 @@ import ( "crypto/tls" "fmt" "io" + "net" "net/http" "strings" + "time" "yunion.io/x/jsonutils" "yunion.io/x/log" @@ -42,12 +44,19 @@ func NewClient(authUrl string, timeout int, debug bool, insecure bool, certFile, tr := &http.Transport{ TLSClientConfig: tlsConf, + DialContext: (&net.Dialer{ + Timeout: 5 * time.Second, + }).DialContext, + TLSHandshakeTimeout: 10 * time.Second, } client := Client{authUrl: authUrl, - timeout: timeout, - debug: debug, - httpconn: &http.Client{Transport: tr}} + timeout: timeout, + debug: debug, + httpconn: &http.Client{ + Transport: tr, + }, + } return &client } diff --git a/pkg/mcclient/options/servers.go b/pkg/mcclient/options/servers.go index ba7b82c87e..6e8150fd28 100644 --- a/pkg/mcclient/options/servers.go +++ b/pkg/mcclient/options/servers.go @@ -47,7 +47,7 @@ type ServerIdsOptions struct { type ServerDeleteBackupOptions struct { ID string `help:"ID of the server" json:"-"` - Purge bool `help:"Purge Guest Backup" json:"purge"` + Purge *bool `help:"Purge Guest Backup" json:"purge"` } type ServerShowOptions struct { diff --git a/pkg/util/httputils/httputils.go b/pkg/util/httputils/httputils.go index b13e1a8f76..8e62b50116 100644 --- a/pkg/util/httputils/httputils.go +++ b/pkg/util/httputils/httputils.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "net/http" "net/url" "os" @@ -102,7 +103,11 @@ func GetAddrPort(urlStr string) (string, int, error) { func GetClient(insecure bool) *http.Client { tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure}, + DialContext: (&net.Dialer{ + Timeout: 5 * time.Second, + }).DialContext, + TLSHandshakeTimeout: 10 * time.Second, + TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure}, } return &http.Client{Transport: tr} }