mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge branch 'release/2.5.0' of ssh://git.yunion.io/~qiujian/onecloud into hotfix/qj-vmware-sync-skip-failed-host
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ type BaseOptions struct {
|
||||
Debug bool `help:"Show debug information"`
|
||||
Version bool `help:"Show version"`
|
||||
Timeout int `default:"600" help:"Number of seconds to wait for a response"`
|
||||
Insecure bool `default:"false" help:"Allow skip server cert verification if URL is https" short-token:"k"`
|
||||
Insecure bool `default:"$YUNION_INSECURE|false" help:"Allow skip server cert verification if URL is https" short-token:"k"`
|
||||
|
||||
CertFile string `default:"$YUNION_CERT_FILE" help:"certificate file"`
|
||||
KeyFile string `default:"$YUNION_KEY_FILE" help:"private key file"`
|
||||
|
||||
@@ -580,5 +580,9 @@ func (self *SManagedVirtualizedGuestDriver) RequestRenewInstance(guest *models.S
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
err = iVM.Refresh()
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return iVM.GetExpiredAt(), nil
|
||||
}
|
||||
|
||||
@@ -427,6 +427,7 @@ func (self *SCloudaccount) ImportSubAccount(ctx context.Context, userCred mcclie
|
||||
|
||||
newCloudprovider := SCloudprovider{}
|
||||
newCloudprovider.Account = subAccount.Account
|
||||
newCloudprovider.Secret = self.Secret
|
||||
newCloudprovider.CloudaccountId = self.Id
|
||||
newCloudprovider.Provider = self.Provider
|
||||
newCloudprovider.AccessUrl = self.AccessUrl
|
||||
@@ -685,6 +686,7 @@ func migrateCloudprovider(cloudprovider *SCloudprovider) error {
|
||||
if err == sql.ErrNoRows {
|
||||
account.AccessUrl = cloudprovider.AccessUrl
|
||||
account.Account = mainAccount
|
||||
account.Secret = cloudprovider.Secret
|
||||
account.LastSync = cloudprovider.LastSync
|
||||
// account.Sysinfo = cloudprovider.Sysinfo
|
||||
account.Provider = cloudprovider.Provider
|
||||
|
||||
@@ -1201,6 +1201,9 @@ func (self *SGuest) moreExtraInfo(extra *jsonutils.JSONDict) *jsonutils.JSONDict
|
||||
}
|
||||
}*/
|
||||
|
||||
extra.Add(self.getDisksInfoDetails(), "disks_info")
|
||||
extra.Add(jsonutils.NewString(self.getIsolatedDeviceDetails()), "isolated_devices")
|
||||
|
||||
host := self.GetHost()
|
||||
if host != nil {
|
||||
info := host.getCloudProviderInfo()
|
||||
@@ -1225,7 +1228,6 @@ func (self *SGuest) GetExtraDetails(ctx context.Context, userCred mcclient.Token
|
||||
|
||||
extra.Add(jsonutils.NewString(self.getNetworksDetails()), "networks")
|
||||
extra.Add(jsonutils.NewString(self.getDisksDetails()), "disks")
|
||||
extra.Add(self.getDisksInfoDetails(), "disks_info")
|
||||
extra.Add(jsonutils.NewInt(int64(self.getDiskSize())), "disk")
|
||||
cdrom := self.getCdrom()
|
||||
if cdrom != nil {
|
||||
@@ -1241,7 +1243,6 @@ func (self *SGuest) GetExtraDetails(ctx context.Context, userCred mcclient.Token
|
||||
|
||||
extra.Add(jsonutils.NewString(strings.Join(self.getIPs(), ",")), "ips")
|
||||
extra.Add(jsonutils.NewString(self.getSecurityGroupsRules()), "security_rules")
|
||||
extra.Add(jsonutils.NewString(self.getIsolatedDeviceDetails()), "isolated_devices")
|
||||
osName := self.GetOS()
|
||||
if len(osName) > 0 {
|
||||
extra.Add(jsonutils.NewString(osName), "os_name")
|
||||
@@ -3430,6 +3431,7 @@ func (manager *SGuestManager) DeleteExpiredPrepaidServers(ctx context.Context, u
|
||||
}
|
||||
for i := 0; i < len(guests); i += 1 {
|
||||
// fake delete expired prepaid servers
|
||||
guests[i].SetDisableDelete(false)
|
||||
guests[i].StartDeleteGuestTask(ctx, userCred, "", false, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -726,3 +726,11 @@ func (self *SHost) DoSaveRenewInfo(ctx context.Context, userCred mcclient.TokenC
|
||||
db.OpsLog.LogEvent(self, db.ACT_RENEW, self.GetShortDesc(ctx), userCred)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHost) SyncWithRealPrepaidVM(ctx context.Context, userCred mcclient.TokenCredential, iVM cloudprovider.ICloudVM) error {
|
||||
exp := iVM.GetExpiredAt()
|
||||
if self.ExpiredAt != exp {
|
||||
return self.DoSaveRenewInfo(ctx, userCred, nil, &exp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1637,6 +1637,10 @@ func (self *SHost) SyncHostVMs(ctx context.Context, userCred mcclient.TokenCrede
|
||||
vhost := HostManager.GetHostByRealExternalId(added[i].GetGlobalId())
|
||||
if vhost != nil {
|
||||
// this recycle vm is not build yet, skip synchronize
|
||||
err = vhost.SyncWithRealPrepaidVM(ctx, userCred, added[i])
|
||||
if err != nil {
|
||||
syncResult.AddError(err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ func (acl *SLoadbalancerAcl) SyncWithCloudLoadbalancerAcl(ctx context.Context, u
|
||||
if projectSync && len(projectId) > 0 {
|
||||
acl.ProjectId = projectId
|
||||
}
|
||||
|
||||
acl.AclEntries = &SLoadbalancerAclEntries{}
|
||||
return aclEntries.Unmarshal(acl.AclEntries)
|
||||
})
|
||||
return err
|
||||
|
||||
@@ -2,11 +2,11 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"fmt"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
@@ -73,6 +73,8 @@ func (self *PrepaidRecycleHostRenewTask) OnInit(ctx context.Context, obj db.ISta
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("expire before %s", iVM.GetExpiredAt())
|
||||
|
||||
err = iVM.Renew(bc)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("iVM.Renew fail %s", err)
|
||||
@@ -81,6 +83,16 @@ func (self *PrepaidRecycleHostRenewTask) OnInit(ctx context.Context, obj db.ISta
|
||||
return
|
||||
}
|
||||
|
||||
err = iVM.Refresh()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("refresh after renew fail %s", err)
|
||||
log.Errorf(msg)
|
||||
self.SetStageFailed(ctx, msg)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("expire after %s", iVM.GetExpiredAt())
|
||||
|
||||
exp := iVM.GetExpiredAt()
|
||||
|
||||
err = host.DoSaveRenewInfo(ctx, self.UserCred, &bc, &exp)
|
||||
|
||||
@@ -110,11 +110,17 @@ type Manager interface {
|
||||
BatchPerformActionInContext(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult
|
||||
BatchPerformActionInContexts(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult
|
||||
Delete(session *mcclient.ClientSession, id string, body jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
DeleteWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
DeleteInContext(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error)
|
||||
DeleteInContextWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error)
|
||||
DeleteInContexts(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error)
|
||||
DeleteInContextsWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error)
|
||||
BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []SubmitResult
|
||||
BatchDeleteWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject) []SubmitResult
|
||||
BatchDeleteInContext(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult
|
||||
BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult
|
||||
BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult
|
||||
BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult
|
||||
}
|
||||
|
||||
type JointManager interface {
|
||||
|
||||
@@ -485,6 +485,10 @@ func (this *ResourceManager) DeleteInContext(session *mcclient.ClientSession, id
|
||||
return this.DeleteInContexts(session, id, body, []ManagerContext{{ctx, ctxid}})
|
||||
}
|
||||
|
||||
func (this *ResourceManager) DeleteInContextWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) {
|
||||
return this.DeleteInContextsWithParam(session, id, query, body, []ManagerContext{{ctx, ctxid}})
|
||||
}
|
||||
|
||||
func (this *ResourceManager) DeleteInContexts(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) {
|
||||
return this.deleteInContexts(session, id, nil, body, ctxs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user