Automatic merge from release/2.6.0 -> release/2.7.0

* commit '246f47a988124837ceade544121497b8d3c14e95':
  fix purge backup guest
  set http connect timeout
  set default http client Timeout
This commit is contained in:
邱剑
2019-02-25 11:21:08 +08:00
5 changed files with 25 additions and 7 deletions
+5 -1
View File
@@ -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
}
+1 -1
View File
@@ -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))
+12 -3
View File
@@ -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
}
+1 -1
View File
@@ -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 {
+6 -1
View File
@@ -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}
}