mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1039 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-host-convert-sched-failed to release/2.5.0
* commit '0608fcad449c1206d3e80be93ee5c5732fe5cceb': baremetal: host convert failed fix: recode host convert codes to fix scheduler failure issues
This commit is contained in:
@@ -811,6 +811,14 @@ func FetchModelObjects(modelManager IModelManager, query *sqlchemy.SQuery, targe
|
||||
return nil
|
||||
}
|
||||
|
||||
func DoCreate(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (IModel, error) {
|
||||
ownerProjId, err := fetchOwnerProjectId(ctx, manager, userCred, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return doCreateItem(manager, ctx, userCred, ownerProjId, nil, data)
|
||||
}
|
||||
|
||||
func doCreateItem(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data jsonutils.JSONObject) (IModel, error) {
|
||||
dataDict := data.(*jsonutils.JSONDict)
|
||||
var err error
|
||||
|
||||
@@ -62,7 +62,7 @@ type IModelManager interface {
|
||||
AllowPerformCheckCreateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool
|
||||
PerformAction(ctx context.Context, userCred mcclient.TokenCredential, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error)
|
||||
|
||||
DoCreate(ctx context.Context, userCred mcclient.TokenCredential, kwargs jsonutils.JSONObject, data jsonutils.JSONObject, realManager IModelManager) (IModel, error)
|
||||
// DoCreate(ctx context.Context, userCred mcclient.TokenCredential, kwargs jsonutils.JSONObject, data jsonutils.JSONObject, realManager IModelManager) (IModel, error)
|
||||
|
||||
InitializeData() error
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package db
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -162,10 +161,6 @@ func (manager *SModelBaseManager) InitializeData() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) DoCreate(ctx context.Context, userCred mcclient.TokenCredential, kwargs jsonutils.JSONObject, data jsonutils.JSONObject, realManager IModelManager) (IModel, error) {
|
||||
return nil, fmt.Errorf("Do create not implement?")
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/pkg/util/timeutils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -36,14 +35,6 @@ func (manager *SResourceBaseManager) RawQuery(fields ...string) *sqlchemy.SQuery
|
||||
return manager.SModelBaseManager.Query(fields...)
|
||||
}
|
||||
|
||||
func (manager *SResourceBaseManager) DoCreate(ctx context.Context, userCred mcclient.TokenCredential, kwargs jsonutils.JSONObject, data jsonutils.JSONObject, realManager IModelManager) (IModel, error) {
|
||||
ownerProjId, err := fetchOwnerProjectId(ctx, manager, userCred, kwargs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return doCreateItem(realManager, ctx, userCred, ownerProjId, nil, data)
|
||||
}
|
||||
|
||||
func CanDelete(model IModel, ctx context.Context) bool {
|
||||
err := model.ValidateDeleteCondition(ctx)
|
||||
if err == nil {
|
||||
|
||||
@@ -380,7 +380,7 @@ func (self *SBaremetalGuestDriver) StartGuestDetachdiskTask(ctx context.Context,
|
||||
}
|
||||
|
||||
func (self *SBaremetalGuestDriver) StartGuestAttachDiskTask(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
return fmt.Errorf("Cannot attach disk from a baremetal serer")
|
||||
return fmt.Errorf("Cannot attach disk to a baremetal serer")
|
||||
}
|
||||
|
||||
func (self *SBaremetalGuestDriver) StartSuspendTask(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
|
||||
@@ -3272,7 +3272,7 @@ func (self *SHost) PerformConvertHypervisor(ctx context.Context, userCred mcclie
|
||||
if err != nil {
|
||||
return nil, httperrors.NewNotAcceptableError("Convert error: %s", err.Error())
|
||||
}
|
||||
guest, err := GuestManager.DoCreate(ctx, userCred, data, params, GuestManager)
|
||||
guest, err := db.DoCreate(GuestManager, ctx, userCred, nil, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -401,9 +401,6 @@ func (d *SchedData) fillNetworksInfo(sjson *simplejson.Json) error {
|
||||
if err != nil || net.Idx == "" {
|
||||
net = new(Network)
|
||||
net.Idx = s.Get("network").MustString()
|
||||
if net.Idx == "" {
|
||||
return fmt.Errorf("Invalid network desc: %s", s.MustString())
|
||||
}
|
||||
net.Wire = s.Get("wire").MustString()
|
||||
net.Driver = s.Get("driver").MustString()
|
||||
net.Exit = s.Get("exit").MustBool()
|
||||
|
||||
Reference in New Issue
Block a user