Automatic merge from release/2.6.0 -> release/2.7.0

* commit 'f6fedf390f43e2ea1c0ef55b67f00bc7bdd5dfad':
  fix: 1. remote file will retry glance if peer url is not available 2. ssh authorized keys ends with \n
This commit is contained in:
邱剑
2019-03-18 09:04:53 +08:00
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -2838,6 +2838,7 @@ func (self *SHost) AllowPerformAddNetif(ctx context.Context,
}
func (self *SHost) PerformAddNetif(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
log.Debugf("add_netif %s", data)
mac, _ := data.GetString("mac")
if len(mac) == 0 || len(netutils.FormatMacAddr(mac)) == 0 {
return nil, httperrors.NewBadRequestError("Invaild mac address")
+1 -1
View File
@@ -182,5 +182,5 @@ func MergeAuthorizedKeys(oldKeys string, pubkeys *sshkeys.SSHKeys) string {
for _, val := range allkeys {
keys = append(keys, val)
}
return strings.Join(keys, "\n")
return strings.Join(keys, "\n") + "\n"
}
@@ -147,7 +147,19 @@ func (r *SRemoteFile) fetch(preChksum string) bool {
return fetchSucc
}
// retry download
func (r *SRemoteFile) download(getData bool, preChksum string) bool {
result := r.downloadInternal(getData, preChksum)
if !result && len(r.downloadUrl) > 0 {
log.Errorf("download from cached url %s failed, try direct download from %s ...", r.downloadUrl, r.url)
r.downloadUrl = ""
result = r.downloadInternal(getData, preChksum)
}
return result
}
func (r *SRemoteFile) downloadInternal(getData bool, preChksum string) bool {
os.Remove(r.tmpPath)
fi, err := os.Create(r.tmpPath)
if err != nil {
log.Errorln(err)