mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #619 in YUNIONIO/onecloud from ~WANYAOQI/onecloud:bugfix/wyq/misc-bugs-on-2.4 to release/2.4.0
* commit 'b241961dc06f480243a9f8dc4972e5498f60507c': fix release/2.4.0 bugs
This commit is contained in:
@@ -2348,9 +2348,9 @@ func (self *SHost) AllowPerformOffline(ctx context.Context,
|
||||
}
|
||||
|
||||
func (self *SHost) PerformOffline(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.Status != HOST_OFFLINE {
|
||||
if self.HostStatus != HOST_OFFLINE {
|
||||
self.GetModelManager().TableSpec().Update(self, func() error {
|
||||
self.Status = HOST_OFFLINE
|
||||
self.HostStatus = HOST_OFFLINE
|
||||
return nil
|
||||
})
|
||||
db.OpsLog.LogEvent(self, db.ACT_OFFLINE, "", userCred)
|
||||
@@ -2368,12 +2368,15 @@ func (self *SHost) AllowPerformOnline(ctx context.Context,
|
||||
|
||||
func (self *SHost) PerformOnline(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.HostStatus != HOST_ONLINE {
|
||||
self.GetModelManager().TableSpec().Update(self, func() error {
|
||||
_, err := self.GetModelManager().TableSpec().Update(self, func() error {
|
||||
self.LastPingAt = time.Now()
|
||||
self.HostStatus = HOST_ONLINE
|
||||
self.Status = BAREMETAL_RUNNING
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.OpsLog.LogEvent(self, db.ACT_ONLINE, "", userCred)
|
||||
logclient.AddActionLog(self, logclient.ACT_ONLINE, nil, userCred, true)
|
||||
self.SyncAttachedStorageStatus()
|
||||
|
||||
@@ -3,13 +3,13 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/serialx/hashring"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"fmt"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -96,7 +96,7 @@ func (self *SStoragecache) getHostId() (string, error) {
|
||||
sqlchemy.Equals(host.Field("host_status"), HOST_ONLINE),
|
||||
sqlchemy.IsTrue(host.Field("enabled")))).
|
||||
Join(storages, sqlchemy.AND(sqlchemy.Equals(storages.Field("storagecache_id"), self.Id),
|
||||
sqlchemy.Equals(storages.Field("status"), STORAGE_ONLINE),
|
||||
sqlchemy.In(storages.Field("status"), []string{STORAGE_ENABLED, STORAGE_ONLINE}),
|
||||
sqlchemy.IsTrue(storages.Field("enabled")))).
|
||||
Filter(sqlchemy.Equals(hoststorages.Field("storage_id"), storages.Field("id"))).All(&hosts)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -426,6 +427,7 @@ func (manager *SZoneManager) FetchZoneById(zoneId string) *SZone {
|
||||
zoneObj, err := manager.FetchById(zoneId)
|
||||
if err != nil {
|
||||
log.Errorf("%s", err)
|
||||
return nil
|
||||
}
|
||||
return zoneObj.(*SZone)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user